Help! Hooking fields

Daleon228_09

Solid & Active Platinian
Original poster
Aug 19, 2022
63
9
8
Poland
void (*old_update)(DWORD*);
void update(DWORD* instance)
{
*(int*)((uint64_t)instance + 0xC) = 99999;
old_update(instance);
}

void Create()
{
MH_Initialize();

MH_CreateHook(reinterpret_cast<LPVOID>(L::GameAssembly + 0x764500), &update, (LPVOID*)&old_update);
MH_EnableHook(reinterpret_cast<LPVOID>(L::GameAssembly + 0x764500));
}


Hello

Please help me hook this field, it doesnt hooking
 

ASDFGHJKLQWE

Solid & Active Platinian
Jul 10, 2022
65
19
8
Nepal
If you are using lgl mod menu the use this
Code:
bool Health;
void (*old_FunctionExample)(void *instance);
void FunctionExample(void *instance) {
    if (instance != NULL) {
        if (Health) {
            *(int *) ((uint64_t) instance + 0x48) = 999;
        }
    }
    return old_FunctionExample(instance);
}

Void hack thread {
HOOK_LIB("libFileB.so", "0x123456", FunctionExample, old_FunctionExample);
}
 
  • Like
Reactions: Sbyky

Sbyky

Approved Modder
Approved Modder
Oct 4, 2022
72
2,215
183
Pakistan
for hooking fields and k__backingfields

Code:
struct {
    bool Update = false;
} MyMod;



void (*old_NameOfYourChoice)(void *instance);
void NameOfYourChoice(void *instance) {
    if (instance != NULL) {
        if (MyMod.Update) {
            *(int *) ((uint64_t) instance + 0xC) = 99999;
        }
    }
    return old_NameOfYourChoice(instance);
}



    HOOK_LIB("libil2cpp.so", "0x764500", NameOfYourChoice, old_NameOfYourChoice);



            OBFUSCATE("Toggle_Whatever Your Hook Does"),



        case 0: // use your case number
            MyMod.Update = boolean;
            break;
you just gotta find the right method to hook, Update() works most of the times but in rare cases when it doesn't work for you or when the class doesn't have an Update() method, try hooking another method from the same class as the field that's getting called, and keep on trying, i hope this helps
 
Last edited: