Tutorial Basic Hooking Tutorial

Tiuu

Awesome Active Platinian
Original poster
Skilled
May 23, 2017
117
775
193
Hey guys, it's SliceCast here. This tutorial is for Advanced Modders who wants to step up their games to get better! Could be for newbies too.
I will show you some basics examples on how to hook a function.

Now let's say our Type Functions are (int, float, bool, double) and that we're doing a int/integer type.

C++:
//the void *instance is a self-created variable.
int (*old_Kills)(void *instance);
int Kills(void *instance) {
    //Check if instance is NULL to prevent CRASH
    if (instance != NULL)
    {
        return 99999; //Return how many value
    }
    //return the original value (this code isn't really needed if you have a toggle/switch)
    return old_Kills(instance);
}
Also make sure to call your hooks with MsHook or your mod won't work.
Example:
C++:
MsHookFunction((void*)getAbsoluteAddress(OFFSETS), (void*)Kills, (void**)&old_Kills);
Field Hooking with Class

C++:
void(*old_GameMode_Update)(void *instance);
void GameMode_Update(void *instance) {
    if(instance != NULL) {
        if (xpPerKill) { //if Toggle
            *(int *) ((uint64_t) instance + 0x30) = 5000;
        }
    }
    old_GameMode_Update(instance);
}
Call the GameMode Update with MSHook

C++:
MSHookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x00000), (void *) GameMode_Update, (void **) &old_GameMode_Update);
If it's a bool, then simple. Just return/put "true" or "false".

If it's a float, then return a 99.0 or whatever.

This is way better than Patching. We don't need to use Hex Values for hooking. Hooking is way better, you can return any value you want.

I might make tutorial on how to do Function Pointers and Strings, but as of now just learn this.

:)
 
Last edited:

champ007

Platinian
Jul 23, 2020
6
2
3
28
Pune
I got it..but it seems for non il2cpp games.....what if I want to edit arm code through hxd for freeze?? Any specific code?? Can you explain?? Thanx for great tutorial
 
  • Like
Reactions: Cyber0860

Galaxy169

