i’m trying to make my hook work globaly inside a process, it worked for me using the _LL (LowLevel) one, when setting hMod and dwTID to 0.
is there a way to make it work without a .dll ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not possible. The requirement is mentioned nearly in every place that talks about or give examples of global hooks on MSDN. Some examples:
Hook Procedures
Installing and Releasing Hook Procedures
SetWindowsHookEx function (Windows)
Note that the reason might be that the code can be run in context of other applications as per the documentation, but this is not always the case – also mentioned in the documentation. From
SetWindowsHookEx:I don’t really know what the can really means in that statement. Is it sometimes that way and sometimes the othwer way, but I only conducted one test, and the hook procedure is called indeed in the context of the thread that installed the hook, rendering unnecessary any interprocess communication. This doesn’t change the requirement for the dll however.
The processing of low level hooks is simply different. As explained to some extent in the documentation, the call to the hook is done by sending a message to the thread that installed the hook and then switching the context to that thread – which does not require installing a dll.