HOW TO HOOK FIELD OFFSETS WHICH DO NO HAVE UPDATE METHOD?

Demon x Gaming

Platinian
Hey, this is my first time seeking for help on forum.

So basically I'm hacking a game name Hide Online I found some classes like Hunter, Prop etc. these classes do not have a private void Update() { } method. So, I want to know how can I hook the field offsets of the classes which do not have the Update() { } method.
@libModz
 
Use HunterControl Update and PropControl Update.

Hook hunter field offset instance from HunterControl class like this...


C++:
void (*old_HunterControl_Update)(void *instance);
void HunterControl_Update(void *instance) {
    if(instance!=nullptr) {
        void *hunter = *(void **) ((uint64_t) instance + 0x24);  // HunterControl_hunter
    }
    old_HunterControl_Update(instance);
}
 
Then you can hook fields from hunter class like this...

C++:
void (*old_HunterControl_Update)(void *instance);
void HunterControl_Update(void *instance) {
    if(instance!=nullptr) {
        void *hunter = *(void **) ((uint64_t) instance + 0x24);  // HunterControl_hunter
        *(int *) ((uint64_t) hunter + 0x6C) = 9999; // Hunter_health
    }
    old_HunterControl_Update(instance);
}
 
Then you can hook fields from hunter class like this...

C++:
void (*old_HunterControl_Update)(void *instance);
void HunterControl_Update(void *instance) {
    if(instance!=nullptr) {
        void *hunter = *(void **) ((uint64_t) instance + 0x24);  // HunterControl_hunter
        *(int *) ((uint64_t) hunter + 0x6C) = 9999; // Hunter_health
    }
    old_HunterControl_Update(instance);
}
It's working for Hunter but why not for Prop?

C++:
void (*old_PropControl_Update)(void *instance);
void PropControl_Update(void *instance) {
    if(instance!=nullptr) {
        void *prop = *(void **) ((uint64_t) instance + 0x34);
    if(PropHealth) {
        *(int *) ((uint64_t) prop + 0xAC) = 9999;
            }
    }
    old_PropControl_Update(instance);
}
 
In Hide Online, prop health (field offset) is obscured.
You'd be better off hooking these methods instead...

Prop_set_Health and Prop_set_MaxHealth
 
C++:
void (*Prop_set_Health)(void *instance, int value);
void (*Prop_set_MaxHealth)(void *instance, int value);

void (*old_PropControl_Update)(void *instance);
void PropControl_Update(void *instance) {
    if(instance!=nullptr) {
        void *prop = *(void **) ((uint64_t) instance + 0x34);    // PropControl_prop
        if(PropHealth) {
            if(prop!=nullptr) {
                Prop_set_Health(prop, 9999);
                Prop_set_MaxHealth(prop, 9999);
            }
        }
    }
    old_PropControl_Update(instance);
}
 
Then under hack_thread...

C++:
Prop_set_Health = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);
  
Prop_set_MaxHealth = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);
 
C++:
OBFUSCATE("1_Toggle_Prop Health"),

case 1:
isHealthP = boolean;
break;

void (*Prop_set_Health)(void *instance, int value);
void (*Prop_set_MaxHealth)(void *instance, int value);

void (*old_PropControl_Update)(void *instance);
void PropControl_Update(void *instance) {
    if(instance!=nullptr) {
        void *prop = *(void **) ((uint64_t) instance + 0x34);    // PropControl_prop
        if(isHealthP) {
            if(prop!=nullptr) {
                Prop_set_Health(prop, 9999);
                Prop_set_MaxHealth(prop, 9999);
            }
        }
    }
    old_PropControl_Update(instance);
}

MSHookFunction((void*)getRealOffset(0x587954), (void*) PropControl_Update, (void**)&old_PropControl_Update);
  
Prop_set_Health = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0x58280C);

Prop_set_MaxHealth = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0x5828AC);
 
Hmmm, not sure tbh. The code looks okay and works fine for me, weird.
Could you please tell me which modding template you are using? If it's something from lgl, did you add any helper libraries or anything else to it? This maybe why your codes may work for you, but may not work for someone else.
 
Back
Top Bottom