Hooking window messages?

Dec 9, 2008 at 6:26 PM
Hello,

First of all thank you for such a wonderful library. It's really useful.

Can the library be used to monitor windows messages? I'd like to hook WM_SETTEXT message.

Thank you.
Dec 24, 2008 at 9:58 AM
Edited Dec 24, 2008 at 10:10 AM
Couldn't you hook User32.GetMessage or would that not work?
Dec 24, 2008 at 10:25 AM
I am not familiar with it, that's why I am asking.
Dec 24, 2008 at 11:23 PM
I'm not either, but at least you can try.  And after testing some code you can report what you learned to the community.  Good luck.

p.s. in WinUser.h WM_SETTEXT is defined as 0xC
Dec 25, 2008 at 9:35 PM
You probably can hook it, it's a simple method, you can find a declaration here: http://pinvoke.net/default.aspx/user32.GetMessage
Filtering the messages is up to you in yout method.
Mar 30, 2009 at 11:48 AM
You can also create your own window proc (message callback function) and get it in use by calling SetWindowLong API function in hooked process. You must first get the original window proc pointer with GetWindowLong() funcition, so you can call it from your custom one.

I think this is a bit more safer&cleaner way than hijacking GetMessage, you just tell windows to use your own message handler instead of apps original one. Also if the hooked app got multiple child windows you can write own function for each of them, so no HWND mapping required to get the correct calls.

I have used this technique several times, but not with EasyHook or from managed code. But i'm just about to do so, after that i can post example if needed.

Mar 30, 2009 at 5:03 PM
Hi,

that's an interesting approach, I'd love to see an example :)

Thanks.