public struct Boards {
// Token: 0x040006C4 RID: 1732
[Token(Token = "0x4000669")]
[FieldOffset(Offset = "0x0")]
public string description;
// Token: 0x040006C5 RID: 1733
[Token(Token = "0x400066A")]
[FieldOffset(Offset = "0x4")]
public string boardTex;
// Token: 0x040006C6 RID: 1734
[Token(Token = "0x400066B")]
[FieldOffset(Offset = "0x8")]
public int coinCost;
// Token: 0x040006C7 RID: 1735
[Token(Token = "0x400066C")]
[FieldOffset(Offset = "0xC")]
public int sodaCost;
// Token: 0x040006C8 RID: 1736
[Token(Token = "0x400066D")]
[FieldOffset(Offset = "0x10")]
public bool isAvailableToPlayers;
// Token: 0x040006C9 RID: 1737
[Token(Token = "0x400066E")]
[FieldOffset(Offset = "0x14")]
public PerkType perkType;
// Token: 0x040006CA RID: 1738
[Token(Token = "0x400066F")]
[FieldOffset(Offset = "0x18")]
public float perkAmount;
}
[Address(RVA = "0x411D7C", Offset = "0x411D7C", VA = "0x411D7C")]
private void SetBoard(Boards board) { }
[Address(RVA = "0x209D98", Offset = "0x209D98", VA = "0x209D98")]
private void SetBoard(Boards board) { }
[FieldOffset(Offset = "0x54")]
public Boards[] boards;
template <typename T>
struct monoArray
{
void* klass;
void* monitor;
void* bounds;
int max_length;
void* vector[1];
int getLength()
{
return max_length;
}
T getPointer()
{
return (T)vector;
}
};
// RVA: 0xA37D1C Offset: 0xA37D1C VA: 0xA37D1C
public static Type GetType(string typeName) { }
// RVA: 0xD007B4 Offset: 0xD007B4 VA: 0xD007B4
public static Object[] FindObjectsOfType(Type type) { }
monoArray<void**>* FindObjectsOfType(void* Type) {
static const auto green_fn = (monoArray<void**>*(*)(void*)) (getAbsoluteAddress("libil2cpp.so", 0xD007B4)); //Offset
return green_fn(Type);
}
void *GetType(monoString* Type) {
static const auto fn = (void* (*)(monoString*)) (getAbsoluteAddress("libil2cpp.so", 0xA37D1C)); //Offset
return fn(Type);
}
bool debug;
void (*old_MainMenu_update)(void *instance);
void MainMenu_update(void *instance) {
if (instance != NULL && debug) {
monoArray<void**>* objMaterial = FindObjectsOfType(GetType(CreateMonoString("BalanceMeterLogic")));
if(objMaterial != NULL) {
int length = objMaterial->getLength();
void **objects = objMaterial->getPointer();
for (int x = 0; x < length; x++) {
void *object = objects[x];
if (object != NULL) {
*(bool*)((uint64_t)object + 0x8) = false;
}
}
}
}
return old_MainMenu_update(instance);
}
//HackThread
HOOK_LIB("libil2cpp.so", "0x201EF8", MainMenu_update, old_MainMenu_update);
//switch case
case 11:
debug = boolean;
break;
}
Make sure the namespace is right. For an example, GetType("UnityEngine.Object, UnityEngine") since it's in UnityEngine.dll, if using Assembly-CSharp.dll --> ("WeaponController") without the namespace, if inside and it has a new class, struct, etc like WarRobots.Player, it'll be like ("WarRobots.Player")update: Im Trying To get the instance of another class using FindObjectOfType of Unity Engine
monoArray struct
C++:template <typename T> struct monoArray { void* klass; void* monitor; void* bounds; int max_length; void* vector[1]; int getLength() { return max_length; } T getPointer() { return (T)vector; } };
making the function pointer of this:
C#:// RVA: 0xA37D1C Offset: 0xA37D1C VA: 0xA37D1C public static Type GetType(string typeName) { } // RVA: 0xD007B4 Offset: 0xD007B4 VA: 0xD007B4 public static Object[] FindObjectsOfType(Type type) { }
function pointer:
C++:monoArray<void**>* FindObjectsOfType(void* Type) { static const auto green_fn = (monoArray<void**>*(*)(void*)) (getAbsoluteAddress("libil2cpp.so", 0xD007B4)); //Offset return green_fn(Type); } void *GetType(monoString* Type) { static const auto fn = (void* (*)(monoString*)) (getAbsoluteAddress("libil2cpp.so", 0xA37D1C)); //Offset return fn(Type); }
My Hook
C++:bool debug; void (*old_MainMenu_update)(void *instance); void MainMenu_update(void *instance) { if (instance != NULL && debug) { monoArray<void**>* objMaterial = FindObjectsOfType(GetType(CreateMonoString("BalanceMeterLogic"))); if(objMaterial != NULL) { int length = objMaterial->getLength(); void **objects = objMaterial->getPointer(); for (int x = 0; x < length; x++) { void *object = objects[x]; if (object != NULL) { *(bool*)((uint64_t)object + 0x8) = false; } } } } return old_MainMenu_update(instance); } //HackThread HOOK_LIB("libil2cpp.so", "0x201EF8", MainMenu_update, old_MainMenu_update); //switch case case 11: debug = boolean; break; }
what went wrong?
info: im using lgl mod menu 2.9
Reference: Find Instance of any class, fields, methods (numark)
Make sure the namespace is right. For an example, GetType("UnityEngine.Object, UnityEngine") since it's in UnityEngine.dll, if using Assembly-CSharp.dll --> ("WeaponController") without the namespace, if inside and it has a new class, struct, etc like WarRobots.Player, it'll be like ("WarRobots.Player")
// Namespace:
public class BalanceMeterLogic // TypeDefIndex: 4306
{
// Fields
private bool balancerFeatureOn; // 0x8
If it's empty, then leave it empty to like Type("BalanceMeterLogic")What if the namespace is none, like this:
C#:// Namespace: public class BalanceMeterLogic // TypeDefIndex: 4306 { // Fields private bool balancerFeatureOn; // 0x8
void (*old_RoomSettings_OnUpdate)(void *instance);
void RoomSettings_OnUpdate(void *instance) {
if(instance!=nullptr) {
monoArray<void**>* objMaterial = FindObjectsOfType(GetType(CreateString("PlayerInfo")));
if(objMaterial!=nullptr) {
int length = objMaterial->getLength();
void **objects = objMaterial->getPointer();
for (int i = 0; i < length; i++) {
void *object = objects[i];
if (object!=nullptr) {
*(int *)((uint64_t) object + 0x24) = 999999;
}
}
}
}
old_RoomSettings_OnUpdate(instance);
}
You can use FindObjectOfType instead FindObjectsOfType. The first one I said is not a monoArray, so you can use it, as it also only grabs one instance instead of all. Easier to use.I'm following the same tutorial but can't get it to work, nothing happens in game
C++:void (*old_RoomSettings_OnUpdate)(void *instance); void RoomSettings_OnUpdate(void *instance) { if(instance!=nullptr) { monoArray<void**>* objMaterial = FindObjectsOfType(GetType(CreateString("PlayerInfo"))); if(objMaterial!=nullptr) { int length = objMaterial->getLength(); void **objects = objMaterial->getPointer(); for (int i = 0; i < length; i++) { void *object = objects[i]; if (object!=nullptr) { *(int *)((uint64_t) object + 0x24) = 999999; } } } } old_RoomSettings_OnUpdate(instance); }
// RVA: 0x4389e80 VA: 0x7ffd51f99e80
public static Object FindObjectOfType(Type type) { }
if (Variables::EnableShootShotgun)
{
void* type = GameFunctions::GetType(GameFunctions::CreateIl2cppString(OBFUSCATE("WeaponSounds")));
void* object = GameFunctions::FindObjectOfType(type);
if (object)
{
*(bool*)((uint64_t)object + IsShotgunOffset) = string2Bool(OBFUSCATE("true"));
}
}
I'm using FindObjectOfType but it's still not working, the value doesn't change in gameYou can use FindObjectOfType instead FindObjectsOfType. The first one I said is not a monoArray, so you can use it, as it also only grabs one instance instead of all. Easier to use.
C++:// RVA: 0x4389e80 VA: 0x7ffd51f99e80 public static Object FindObjectOfType(Type type) { }
C++:if (Variables::EnableShootShotgun) { void* type = GameFunctions::GetType(GameFunctions::CreateIl2cppString(OBFUSCATE("WeaponSounds"))); void* object = GameFunctions::FindObjectOfType(type); if (object) { *(bool*)((uint64_t)object + IsShotgunOffset) = string2Bool(OBFUSCATE("true")); } }
void (*old_RoomSettings_OnUpdate)(void *instance);
void RoomSettings_OnUpdate(void *instance) {
if(instance!=nullptr) {
void *type = GetType(CreateString("PlayerInfo"));
void *object = FindObjectOfType(type);
if (object!=nullptr) {
*(int *)((uint64_t) object + 0x24) = 999999;
}
}
old_RoomSettings_OnUpdate(instance);
}
RVA OFFSET could be wrong or either calling the hook in a bad spot which will not workI'm using FindObjectOfType but it's still not working, the value doesn't change in game
C++:void (*old_RoomSettings_OnUpdate)(void *instance); void RoomSettings_OnUpdate(void *instance) { if(instance!=nullptr) { void *type = GetType(CreateString("PlayerInfo")); void *object = FindObjectOfType(type); if (object!=nullptr) { *(int *)((uint64_t) object + 0x24) = 999999; } } old_RoomSettings_OnUpdate(instance); }
It depends where you're calling the method from. Maybe try in another Update class. Make sure you log to see if the field is being called or to see if the instance is being used. I just tested mine with another class and it works fine for me. Add additional debugging/logs.I'm using FindObjectOfType but it's still not working, the value doesn't change in game
C++:void (*old_RoomSettings_OnUpdate)(void *instance); void RoomSettings_OnUpdate(void *instance) { if(instance!=nullptr) { void *type = GetType(CreateString("PlayerInfo")); void *object = FindObjectOfType(type); if (object!=nullptr) { *(int *)((uint64_t) object + 0x24) = 999999; } } old_RoomSettings_OnUpdate(instance); }
RVA OFFSET could be wrong or either calling the hook in a bad spot which will not work
void *(*Find_Object_Of_Type)(void*);
void *(*Get_Type)(monoString*);
void *FindObjectOfType(void* Type) {
return Find_Object_Of_Type(Type);
}
void *GetType(monoString* Type) {
return Get_Type(Type);
}
// Hackthread
Find_Object_Of_Type = (void*(*)(void*)) getAbsoluteAddress(targetLibName, 0x1C55DE4); // UnityEngine.CoreModule - UnityEngine - Object - FindObjectOfType(Type type)
Get_Type = (void*(*)(monoString*)) getAbsoluteAddress(targetLibName, 0x13CFCE0); // mscorlib - Sysytem - Type - GetType(string typeName)
I've tried hooking it to several different updates, the offsets are correct. It's not workingIt depends where you're calling the method from. Maybe try in another Update class. Make sure you log to see if the field is being called or to see if the instance is being used. I just tested mine with another class and it works fine for me. Add additional debugging/logs.
Nevermind, working now. ThanksIt depends where you're calling the method from. Maybe try in another Update class. Make sure you log to see if the field is being called or to see if the instance is being used. I just tested mine with another class and it works fine for me. Add additional debugging/logs.
Glad it works! Just be aware that there are two different FindObject. FindObjectsOfType will grab all the objects to create an instance, as it will slow down performance. As long as you don't call it in a player class I guess, call it in a good working Update class. FindObjectOfType with the S in its name, will grab one object. Less laggy, less work. Most likely, I like to mess with monoArrays for loops.Nevermind, working now. Thanks
It's working fine for some field offsets like ammo, but not working at all for others such as money. I tested the int money field offset with game guardian and it works fineGlad it works! Just be aware that there are two different FindObject. FindObjectsOfType will grab all the objects to create an instance, as it will slow down performance. As long as you don't call it in a player class I guess, call it in a good working Update class. FindObjectOfType with the S in its name, will grab one object. Less laggy, less work. Most likely, I like to mess with monoArrays for loops.
Hi bro, can tell me which game you are asking?It's working fine for some field offsets like ammo, but not working at all for others such as money. I tested the int money field offset with game guardian and it works fine
It depends where you're calling the method from. Maybe try in another Update class. Make sure you log to see if the field is being called or to see if the instance is being used. I just tested mine with another class and it works fine for me. Add additional debugging/logs.
I apologize for the inconvenience. Could you please provide the names of the games and the required versions (as well as the necessary methods/fields) where this method of finding an instance works? I tried several games, but no changes occurred. Either I chose unsuitable games or made mistakes in the code. Identifying the issue would be easier with a suitable game. Thank you for your understandingNevermind, working now. Thanks
The game I have modded is Pixel Gun 3D. A basic unity game that is obfuscated using BeeByte Obfuscation. This is where I made my real first Universal Unity Chams instead of using actual GL Hooks.I apologize for the inconvenience. Could you please provide the names of the games and the required versions (as well as the necessary methods/fields) where this method of finding an instance works? I tried several games, but no changes occurred. Either I chose unsuitable games or made mistakes in the code. Identifying the issue would be easier with a suitable game. Thank you for your understanding
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