View Single Post
psychonic

BAFFLED
Join Date: May 2008
Old 03-24-2018 , 08:41   Re: Hooking a function with unusual call conventions?
Reply With Quote #2

Going by memory for some of this. Hopefully it's correct.

For any function that returns a class/struct instance by value, MSVC compiles it as you say, with an added param that passing the value by ref. I believe GCC and Clang do the same, but only if the class is larger than the size of a pointer (which it isn't in this case). I believe there's still a return value, a pointer to the return object.

I think that last piece is the only part you're missing in your first try above.

Edit: that said, the compiler just might do the work for you, depending on what CDetour's macros create. You might be able to just do:
DETOUR_DECL_MEMBER1(CTFGameRules_GetPayloadTo Push, CBaseHandle, int, team)

Last edited by psychonic; 03-24-2018 at 08:43.
psychonic is offline