Intercept recursive functions ...

Jun 5, 2009 at 9:06 AM

Hi all,

first of all: EasyHook looks great to me! Good job ... keep up the good work!

However I ran into a situation that I don't see how I can resolve with the current EasyHook implementation:

I wanted to hook the "SendMessage" function. In my replacement function, for now I simply call the original "SendMessage" function.

For the "first-level" invocation, this works fine and the original code is executed. However, my test application uses the "SendMessage" function recursively in a WindowProc and I would want the call from the WindowProc to call the intercepted version of "SendMessage" again, which does not happen - the "unmodified" original version is called "directly" without passing through my hook. My assumption is that as long as the first call of my replacement function has not returned, the injected code always directly calls the original version. Is that correct or did I miss something?

If so, is there a way to achieve my original goal (only call the original function directly if called from my replacement function)? I think in the Detours "concept", this is possible by keeping an explicit "copy" of the original code for use in the hook function and let the modified code always execute the hook function ...

Thanks a lot for your feedback in advance,