Help! About Button Hook - LGLTeam Android Mod Menu

TFive

Platinian
Original poster
May 5, 2019
16
63
78
Thai
Hello, I have a question about using button to hook method.
this is what i wrote but can't use the button What did I do wrong?

code:
update.png


loadValue.png


addintbutton.png


addintdoubleboolbutton.png
 
  • Like
Reactions: samber23

Galaxy169

Approved Modder
Approved Modder
Apr 28, 2020
29
1,336
178
Home
Remove curly brackets "{}" from the switch statements.

C++:
                        case 1:
                            if (btnAddIntButton != NULL)
                               AddIntButtonMethod1(btnAddIntButton, 500);
                            break;
 

Yaskashije

PMT Elite Modder
Staff member
Modding-Team
Sep 9, 2018
4,384
851,078
1,213
Minkowski Space
Remove curly brackets "{}" from the switch statements.

C++:
                        case 1:
                            if (btnAddIntButton != NULL)
                               AddIntButtonMethod1(btnAddIntButton, 500);
                            break;
That's not a must; it makes no difference wether you call if(...) xxxx; or if(...){xxxx;} as long as xxxx is a "one liner"
Moreover, if(...){} allows for more "lines" for a single if.
 
  • Like
Reactions: CM_OfficialYT

Quachty2501

Rookie
Sep 18, 2021
4
0
1
24
Viet Nam
help hooking OnUpdate





void (*old_ActorDefaultControlPlayer_OnUpdate) (void *instance);

void (*OnClickFishing) (void *instance) = (void *()(void *))getAbsoluteAddress("libil2cpp.so", 0xB6108648);

void ActorDefaultControlPlayer_OnUpdate(void *instance){
if (instance != NULL && feature3){
uint _fishingState = (uint) ((uint)instance + 0x20C);
if (_fishingState == 0){
OnClickFishing(instance);
}
else if (_fishingState == 4){

}
}
old_ActorDefaultControlPlayer_OnUpdate(instance);
}
 

CM_OfficialYT

1/3 Games Approved
Jun 16, 2023
16
1
3
16
Philippines
That's not a must; it makes no difference wether you call if(...) xxxx; or if(...){xxxx;} as long as xxxx is a "one liner"
Moreover, if(...){} allows for more "lines" for a single if.
You are right and curly brackets makes the code more safer and not be able to pass from other switch.
 

CM_OfficialYT

1/3 Games Approved
Jun 16, 2023
16
1
3
16
Philippines
This example might solve your problem:

C++:
int iAmmo = 0;

void *sAmmoBtn;



void (*old_m_Count)(void *instance);
void m_Count(void *instance) {
if (instance != NULL) {
  if (sAmmoBtn != NULL) {
   *(int *) ((uint64_t) instance + 0x10) = iAmmo;
  }
}
return old_m_Count(instance);
}