Numark
Awesome Active Platinian
Hey guys, it's SliceCast. So people have been asking, "how do you modify a set method instead of using get?". It's simple, since I'm a nice person, I don't mind sharing this information for you newbies or advanced modders. Let's get started.
Wait, before we actually start anything...
You need to read this tutorial first BEFORE WE START! If you already know how to hook, then skip onto the set tutorial.
So get your set method, we're gonna make our set method a function pointer. We will be splitting this function pointer because when your lib is loaded sometimes, the libil2cpp isnt loaded already, but your lib doesn't know that and already tries to read the address which will result in a null pointer or crash. So here's how this will work.
Now what were gonna do is use "set_kills" and paste it in our class hook which is get_ that we have made. All you need to do now is do "set_kills(instance, 999999);" without the parenthesis. It's really simple to do.
If this crashes, then you need to log the crashes and find out why.
It's pretty easy and simple. Last thing we need to do now is call the function pointer just like calling your MSHooks to make your mods work.
Also make sure to call your hooks (I forgot)
Note: HOOK_LIB is from LGL's mod menu template.
Credits to SliceCast & Octowolve.
Discord: Slicey#5894
Wait, before we actually start anything...
You need to read this tutorial first BEFORE WE START! If you already know how to hook, then skip onto the set tutorial.
Basic Hooking Tutorial
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...
platinmods.com
So get your set method, we're gonna make our set method a function pointer. We will be splitting this function pointer because when your lib is loaded sometimes, the libil2cpp isnt loaded already, but your lib doesn't know that and already tries to read the address which will result in a null pointer or crash. So here's how this will work.
C++:
void (*set_kills)(void *_instance, int AmountOfKills);
Now what were gonna do is use "set_kills" and paste it in our class hook which is get_ that we have made. All you need to do now is do "set_kills(instance, 999999);" without the parenthesis. It's really simple to do.
C++:
//the void *instance is a self-created variable.
int (*old_get_Kills)(void *instance);
int get_Kills(void *instance) {
//Check if instance is NULL to prevent CRASH
if (instance != NULL)
{
set_kills(instance, 999999); //Function Pointer mod
}
//return the original value (this code isn't really needed if you have a toggle/switch)
return old_get_Kills(instance);
}
If this crashes, then you need to log the crashes and find out why.
It's pretty easy and simple. Last thing we need to do now is call the function pointer just like calling your MSHooks to make your mods work.
C++:
set_kills = (void (*)(void *, int))getRealOffset(OFFSET);
Also make sure to call your hooks (I forgot)
Note: HOOK_LIB is from LGL's mod menu template.
C++:
HOOK_LIB("libil2cpp.so", "0x00000", get_kills, old_get_kills);
Credits to SliceCast & Octowolve.
Discord: Slicey#5894
Last edited: