Raised This Month: $99 Target: $400
 24% 

[NMRiH/Any] DHooks with detours not superseding function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Addie
Junior Member
Join Date: Nov 2018
Old 07-07-2019 , 18:33   [NMRiH/Any] DHooks with detours not superseding function
Reply With Quote #1

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?

Last edited by Addie; 07-07-2019 at 22:52.
Addie is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 07-07-2019 , 20:09   Re: [NMRiH/Any] DHooks with detours not superseding function
Reply With Quote #2

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.
__________________
Spirit_12 is offline
Addie
Junior Member
Join Date: Nov 2018
Old 07-07-2019 , 22:51   Re: [NMRiH/Any] DHooks with detours not superseding function
Reply With Quote #3

Quote:
Originally Posted by Spirit_12 View Post
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

Last edited by Addie; 07-08-2019 at 00:37.
Addie is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-08-2019 , 15:07   Re: [NMRiH/Any] DHooks with detours not superseding function
Reply With Quote #4

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.
__________________
asherkin is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-14-2019 , 07:29   Re: [NMRiH/Any] DHooks with detours not superseding function
Reply With Quote #5

That line is about virtual hooks using SourceHook. The example gamedata uses a detour, so it's using a different code path.
__________________
Peace-Maker is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode