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

Demon x Gaming

Platinian
Original poster
May 7, 2024
5
1
3
23
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
 

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
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);
}
 

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
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);
}
 

Demon x Gaming

Platinian
Original poster
May 7, 2024
5
1
3
23
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);
}
 

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
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
 

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
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);
}
 
  • Like
Reactions: Demon x Gaming

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
Then under hack_thread...

C++:
Prop_set_Health = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);
  
Prop_set_MaxHealth = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);
 

Demon x Gaming

Platinian
Original poster
May 7, 2024
5
1
3
23
Then under hack_thread...

C++:
Prop_set_Health = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);

Prop_set_MaxHealth = (void(*)(void*, int)) getAbsoluteAddress(targetLibName, 0xOFFSET);
I tried but it's not working!?
 

Demon x Gaming

Platinian
Original poster
May 7, 2024
5
1
3
23
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);
 

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
Hmmm, not sure tbh. The code looks okay and works fine for me, weird.
 

AZFernandez

Platinian
Dec 8, 2023
19
3
3
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.
 

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
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.
LGL 3.2