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

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;
 

 
Thanks bro, I'll test it, I'll look carefully at how you explained it to learn
 
Here is another example, this time a void method with an int parameter.

Example: private void set_ammo(int ammo) {}

Again we hook it through an update method like so...

C++:
void (*set_ammo)(void *instance, int ammo);


bool UnlimitedAmmo;


void (*old_ClassName_Update)(void *instance);
void ClassName_Update(void *instance) {
    if(instance!=nullptr) {
        if(UnlimitedAmmo) {
            set_ammo(instance, 9999);
        }
    }
    old_ClassName_Update(instance);
}

Then under hackthread...
C++:
HOOK("0xOFFSET", ClassName_Update, old_ClassName_Update);

set_ammo = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);

Lastly make our switch & case...

C++:
OBFUSCATE("XX_ButtonOnOff_Unlimited Ammo"),


case XX:
    UnlimitedAmmo = boolean;
    break;


Hope this helps, if you need any more examples just ask.
 
I don't know if there is a way to send images here, but I want to call a function but it doesn't have Update, LateUpdate or FixedUpdate, this function that I want to call takes to a "public enum XPManager.eXPcat" which inside has several names like that, I'll give an example of "public const XPManager.eXPcat avakinlife_xp_reward_talking = 0;"
 

C++:
void (*AddXP)(void *instance, int inCat);


void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=nullptr) {
        AddXP(instance, XX);   // Replace XX with XPManager.eXPcat reward number of choice (0-16)
    }
    old_Update(instance);
}

Under hackthread...
C++:
HOOK("0xOFFSET", Update, old_Update);

AddXP = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0x24FD2A8);
 

Help me please To Hook This enum
 
Can you help me hook this enum?
 
How to call offset ?

// RVA: 0x4666D48 Offset: 0x4666D48 VA: 0x4666D48
public ClaimRewardHandle ClaimReward(string lReward, bool playSound = True, int count = 1, Action<IWebRequest> onRewardReceived) { }

It's very difficult, can you help me?
 

Attachments

  • 20240928_142639.jpg
    94.9 KB · Views: 60