Solved Access Argument Function / Method

Status
Not open for further replies.

Kaorin333

Solid & Active Platinian
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.
 
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
 
Status
Not open for further replies.
Back
Top Bottom