public class Player : MonoBehavior
{
// Fields
private float m_baseSpeed; // 0x68
}
void (*old_m_baseSpeed)(void *instance);
void m_baseSpeed(void *instance) {
if (speed6 > 1) {
*(float *) ((uint32_t) instance + 0x68) = speed6;
}
return old_m_baseSpeed(instance);
}
Did you hook to it with MSHookFunction or any other hooking tool?I tried and nothing happened.
void(*old_speed)(void *instance);
void speed(void *instance) {
if (isSpeed) {
*(float *) ((uint64_t) instance + FieldOffset) = 50.0;
}
old_speed(instance);
}
And
HOOK_LIB("libil2cpp.so", "UpdateOffset", speed, old_speed);
void(*_NoTut)(void *instance); //this can also be done within the player update hook
void NoTut(void *instance) {
if (NoTutOn) {
*(bool *) ((uint64_t) instance + 0xC) = true;
}
else {
*(bool *) ((uint64_t) instance + 0xC) = *(bool *) ((uint64_t) instance + 0xC);
}
_NoTut(instance);
}
HOOK_LIB("libil2cpp.so", "0x52C5EC", NoTut, _NoTut); //1
C++:void(*old_speed)(void *instance); void speed(void *instance) { if (isSpeed) { *(float *) ((uint64_t) instance + FieldOffset) = 50.0; } old_speed(instance); } And HOOK_LIB("libil2cpp.so", "UpdateOffset", speed, old_speed);
like:
View attachment 413878
you can use update() or fixedUpdate() to hook
for my hook:
C++:void(*_NoTut)(void *instance); //this can also be done within the player update hook void NoTut(void *instance) { if (NoTutOn) { *(bool *) ((uint64_t) instance + 0xC) = true; } else { *(bool *) ((uint64_t) instance + 0xC) = *(bool *) ((uint64_t) instance + 0xC); } _NoTut(instance); } HOOK_LIB("libil2cpp.so", "0x52C5EC", NoTut, _NoTut); //1
Update Hook Offset: (Class Name - WeaponInterface)
// Token: 0x06002E73 RID: 11891 RVA: 0x0000209A File Offset: 0x0000029A
[Token(Token = "0x6002E73")]
[Address(RVA = "0x121B3D8", Offset = "0x121B3D8", VA = "0x121B3D8", Slot = "4")]
public virtual void Update()
{
}
Bullet Counter Field Offset: (Class Name - WeaponInterface)
// Token: 0x040033F3 RID: 13299
[Token(Token = "0x40033F3")]
[FieldOffset(Offset = "0x90")]
[HideInInspector]
public int BulletsInClip;
Ammo Field Offset: (Class Name - WeaponInterface)
// Token: 0x04003409 RID: 13321
[Token(Token = "0x4003409")]
[FieldOffset(Offset = "0x110")]
public CapacityClass CapacityProperties;
Current Ammo + Max Ammo Field Offsets: (Class Name - CapacityClass)
using System;
using Il2CppDummyDll;
// Token: 0x02000999 RID: 2457
[Token(Token = "0x2000999")]
[Serializable]
public class CapacityClass
{
// Token: 0x06002DBA RID: 11706 RVA: 0x0000209A File Offset: 0x0000029A
[Token(Token = "0x6002DBA")]
[Address(RVA = "0x1429EF0", Offset = "0x1429EF0", VA = "0x1429EF0")]
public CapacityClass()
{
}
// Token: 0x0400331B RID: 13083
[Token(Token = "0x400331B")]
[FieldOffset(Offset = "0x14")]
[Attribute(Name = "RangeAttribute", RVA = "0x9FE1BC", Offset = "0x9FE1BC")]
public int MagazineSize;
// Token: 0x0400331C RID: 13084
[Token(Token = "0x400331C")]
[FieldOffset(Offset = "0x18")]
public int TotalAmmo;
}
Initialize Hooks: (Android Studio)
void *hack_thread(void *) {
LOGI(OBFUSCATE("pthread created"));
do {
sleep(1);
} while (!isLibraryLoaded(targetLibName));
LOGI(OBFUSCATE("%s has been loaded"), (const char *) targetLibName);
#if defined(__aarch64__)
LOGI(OBFUSCATE("Hooking Addresses (x64-Bit)... "));
HOOK_LIB("libil2cpp.so", "0x121B3D8", HookAmmo, UnHookAmmo);
GetCapacityClass = (void *)getAbsoluteAddress(targetLibName, 0x1429EF0);
LOGI(OBFUSCATE("Hooking Addresses (x64-Bit) - Completed "));
#else
LOGI(OBFUSCATE("Hooking Addresses (x32-Bit)... "));
HOOK_LIB("libil2cpp.so", "0x121B3D8", HookAmmo, UnHookAmmo);
GetCapacityClass = (void *)getAbsoluteAddress(targetLibName, 0x1429EF0);
LOGI(OBFUSCATE("Hooking Addresses (x32-Bit) - Completed "));
#endif
return NULL;
}
My Hook: (Android Studio - Project)
bool unlimitedAmmoToggle;
int bulletCounter, currentAmmo, maxAmmo;
void *GetCapacityClass;
void (*UnHookAmmo)(void *instance);
void HookAmmo(void *instance) {
if (instance != NULL) {
if (GetCapacityClass != NULL) {
if (unlimitedAmmoToggle) {
if (bulletCounter == 0 && *(int *) ((uint64_t) instance + 0x90) != 0) {
bulletCounter = *(int *) ((uint64_t) instance + 0x90);
currentAmmo = *(int *) ((uint64_t) GetCapacityClass + 0x14);
maxAmmo = *(int *) ((uint64_t) GetCapacityClass + 0x18);
LOGI(OBFUSCATE("Bullet Counter: %d"), bulletCounter);
LOGI(OBFUSCATE("Current Ammo: %d"), currentAmmo);
LOGI(OBFUSCATE("Max Ammo: %d"), maxAmmo);
}
*(int *) ((uint64_t) instance + 0x90) = 90;
} else {
if (bulletCounter != 0) {
*(int *) ((uint64_t) instance + 0x90) = bulletCounter;
bulletCounter = 0;
}
return UnHookAmmo(instance);
}
}
}
}
Final Results: (Android Studio - Logcat)
I/Mod_Menu: Bullet Counter: 30 //Correct Value & Offset (WeaponInterface)
I/Mod_Menu: Current Ammo: 840893416 //Incorrect Value & Offset (CapacityClass)
I/Mod_Menu: Max Ammo: -1191163896 //Incorrect Value & Offset (CapacityClass)
How to unlink functions in IL2CPP and other native games
~Read this tutorial first: Basic Hooking Tutorial ~Use this template to do this: LGLTeam/Android-Mod-Menu ~You need some knowledge of C++ to understand this (You can learn C++ on sites such as Geeks For Geeks, TutorialsPoint, Youtube etc. or from apps in the Play Store) Before I start, what do...platinmods.com
This Might Help You
Glad to hear that
bool unlimitedAmmoToggle;
int weaponOwner, bulletCounter, currentAmmo, maxAmmo;
void *GetCapacityClass;
void *GetWeaponOwnerClass;
void (*UnHookAmmo)(void *instance);
void HookAmmo(void *instance) {
if (instance != NULL) {
//*
// private Enumerations.WeaponOwner weaponOwner;
//*
GetWeaponOwnerClass = *(void **) ((uint64_t) instance + 0x30C); //Field Offset For WeaponOwner Enumeration
if (GetWeaponOwnerClass != NULL) {
//*
// public CapacityClass CapacityProperties;
//*
GetCapacityClass = *(void **) ((uint64_t) instance + 0x110); //Field Offset For Capacity Class
if (GetCapacityClass != NULL) {
weaponOwner = *(int *) ((uint64_t) GetWeaponOwnerClass); //Converting Enum to Int
if (weaponOwner == 0) { // ENUMS: [0 = Player; 1 = Enemy; 2 = Friendly; 3 = ServerPlayer]
if (unlimitedAmmoToggle) {
if (bulletCounter == 0 && *(int *) ((uint64_t) instance + 0x90) != 0) {
bulletCounter = *(int *) ((uint64_t) instance + 0x90);
currentAmmo = *(int *) ((uint64_t) GetCapacityClass + 0x14);
maxAmmo = *(int *) ((uint64_t) GetCapacityClass + 0x18);
LOGI(OBFUSCATE("Bullet Counter: %d"), bulletCounter);
LOGI(OBFUSCATE("Current Ammo: %d"), currentAmmo);
LOGI(OBFUSCATE("Max Ammo: %d"), maxAmmo);
}
*(int *) ((uint64_t) instance + 0x90) = 90;
*(int *) ((uint64_t) GetCapacityClass + 0x14) = 999;
*(int *) ((uint64_t) GetCapacityClass + 0x18) = 999;
} else {
if (bulletCounter != 0) {
*(int *) ((uint64_t) instance + 0x90) = bulletCounter;
*(int *) ((uint64_t) GetCapacityClass + 0x14) = currentAmmo;
*(int *) ((uint64_t) GetCapacityClass + 0x18) = maxAmmo;
bulletCounter = 0;
}
UnHookAmmo(instance);
}
}
}
}
}
}
how hook this singleton?Glad to hear that
You should post that on a separate thread, that way more people will help you.
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies