hooking C++ methods

c++ / delphi package - dll injection and api hooking
Post Reply
dgmax
Posts: 3
Joined: Wed Jul 12, 2017 6:49 pm

hooking C++ methods

Post 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
madshi
Site Admin
Posts: 10365
Joined: Sun Mar 21, 2004 5:25 pm

Re: hooking C++ methods

Post 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.
Post Reply