Help! Field offset hooking with switch

TimidNova

Platinian
Original poster
Aug 7, 2020
9
0
1
20
United states
so here's my hook

void (*old_isPremium)(void *instance);
void isPremium(void *instance) {
instanceBtn = instance;
if (instance != NULL) {
if (Premium) {
*(bool *) ((uint32_t) instance + 0x320) = true;

}
}
return old_isPremium(instance);
}

HOOK_LIB("libil2cpp.so", "0x156C100", isPremium, old_isPremium);

and then my switch case

case 5:
Premium = boolean;
break;

would this be the correct way to make it modify the value when the switch is on and then return when off?
 

ASDFGHJKLQWE

Solid & Active Platinian
Jul 10, 2022
65
19
8
Nepal
Your everything is right but just remove your
instanceBtn = instance; from that like this

void (*old_isPremium)(void *instance);
void isPremium(void *instance) {
if (instance != NULL) {
if (Premium) {
*(bool *) ((uint32_t) instance + 0x320) = true;

}
}
return old_isPremium(instance);
}

And try to use
This MSHookFunction((void*)getAbsoluteAddress("libil2cpp.so", 0x156C100), (void*)isPremium, (void**)&old_isPremium);

in the place of
HOOK_LIB("libil2cpp.so", "0x156C100", isPremium, old_isPremium);


And
Make sour your Switch will like this

OBFUSCATE("5_Toggle_Premium Unlock"),

And the case like this

Case 5:
Premium = boolean;
break;

Now you will not get any kind of problem
 
  • Like
Reactions: ren54321

FIDΞN

Platinian
Jan 8, 2022
5
1
3
17
Italy
Also If I use an Update function outside of the class how exactly would that work? Would I have to do anything special
then it's all about the instance, if you can get the instance of the field from another class then of course you can, here are some examples:

 

ASDFGHJKLQWE

Solid & Active Platinian
Jul 10, 2022
65
19
8
Nepal
how do i restore the field offset when it's turned on, when i turn off it's not restoring

how do i restore?
In full details
bool Premium = false;
void (*old_isPremium)(void *instance);
void isPremium(void *instance) {
if (instance != NULL) {
if (Premium) {
*(bool *) ((uint32_t) instance + 0x320) = true;

}
}
return old_isPremium(instance);
}

And try to use
This MSHookFunction((void*)getAbsoluteAddress("libil2cpp.so", 0x156C100), (void*)isPremium, (void**)&old_isPremium);

in the place of
HOOK_LIB("libil2cpp.so", "0x156C100", isPremium, old_isPremium);


And
Make sour your Switch will like this

OBFUSCATE("5_Toggle_Premium Unlock"),

And the case like this

Case 5:
Premium = boolean;
break;

It will restore it :);
 

GHr__><__

Solid & Active Platinian
May 22, 2020
71
3,434
1,193
Indonesia
Simple.
C++:
void (*old_isPremium)(void *instance);
void isPremium(void *instance) {
instanceBtn = instance;
if (instance != NULL) {

if (Premium) {
*(bool *) ((uint32_t) instance + 0x320) = Premium;

}
}
return old_isPremium(instance);
}

HOOK_LIB("libil2cpp.so", "0x156C100", isPremium, old_isPremium);
 
  • Like
Reactions: ASDFGHJKLQWE