AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [NMRiH/Any] DHooks with detours not superseding function (https://forums.alliedmods.net/showthread.php?t=317327)

Addie 07-07-2019 18:33

[NMRiH/Any] DHooks with detours not superseding function
 
I'm trying to prevent the execution of:

PHP Code:

void __cdecl Bot_RunAll() 

using DHooks with Experimental Detours.

I successfully create the detour and simply return MRES_Supercede. Code below:

Spoiler


My gamedata:

Spoiler


My detour executes but so does the original function, why?

From dhooks.inc:

PHP Code:

enum MRESReturn
{
    
MRES_Supercede                // skip real function; use my return value
}; 

I've detoured plenty of functions in the past but never superseded them till now.
Am I doing something wrong?

Spirit_12 07-07-2019 20:09

Re: [NMRiH/Any] DHooks with detours not superseding function
 
I think you are failing to set the return value with DHookSetReturn. Supercede will skip the real value, but you have to set a return value for the function.

Addie 07-07-2019 22:51

Re: [NMRiH/Any] DHooks with detours not superseding function
 
Quote:

Originally Posted by Spirit_12 (Post 2658191)
I think you are failing to set the return value with DHookSetReturn. Supercede will skip the real value, but you have to set a return value for the function.

I don't believe DHooks expects me to set a return value on a void function. It knows it's void thanks to gamedata:

PHP Code:

"Functions" 

    
"Bot_RunAll" 
    
{  
        
"return" "void" 


There's nothing for it to override. If it expected a return, it would have shown me this:

Code:

[SM] Exception reported: Tried to override return value without return value being set

asherkin 07-08-2019 15:07

Re: [NMRiH/Any] DHooks with detours not superseding function
 
https://bitbucket.org/Peace_Maker/dh....cpp#lines-434

I don't think this line should be here, and might mean that it is ignoring the next call by the game.

Peace-Maker 07-14-2019 07:29

Re: [NMRiH/Any] DHooks with detours not superseding function
 
That line is about virtual hooks using SourceHook. The example gamedata uses a detour, so it's using a different code path.


All times are GMT -4. The time now is 18:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.