Platinian
Apr 28, 2020
23
8
3
23
Home
what if the game have not lateupadte function? where should i placee my hook?
Then use other methods available in the class i.e update, fixedupdate, etc... avoid using awake and start as they get called only once per object (unless you don't have any other choice).
 

DawnBreaker

Platinian
Nov 4, 2018
46
3,450
83
23
Earth
what make me confused is, how and where should i put that code ? i just know how to edit game that have il2cpp and globalmetada in it otherwise i dont know how to grab the assemblycsharp
 

Tiuu

Awesome Active Platinian
Original poster
Skilled
May 23, 2017
117
775
193
what make me confused is, how and where should i put that code ? i just know how to edit game that have il2cpp and globalmetada in it otherwise i dont know how to grab the assemblycsharp
[/QUOTE
basically what i'm getting out of this is,

[Hidden content]

only question is do i include the get_ part of my function?
No, it doesn't. Including the names in the code does not matter at all, you just need to memorize the method/function and make sure the code is used/recognize in Android Studio or whatever tool you're using it to compile with.
 

Tiuu

Awesome Active Platinian
Original poster
Skilled
May 23, 2017
117
775
193
what if the game have not lateupadte function? where should i placee my hook?
If your game doesn't have a late update, then then use other functions that calls the method 60 fps or create your own hooks, if not... Out of look :)
 

LEIIKUN

Retired Staff
Retired but loved <3
Oct 13, 2019
579
12,451
1,193
18
Davao
i know the basic c++ (really basic), but what i dont know is how and where to put that code. did you just put it on the assembly csharp ? isn't that make the game crash ?
Put it and hook it inside main.cpp. You can find main.cpp if you use the lgl mod menu template.
 
  • Like
Reactions: TeddyMods

DawnBreaker

Platinian
Nov 4, 2018
46
3,450
83
23
Earth
Put it and hook it inside main.cpp. You can find main.cpp if you use the lgl mod menu template.
lgl mod menu ? where i can get one ? oh and maybe this is out of context but.. what code that when you buy something in the game, instead of decreasing its increasing ? because some game that i mod,the value is turning into minus even though the value that i mess with is a int, a flat number.
ty for your response btw
 

DawnBreaker

Platinian
Nov 4, 2018
46
3,450
83
23
Earth
and how to edit this ?
public partial class ActorMonster : ActorBase
{
// Token: 0x060000AF RID: 175 RVA: 0x00002050 File Offset: 0x00000250
[Token(Token = "0x60000A2")]
[Address(RVA = "0xBDAF90", Offset = "0xBDAF90", VA = "0xBDAF90", Slot = "33")]
protected virtual void Attack()
{
}
}

i want the monster become unable to attack me but instead edit it on hex editor ( i already do that and yes it work ) that can't be turned off, i want this function have a switch
 

LEIIKUN

Retired Staff
Retired but loved <3
Oct 13, 2019
579
12,451
1,193
18
Davao
and how to edit this ?
public partial class ActorMonster : ActorBase
{
// Token: 0x060000AF RID: 175 RVA: 0x00002050 File Offset: 0x00000250
[Token(Token = "0x60000A2")]
[Address(RVA = "0xBDAF90", Offset = "0xBDAF90", VA = "0xBDAF90", Slot = "33")]
protected virtual void Attack()
{
}
}

i want the monster become unable to attack me but instead edit it on hex editor ( i already do that and yes it work ) that can't be turned off, i want this function have a switch
Learn patching instead of using hex editor so you could turn it off. We already have a tutorial here on platinmods, search it.
 

DawnBreaker

Platinian
Nov 4, 2018
46
3,450
83
23
Earth
Learn patching instead of using hex editor so you could turn it off. We already have a tutorial here on platinmods, search it.
i have click all of the tutorial threads on this site, i learn modding using ida pro, hex patching, making mod menu (open dll), basic modding, etc from @DVAツ , @G-Bo ッ @AndnixSH , you @LEIIKUN , and other ( big thanks for all of you that want to share your knowledge in here ) . but, when i see the comment on How to make a Floatable Mod Menu [Team LGL] - {Beginners Tutorial} {All Explained} - Part 3 - Platinmods.com - Android & iOS MODs, Mobile Games & Apps , lot of friends in there saying that is morelike patching than hooking or something like that, that's why im curious what is a real hooking look like, and yeah although i almost reach the end of the tutorial threads, im not find something like " hooking tutorial full explained" that's why i asked in this thread's comment section about how to hook with a whole function than just hook with a offset. hooking with offset it's just like modding using hex editor with extra step. ty for your reply btw
 

LEIIKUN

Retired Staff
Retired but loved <3
Oct 13, 2019
579
12,451
1,193
18
Davao
i have click all of the tutorial threads on this site, i learn modding using ida pro, hex patching, making mod menu (open dll), basic modding, etc from @DVAツ , @G-Bo ッ @AndnixSH , you @LEIIKUN , and other ( big thanks for all of you that want to share your knowledge in here ) . but, when i see the comment on How to make a Floatable Mod Menu [Team LGL] - {Beginners Tutorial} {All Explained} - Part 3 - Platinmods.com - Android & iOS MODs, Mobile Games & Apps , lot of friends in there saying that is morelike patching than hooking or something like that, that's why im curious what is a real hooking look like, and yeah although i almost reach the end of the tutorial threads, im not find something like " hooking tutorial full explained" that's why i asked in this thread's comment section about how to hook with a whole function than just hook with a offset. hooking with offset it's just like modding using hex editor with extra step. ty for your reply btw
Uhmm, inside the lgl mod menu original 'main.cpp', you can find several hooking examples, it is a completely example. Find it out and analyze!

lot of friends in there saying that is morelike patching than hooking
Yeah, indeed that video tutorial is showing a patching instead of hooking. Patching is when you still use hex codes.
 

DawnBreaker

Platinian
Nov 4, 2018
46
3,450
83
23
Earth
Uhmm, inside the lgl mod menu original 'main.cpp', you can find several hooking examples, it is a completely example. Find it out and analyze!


Yeah, indeed that video tutorial is showing a patching instead of hooking. Patching is when you still use hex codes.
i find the hooking example from the original lgl mod menu and i think i already find it out, but i have feeling it will be a million of trial and error. ty for your response
 

About us

  • Welcome to platinmods.com! We are proud to present you the place which let's dreams come true! Focusing on quality and trust we have spend much time to build a gaming community fitting to your wishes and needs. Actually we offer you the finest MODs and Games of the Android section and we slowly expand to the iOS section as well. But games, Android MODs & iOS MODs are not the only things we can offer you. We have tutorials, tools, a very friendly, active and solid community which will help you with any problem you have =) Your happiness is our goal. We hope you enjoy!

Forum statistics

Threads
53,101
Messages
1,563,308
Members
2,856,048
Latest member
Areeb.a