Help! How to call offset?

Hooking a void method example: private void EndRound() {}

1) Hook it like so...

C++:
void (*EndRound)(void *instance);

2) Create a boolean switch for EndRound, make sure it has a different name than the hooked method name, like so...

C++:
bool EndCurrentRound;

Since this is a void function which can't return anything, we must call it through an update method, preferably one from the same class. This can be LateUpdate, Update, FixedUpdate etc.

3) Create the update hook like so...

C++:
void (*old_ClassName_Update)(void *instance);
void ClassName_Update(void *instance) {
    if(instance!=nullptr) {
        if(EndCurrentRound) {
            EndRound(instance);
            EndCurrentRound=false;  // because we only want to call the method once
        }
    }
    old_ClassName_Update(instance);
}

Now under hackthread we put this code...

C++:
HOOK("0xOFFSET", ClassName_Update, old_ClassName_Update);  // Add offset of update method

EndRound = (void(*)(void*)) getAbsoluteAddress(targetLibName, 0xOFFSET);  // Add offset of EndRound method

Next we add a button to our menu and the case, like so...

C++:
OBFUSCATE("XX_Button_END ROUND"),  // XX = add number at start to link to case


case XX:
    EndCurrentRound = !EndCurrentRound;
    break;
 
  • Like
Reactions: nowhere_222