This is the AMP version of this page.
If you want to load the real page instead, click this text.

Help! Hooking fields

Daleon228_09

Solid & Active Platinian
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
 
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);
}
 
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:
Make sure instance is NULL before you pass it, so the game doesn't crash. Anyways, since you're modding PC, make sure you check that GameAssembly actually resembles to "inline uintptr_t UnityGameAssembly = (uintptr_t)GetModuleHandleA("GameAssembly.dll");" Otherwise, nothing will work. Inline is also needed to pass it's code to other header files and functions. Don't use Dword for your params.