|
-
April 29th, 2004, 10:29 AM
#1
"hook" problem
I would like to hook some app from another app. Hook procedure (keyboard type) is in exe file. I don't want to use global hook so I used "local" like this:
HWND hwnd = ::FindWindow(NULL,"Some app to hook");
if(hwnd == NULL) return;
LPDWORD processID = NULL;
UINT threadID = GetWindowThreadProcessId(hwnd,processID);
if(threadID == 0) return;
m_hHook = SetWindowsHookEx(WH_KEYBOARD,hookproc,NULL,threadID);
When I use debug versions of both apps hook procedure is working correctly but when I use release versions it don't (SetWindowsHookEx is working fine). Any idea why?
Maybe there is another way to take control of keyboard in some process. I tray also to use separate hooking dll, but when I used GetProcAddress to get pointers to exported funcions it always return NULL. Please help me.
-
April 29th, 2004, 10:37 AM
#2
If you want to hook an external application you must use a DLL. The reason is because an application can not access code outside of its address space, which includes code in your application. By putting the code into a DLL, the DLL can be loaded into the target process's address space.
GetProcAddress may be failing because you are not using the "decorated name". There is a command line program that will tell you the name you need to use, or you can use depends i think.
-
April 29th, 2004, 10:53 AM
#3
Thanks! How to get the "real" names of dll functions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|