Help! Game crashes when hooking Update() method

Denka

Platinian
Hi. When i hook update method the game crashes. Here is my update and old update method:
Code:
void (*GoldHack_old)(void *instance);
void GoldHack(void *instance){
    if(instance != NULL && NM.isMajor){
        *(float *) ((uint64_t) instance + 0x300) = 999.5f;
    }
    return GoldHack_old(instance);
}
And here is my hook call: A64HookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x655D98), (void *)GoldHack, (void **)&GoldHack_old);
Help me pls
 
void (*old_GoldHack)(void *instance);
void GoldHack(void *instance){
if(instance != NULL && NM.isMajor){
*(float *) ((uint64_t) instance + 0x300) = 999.5f;
}
return old_GoldHack(instance);
}

A64HookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x655D98), (void *)GoldHack, (void **)&old_GoldHack);
 
Last edited:
NVM I got it working. FYI if someone else runs into this issue I am sharing what worked for me:

Say you want to hack ammo for example. In a lot of games you would have a getAmmo and/or setAmmo. But knowing my luck, in my game, the only thing "feasible" I was able to find in my dump.cs file with the word "Ammo" was AmmoInMag, and it's a field offset. There are no methods with the word "Ammo" whatsoever. I have an Update() method in this class but whenever I hook the AmmoInMag field offset to the Update() method the game crashes. I tried other Update/LateUpdate/FixedUpdate methods from other classes and I even tried Start() and Awake() methods with no success...kept crashing. In this case it's pretty evident that the field offset just isn't going to work for whatever reason. At least I don't know how to get it working. HOWEVER, I did spot a Void Refill() method in the same class. So I hooked it like this and it worked! I got infinite Ammo:


Code:
void (*Anyname)(void *instance,int value);
void (*_voidinthooking)(void *instance);
void Voidinthooking(void *instance) {
    if (instance != NULL) {
        if (VoidHookingint) {
            Anyname(instance, 999); //you can replace it with any number you want
            }
            }
            return _voidinthooking(instance);
            }



HOOK_LIB("libil2cpp.so","0xUpdateOFFSET",Voidinthooking,_voidinthooking);
Anyname = (void (*)(void *, int))getAbsoluteAddress("libil2cpp.so",0x(TheRefillOFFSET));



So in conclusion look for a method that has to do with whatever field offset you're trying to hook with an Update (which is crashing the game), even if it's not "worded" with what you think it should be. "Refill" has to do with "Ammo". So Voila!
 
Back
Top Bottom