This topic is now archived and is closed to further replies.


Windows mesage Hooks question...

Recommended Posts

Hostility    122
I''ve been toying with Windows message hooks lately. What I''ve been trying to do is send messages that one application gets and send them to my own. Despite my efforts, I''ve been unable to get the hook workingwithout the program I''m trying to get hooked messages from crashing. I read in MSDN that in order to hook messages from another process, the hookproc needs to be in a DLL. I created a DLL with a Hookproc that does the following: LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam) { CWPSTRUCT *m = (CWPSTRUCT*)lParam; PostMessage(mywindow,m->message,m->wParam,m->lParam); return 0; } mywindow is a handle to my application(the DLL searches and finds my window''s class upon entry, or fails to load). At this point I''ve tried both making the DLL handle all the hooking internally(setting the hook up at load, and unhooking at unload), and having my application use the above function as exported from the DLL to do the hooking. So far, nothing has worked, and the hooked window crashes. The hooking function is called as follows: hook = SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)CallWndProc, hInstance,thread); Since that specific program is crashing, I''m pretty sure that all the window and thread getting code is working. At this point I''ve chalked my problem up to my lack of knowledge in Windows hooks. I hope that''s clear enough for everyone. Any help at all would be greatly appreciated. Thanks in advance to anyone who bothers to read. I''d be glad to clarify anything else I can.

Share this post

Link to post
Share on other sites