- Gender
- Male
- Device
- Realme GT Master Edition - Android 13
- Country
- Bangladesh
Heya Everyone . Hope Everyone is doing alright. Today I am making this tutorial as per @DDeveloper's Request. On this tutorial I will show you how to use basic hooks.
Lets Get Started ....
Lets Say We Are Going To hook a function called get_Coins.
First of all we need to copy a original instance of that function.
Next We need to make our function to replace that old function on the game after hooking.
Now We can modify the function as per we want. But Most of the case we simply return a value. Lets do that for the sake of this tutorial.
First we need to check this function's validity on runtime. We can simply use "if" statement for that .
Now Here we can if instance is valid we can simply return our value . (Knowledge about data types will help a bit).
But when its not valid (and for some other cases) we should return that original instance we copied.
Now the code shlould look like this.
Now if you use Mod menus you can simply use your switch boolean here.
At last hook you offsets on hack thread (LGL Menu) using MSHook or A64InlineHook.
For other returning types just change the data type of your hook functions. Like ...
Thats all for today. Hope this tutorial helps you a bit .
Lets Get Started ....
Lets Say We Are Going To hook a function called get_Coins.
First of all we need to copy a original instance of that function.
C++:
int (*org_getCoins)(void *instance);
Next We need to make our function to replace that old function on the game after hooking.
C++:
int getCoins(void *instance) {
}
Now We can modify the function as per we want. But Most of the case we simply return a value. Lets do that for the sake of this tutorial.
First we need to check this function's validity on runtime. We can simply use "if" statement for that .
C++:
int getCoins(void *instance) {
if (instance != NULL) {
}
}
Now Here we can if instance is valid we can simply return our value . (Knowledge about data types will help a bit).
C++:
int getCoins(void *instance) {
if (instance != NULL) {
return 99999;
}
}
But when its not valid (and for some other cases) we should return that original instance we copied.
C++:
int getCoins(void *instance) {
if (instance != NULL) {
return 99999;
}
return org_getCoins(instance);
}
Now the code shlould look like this.
C++:
int (*org_getCoins)(void *instance);
int getCoins(void *instance) {
if (instance != NULL) {
return 99999;
}
return org_getCoins(instance);
}
Now if you use Mod menus you can simply use your switch boolean here.
C++:
int getCoins(void *instance) {
if (instance != NULL) {
if (feature1){ //your switch boolean
return 99999;
}
}
return org_getCoins(instance);
}
At last hook you offsets on hack thread (LGL Menu) using MSHook or A64InlineHook.
C++:
MSHookFunction((void *) getAbsoluteAddress(targetLibName, string2Offset(OBFUSCATE_KEY("0x123456", 'a'))), (void *) getCoins, (void **) &org_getCoins);
For other returning types just change the data type of your hook functions. Like ...
C++:
float (*org_getCoins)(void *instance);
float getCoins(void *instance) {
if (instance != NULL) {
return 99999.0f;
}
return org_getCoins(instance);
}
C++:
bool (*org_isUnlocked)(void *instance);
bool isUnlocked(void *instance) {
if (instance != NULL) {
return true;
}
return org_isUnlocked(instance);
}
Thats all for today. Hope this tutorial helps you a bit .
Attachments
-
2.4 KB Views: 134
-
2.5 KB Views: 130
-
2.5 KB Views: 107