Jump to content

11 posts in this topic

Recommended Posts

Posted (edited)

Since it's been a while - I forgot how to actually code stuff, could you please tell me how do properly I implement that?

bool (*get_isEnemy)(void *instance) = (bool (*)(void *))getRealOffset(0x101FB0804); 

float (*old_getDamage)(void *e);
float getDamage(void *e){
bool enemy = get_isEnemy(e);
if (e && enemy == false) {
return 9999.0f;
}
return old_getDamage(e);
}
///

 

HOOK(0xaddress, old_getDamage, getDamage);

 

Currently that just crashes the game.

Updated by Laxus
Posted

Nothing wrong, if you are using unc0ver hooking may not work sometimes

Posted (edited)
6 minutes ago, Laxus said:

Nothing wrong, if you are using unc0ver hooking may not work sometimes

Thanks, I guess its' just the address being wrong then. 

I'm using oddysey tho

if I comment these out it works as intended 

https://codeshare.io/YLb90R

Updated by n1ce0n3
Posted

Try changing get_isenemy function pointer *instance to *e

Try changing if(e && enemy == false) to if(!enemy)

Posted
4 minutes ago, Laxus said:

Try changing get_isenemy function pointer *instance to *e

Try changing if(e && enemy == false) to if(!enemy)

I  tried (!enemy)  before adding (e && enemy == false), that crashed it too.

that actually was a bad address, I've checked this by changing both of the functions body to return old_get and it still crashed.

so I changed the addresses and it worked. (well it didn't work, but it didn't crash either)

Posted

Use something like Cr4shed to see exactly where it crashes. It's probably an issue with the function prototype or with the address itself. The NULL check should also be done before you call the actual function but eitherway the original function would get a NULL pointer so there's no reason to check.

Posted (edited)
2 minutes ago, bR34Kr said:

Use something like Cr4shed to see exactly where it crashes. It's probably an issue with the function prototype or with the address itself. The NULL check should also be done before you call the actual function but eitherway the original function would get a NULL pointer so there's no reason to check.

I have Crash Reporter which gives me a syslog of the crash, but I never even thought about checking it after a crash like this.

I don't think it will show anything relatively useful? Except for when the address is null?

Updated by n1ce0n3
Posted

It'll show you the tracelog which is pretty useful. You can try opening your binary in IDA afterwards and seeing exactly where the crash is unless you have debug info turned on.

Posted
1 minute ago, bR34Kr said:

It'll show you the tracelog which is pretty useful. You can try opening your binary in IDA afterwards and seeing exactly where the crash is unless you have debug info turned on.

Well, that actually makes some sense, I guess. Thanks for the tip.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines