Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window hooks - How do they work?

Tags:

windows

I've got no idea how window hooks work at the "system level". MSDN only touches what's going on very briefly:

A hook is a point in the system message-handling mechanism where an application can install a subroutine to monitor the message traffic in the system and process certain types of messages before they reach the target window procedure.

My best guess is something like below:

enter image description here

Before each message is added to the message queue for a window, it'll first send the message to the global/local hooks, which may do something, depending on their hook procedures. After all global hooks and local hooks, the message is finally added to the window message queue.

However, MSDN says that for some of the types of hooks, it will monitor events, notifications etc.

An example is the WH_MOUSE_LL hook:

Installs a hook procedure that monitors low-level mouse input events. For more information, see the LowLevelMouseProc hook procedure.

When they say events, are we talking window messages, or do they mean something else?

Am I all wrong?

like image 224
ebb Avatar asked Dec 26 '11 00:12

ebb


1 Answers

Yes, this is a mechanism for windows messages, you can process this data (messages) before they reach target window procedure (message loop).

If you want hook other process windows you can simply do this in DLL, and use DLL injection for inject your library to other process.

like image 181
Svisstack Avatar answered Oct 21 '22 16:10

Svisstack