Click to See Complete Forum and Search --> : Need help with hooks.


Guidosoft
March 22nd, 2006, 09:29 AM
I need 3 things:

1. I have been testing out SetWindowsHookEx with WH_GETMESSAGE and I have had some success. The only problems I am having is it won't notify me of WM_CREATE, WM_DESTROY, WM_CLOSE or anything sent via SendMessage.
Another thing is, it won't let me listen in on other processes. I want to listen to all processes not just my own.

2. I need to be able to remotely destroy and control windows in other processes. You see I am working of a program called WinMan (If the name is takin I don't care.) Anyway it lets me hide and show windows from other processes but thats it. I need more.

3. I need to be able to inject code into other process via hooks.

philkr
March 22nd, 2006, 10:16 AM
You might try the other hooking method using CreateRemoteThread().
It is explained here: Three Ways To Inject Your Code Into Another Process (http://www.codeguru.com/Cpp/W-P/system/processesmodules/article.php/c5767)

Once you got the hooking DLL in the address space of the other process you can use SetWindowLongPtr() funciton to redirect its window procedure. But first you should get the address of the old window procedure using GetWindowLongPtr(), because you should call it using CallWindowProc() in your hook window procedure.

Note that the CreateRemoteThread() function does not work under Win95/98. There is a technique to achieve the same, but it is more complicated.