I have tried to use hook recently, I get the game crash when calling the "origIsEnemy" bool function, but "origIsDead" is work, how to write the code can read IsEnemy(BaseUnit unit) correctly, please?
ingame dump.cs function:
public bool get_isDead(); // RVA: 0xC636F8 Offset: 0xC636F8
public bool IsEnemy(BaseUnit unit); // RVA: 0xC6EE38 Offset: 0xC6EE38
my hook script:
bool (*origIsDead)(void *_this);
bool _hookIsDead(void * _this)
{
bool mydata1 = origIsDead(_this);
return origIsDead(_this);
}
bool (*origIsEnemy)(void *_this);
bool _hookIsEnemy(void * _this)
{
bool mydata2 = origIsEnemy(_this);
return origIsEnemy(_this);
}
MSHookFunction((void *)getRealOffset(0xC636F8), (void *)_hookIsDead, (void **)&origIsDead);
MSHookFunction((void *)getRealOffset(0xC6EE38), (void *)_hookIsEnemy, (void **)&origIsEnemy);