I've got a button on my menu to add 1k currency each time it is pressed:
To get `playerDataManager`, I hook the `Initialize` function:
And then I also get the `AddGem` function:
This only works if I call `AddGem` from inside my hooked function. If I store the address and reference it later, it crashes the game.
C++:
case 5:
if(playerDataManager) {
AddGem(playerDataManager, 1000, nullptr, nullptr);
}
break;
C++:
void(*old_PlayerDataManager_Initialize)(void *instance);
void PlayerDataManager_Initialize(void *instance) {
old_PlayerDataManager_Initialize(instance);
playerDataManager = instance;
//AddGem(instance, 100000, nullptr, nullptr);
}
C++:
HOOK("0xE0A634", PlayerDataManager_Initialize, old_PlayerDataManager_Initialize);
C++:
AddGem = (void(*)(void*, u_long, void*, void*))getAbsoluteAddress(targetLibName, 0xE0D2DC);