Page 1 of 1

hooking C++ methods

Posted: Fri Aug 18, 2017 8:37 pm
by dgmax
Hello,

I have been playing with MadCodeHook trying to hook methods in a C++ class in a 32 bit application.
In 32 bits, the usual "__thiscall" calling convention will require handcrafted assembly to recover the "this" pointer passed by ecx and pass it on to the "next hook".
I can declare the handler/nexthook as class members and follow the technique shown here viewtopic.php?t=66.
I am curious if this is still the recommended way, or if the library has changed since then and you recommend a different method.

Thanks,
dgmax

Re: hooking C++ methods

Posted: Mon Aug 21, 2017 1:58 pm
by madshi
I'm not sure. Maybe you can do something with "__thiscall"? I never really had the need to hook a C++ class, yet, so I didn't really try myself. I did hook some interfaces, like Direct3D, but they're WINAPI/stdcall, which makes things a lot easier.