Tutorial Get/Set Fields & Unlink Unity Functions (IL2CPP)

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

HelloWhyMe

Android Modding
Meme Tier VIP
Fleep Tier Donator
Dank Tier Donator
Apr 3, 2019
199
5,428
9
So, bois, listen up. I have a new tutorial for ya.
In my function pointers tutorial for android I mentioned Im gonna make a tutorial on how to get/set fields.
Also I will explain how to unlink functions.
So we gonna do this now. But what do I mean with "Unlinking". Well Imagine we have a Character Class, this class has ann Update function. Nice. And this class also has a function something like this

private void Die();

We all know


but we still dont wanna kill ourself when we hook the update function and just use it without any checks eh?

Example:
//This is a function pointer to the function private void Die
//Since this is a non-static function the first parameter is always the
//instance of the class (this)
void (*Character_Die)(void* instance) =  (void (*)(void*))getAbsoluteAddress("libIl2Cpp.so", 0x38E8168);

//Example hook for the update function in the Imaginary class Character
void(*old_Update)(void *instance);
void Update(void *instance) {
  //code comes here
Character_Die(instance);
}
But that would kill everyone and everything. Even you! yea not cool.

So by Unlinking it is ment to except yourself from it. or the enemy. So only a specific object gets to use it

So how would we do that now?

Well luckily we found a field (bool) that checks if its you:

private bool isMine; // 0x1D

BUT. its not in the same class. Actually its in the class CharacterAttributes
So we try to find an instance to this class. And UwU whats this. Our Character class has a field for CharacterAttributes!

private CharacterAttributes characterAttributes; // 0x1C

So we will use this instance to get the field in CharacterAttributes and check if is our character.

So how would that look like?

Something like this:
void (*Character_Die)(void* instance) =  (void (*)(void*))getAbsoluteAddress("libIl2Cpp.so", 0x38E8168);
void(*old_Update)(void *instance);
void Update(void *instance) {

  //get a pointer to the CharacterAttributes class
    void *getCharacterAttributes = *(void**)((uint64_t)instance + 0x1C);
    //check if valid pointer (not null)
    if(getCharacterAttributes){
        //get the bool from the field private bool isMine; //0x1D
        bool isMine = *(bool*)((uint64_t)getCharacterAttributes + 0x1D);
        //if its not ourself kill it
        if(!isMine){
            Character_Die(instance);
        }
    }

}
So know you successfully unlinked this carnage from yourself and everyone else dies except you. Damn....

Now, what if, you want to actually set a field?
Like we found a variable in the Character class that hold the value for the kills you made.

public int kills; //0x18

how we gonna set this? well its damn easy!

C++:
void(*old_Update)(void *instance);
void Update(void *instance) {
void *getCharacterAttributes = *(void**)((uint64_t)instance + 0x1C);
    //check if valid pointer (not null)
    if(getCharacterAttributes){
        //get the bool from the field private bool isMine; //0x1D
        bool isMine = *(bool*)((uint64_t)getCharacterAttributes + 0x1D);
        //we check if its us and then set the kills
        if(isMine){
            *(int*)((uint64_t)instance + 0x18) = 1337;
        }
     }
}
And what if the field is in another class? Well you do it like we did it with the boolean isMine. Simple
Well thats it for today. Hfgl on your journey =)
 
Last edited:

kylesmile

Full Member
Aug 26, 2020
1
102
0
wow thanks, worked like a charm. But only with non-static fields, how can I get and set the static field?

Static fields dumped from il2cpp:
    public static int a; // 0x00
    public static int b; // 0x04
 

Lukor

ded
Meme Tier VIP
Fleep Tier Donator
Dec 13, 2013
488
5,353
25
Static variables are not part of the class instance. They are created once per class und as such located somewhere in the data.
You probably have to reverse the class methods to find the offset from the base address.
 

tranhad

Newbie
Dank Tier Donator
Nov 24, 2017
2
1,988
0
When we do modding there will be problem with MD5 check sum right ? Do you have any idea how to ypass it ?
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods