Czaj-nick
August 28th, 2001, 19:29
I've just tried using SetWindowsHookEx for the first time. Global hooking (with thread ID = 0) works pretty, my DLL gets attached to everything around 
But I can't make a hook on a particular thread.
I do the following:
1. spawn my target using CreateProcess(..., &pi)
2. get pi.dwThreadID (id of main thread of just created process, isn't it ?)
3. pass it to InstallHook (that is in my DLL)
4. in InstallHook (in DLL code) i run SetWindowsHookEx.
But it returns NULL, and sets last error to ERROR_INVALID_PARAMETER (that probably means invalid thread ID)
What's wrong with this approach ? Is it possible at all ? I can't find any examples doing it this way...

But I can't make a hook on a particular thread.
I do the following:
1. spawn my target using CreateProcess(..., &pi)
2. get pi.dwThreadID (id of main thread of just created process, isn't it ?)
3. pass it to InstallHook (that is in my DLL)
4. in InstallHook (in DLL code) i run SetWindowsHookEx.
But it returns NULL, and sets last error to ERROR_INVALID_PARAMETER (that probably means invalid thread ID)
What's wrong with this approach ? Is it possible at all ? I can't find any examples doing it this way...