Setwindowshookex fail




















Quick access. Search related threads. Remove From My Forums. Answered by:. Archived Forums. Also discuss all the other Microsoft libraries that are built on or extend the. Sign in to vote. Monday, November 21, AM. Glad to hear that. Maybe you can try to run it on another machine to test the code. Have a nice day. You must place a global hook procedure in a DLL separate from the application installing the hook procedure.

The installing application must have the handle to the DLL module before it can install the hook procedure. After you have obtained the handle, you can call the GetProcAddress function to retrieve a pointer to the hook procedure. Finally, use SetWindowsHookEx to install the hook procedure address in the appropriate hook chain. SetWindowsHookEx passes the module handle, a pointer to the hook-procedure entry point, and 0 for the thread identifier, indicating that the hook procedure should be associated with all threads in the same desktop as the calling thread.

This sequence is shown in the following example. You can release a thread-specific hook procedure remove its address from the hook chain by calling the UnhookWindowsHookEx function, specifying the handle to the hook procedure to release. Release a hook procedure as soon as your application no longer needs it. SetLastError flag set. Improve this question. Hans Passant k gold badges silver badges bronze badges.

Mehran Mehran Could you please explain more or point me to the right resource? Hooking usually involves some code becoming part of the target process es. Could you please tell me what can I do in this case?

Any suggestions? For this specific library it might help to change the source code for details see stackoverflow. Show 1 more comment. Active Oldest Votes. Improve this answer. Hans Passant Hans Passant k gold badges silver badges bronze badges. Thanks Hans, it worked perfectly. I just want to add that I managed to find the problem. Yours will be the solution I will use but I just wanted to ask for your thoughts on my new discovery if you please.

The problem was that my project's Platform target was set to x86 while my OS is Windows 7x I explicitly pointed out in the answer that making it work on any Windows version was the goal. A solution to that problem is to make another procedure that will work on another thread that will monitor and respond to these messages. Another limitation is that SetWindowsHookEx cannot be used on a process with a higher integrity level.

Share this: Twitter Facebook. Like this: Like Loading Follow Following.



0コメント

  • 1000 / 1000