Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to check if pointer is pointing to a null value for CBaseEntity and Edict type of param #15

Closed
GAMMACASE opened this issue Dec 22, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@GAMMACASE
Copy link

GAMMACASE commented Dec 22, 2020

Currently you can only check if the address itself is a null if I'm reading the code here correctly, but when you are getting a param of a type CBaseEntity or Edict it'll check the value stored in the pointer and if it's a NULL it'll error about it here. So currently there's no way to check if you can safely get the entity or edict from a param or not and it'll always error if it's NULL. In my test case DHookIsNullParam() returned false and skipped my if block, so it resulted in a "Exception reported: Trying to get value for null pointer".

Test code snippet:

	if(DHookIsNullParam(hParams, 5))
		return MRES_Ignored;
	
	int val = DHookGetParam(hParams, 5);

Error happens on the int val = DHookGetParam(hParams, 5); line.

@peace-maker peace-maker added the bug Something isn't working label Dec 22, 2020
peace-maker added a commit that referenced this issue Jun 24, 2021
If the function is optimized to expect some parameter through a register instead of the stack, DHookParam.IsNull might validate the wrong parameter. First we store the stack parameters, then the register parameters in orgParams.
@peace-maker
Copy link
Owner

Was your detour setup with at least one parameter passed through a custom register? I've just fixed a bug with DHookIsNullParam, but can't test your usecase.

@peace-maker
Copy link
Owner

Fix confirmed through Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants