Raised This Month: $51 Target: $400
 12% 

Solved call detoured function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 02-26-2014 , 11:32   call detoured function
Reply With Quote #1

PHP Code:
DETOUR_DECL_MEMBER0(Detourfunc1void)
{
    
DETOUR_MEMBER_CALL(Detourfunc1)();
    return;
}

DETOUR_DECL_MEMBER0(Detourfunc2void)
{
    
//How can I call Detourfunc1 hear ?

    
DETOUR_MEMBER_CALL(Detourfunc2)();
    return;


Last edited by kadet.89; 02-05-2020 at 14:39.
kadet.89 is offline
Send a message via Skype™ to kadet.89
psychonic

BAFFLED
Join Date: May 2008
Old 02-26-2014 , 11:36   Re: call detoured function
Reply With Quote #2

It looks like you're using pred's CDetour.

Here are two macros that I added to detours.h in the SM RCon Sourcemod extension to do similar:
Code:
#define DETOUR_MEMBER_MCALL_CALLBACK(name, classptr) \
    ((name##Class *)classptr->*(&name##Class::name))
#define DETOUR_MEMBER_MCALL_ORIGINAL(name, classptr) \
    ((name##Class *)classptr->*(&name##Class::name##_Actual))
psychonic is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 02-26-2014 , 11:45   Re: call detoured function
Reply With Quote #3

Unfortunately I don't understand how it works. Could you give a simple example?
kadet.89 is offline
Send a message via Skype™ to kadet.89
psychonic

BAFFLED
Join Date: May 2008
Old 02-26-2014 , 11:56   Re: call detoured function
Reply With Quote #4

If you want to call the original function, the one being detoured, use DETOUR_MEMBER_MCALL_ORIGINAL. Use it the same way you're using DETOUR_MEMBER_CALL, except that you also need a pointer to the instance of the class that you're calling it on since it's a member function.

DETOUR_MEMBER_MCALL_CALLBACK(Detourfunc1, instanceptr)();
psychonic is offline
Reply



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 09:28.


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