Solved Hooks do not work correctly

Status
Not open for further replies.

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
So I found two fields:
Code:
public Int32 Damage; // 0x24 
public Int32 Mana; // 0x28

RVA: 0x64e368 VA: 0xc024e368
 public Void Update() { }
I wrote hooks using these fields and the update function, but only one of the hooks is in the game. If you remove one hook code, the second one will start working. How can I get both hooks to work? (I'm using lgl mod menu 3.2)

My code:
Code:
bool Damage = false;
bool Mana = false;

void (*old_Dmg)(void *instance);
void Dmg(void *instance) {
    if (instance != NULL) {
        if (Damage) {
            *(int *) ((uint64_t) instance + 0x24) = 999999999;
        }
    }
    return old_Dmg(instance);
}


void (*old_InfiniteMana)(void *instance);
void InfiniteMana(void *instance) {
    if (instance != NULL) {
        if (Mana) {
            *(int *) ((uint64_t) instance + 0x28) = 999999999;
        }
    }
    return old_InfiniteMana(instance);
}


HOOK_LIB("libil2cpp.so", "0x64e368", Dmg, old_Dmg);
HOOK_LIB("libil2cpp.so", "0x64e368", InfiniteMana, old_InfiniteMana);


OBFUSCATE("Toggle_Hit Kill"),
OBFUSCATE("Toggle_Infinite Mana"),


switch (featNum) {
        case 0:
            Damage = boolean;
            break;
        case 1:
             Mana = boolean;
             break;     
    }
}


If you do this, everything works, but I would like to run hacks on two different buttons
Code:
void (*old_DmgMana)(void *instance);
void DmgMana(void *instance) {
    if (instance != NULL) {
        if (Toggle) {
            *(int *) ((uint64_t) instance + 0x24) = 999999999;
            *(int *) ((uint64_t) instance + 0x28) = 999999999;
        }
    }
    return old_DmgMana(instance);

}
 

libModz

Awesome Active Platinian
Jun 2, 2022
171
30
28
UK
void (*old_DmgMana)(void *instance);
void DmgMana(void *instance) {
if (instance != NULL) {
if (Damage) {
*(int *) ((uint64_t) instance + 0x24) = 999999999;
}
if(Mana) {
*(int *) ((uint64_t) instance + 0x28) = 999999999;
}
}
old_DmgMana(instance);
}
 

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
void (*old_DmgMana)(void *instance);
void DmgMana(void *instance) {
if (instance != NULL) {
if (Damage) {
*(int *) ((uint64_t) instance + 0x24) = 999999999;
}
if(Mana) {
*(int *) ((uint64_t) instance + 0x28) = 999999999;
}
}
old_DmgMana(instance);
}
Everything was so simple, why didn’t I think of it... Thank you very much
 

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,884
15,702
2,120
27
Skyrim
Thread will be set to "solved" and closed.
1707525899959.png
 
Status
Not open for further replies.