I created 2 hooks in my host application. 1st is WH_MOUSE
set specifically for Taskbar's thread. 2nd is global WH_KEYBOARD_LL
hook (dwThreadId
is set to 0).
As you can see in Process Explorer, the "local" hook actually injected my dll into specific explorer.exe thread. However, there is no indication that my 2nd global hook got injected into any other processes, yet it still works perfectly... Moreover, it also works for all the new processes I start, even after the hook was set! How SetWindowsHookEx
manages that?
I read that it only applies to processes that load user32.dll
. My weak suspicion is that in a case of global hook, Windows somehow injects my custom dll code into user32.dll
"hook-chain". And then, when new process that loads user32.dll
is started, it automatically loads my hook with it? Is this correct or is there some other mechanism at work?