Solved Access Argument Function / Method

Status
Not open for further replies.

Kaorin333

Solid & Active Platinian
Original poster
Jun 11, 2022
89
9
8
34
Germany
Hi i would like to know how i can access a method in an argument,


C++:
//example, not real code

//dnspy class with these functions
LifePlayer{
    LifePlayer();
    int getLife(); //0x111111
}

int (*LifePlayer)(void* instance);
void Damage(void* instance, LifePlayer life, bool b){
  
    int x = *(int*)((uint64_t)instance + life).getLife();
    //or
    int x = LifePlayer(instance).getLife();
    //
    ...
}
this should just show you that i want for example access the "getLife" function of the method which is givien by the argument.
 

NullCoder

Inactive Approved Modder
Jun 8, 2020
110
901
93
21
None
C#:
public class PlayerController : MonoBehaviour {
    public bool IsDead() {
        // Code
    }
}

public class GameManager : MonoBehaviour {
    private void Damage(PlayerController player, float damage) {
        // Code
    }
}
C++:
bool (*Player_IsDead)(void* instance);

void (*old_GameManager_Damage)(void* instance, void* playerController, float damage);
void GameManager_Damage(void* instance, void* playerController, float damage) {
    if (instance != NULL) {
        bool dead = Player_IsDead(playerController);
    }
    old_GameManager_Damage(instance, playerController, damage);
}
void* - can store a pointer to any data type
 
  • Like
Reactions: jkof and Kaorin333
Status
Not open for further replies.