Help! how to hook field offset has no update in lgl mod menu

Correct me if I'm wrong, but you can try this method

Imagine if we have data like this

C#:
// This class have Update method and CharacterData field
public class CharacterManager
{
    private CharacterData characterData; // 0x68

    // update method
    // RVA: 0x273C3CC Offset: 0x273B3CC VA: 0x273C3CC
    private void Update() { }
}

// This class doesn't have Update method, but this class used in CharacterManager
public class CharacterData
{
    private int characterHealth; // 0x60
}


Now we create Update hook function in our LGL mod menu
C++:
void (*orig_CharacterUpdate)(void *_this);
void CharacterUpdate(void *_this) {
    if (_this != NULL) {
        // so we can get the CharacterData class from CharacterManager
        // 0x273B3CC is the offset of Update method from CharacterManager
        // 0x68 is the offset of CharacterData class from CharacterManager
        // 0x60 is the offset of Health from CharacterData class
        // so 0x273B3CC + 0x68 + 0x60 = characterHealth
        *(int *) ((uint64_t) _this + 0x68 + 0x60) = 9999999; // you can set the health value here
        
    }
}

After that, we can use that hook with dobby or another hooking library
C++:
DobbyHook((void *) getAbsoluteAddress("libil2cpp.so",0x273B3CC), (void *) &CharacterUpdate, (void **) &orig_CharacterUpdate);
 
Start by finding references to the class that has no update. Find a class that has a pointer leading to that class. Once you find it, make some hooks for it.

or

You can use FindObjectOfType, it is a method in Unity Engine class within the dumps. Search for it, once searched, you need to create a hook for it. Find the object of the class that doesn't have update. Call those methods and hooks within a random class that has update. (Wouldn't recommend, but go ahead).
 
Back
Top Bottom