Monday, July 1, 2013

Global hook

Global hook is injected your code to all process and all executable are working in your system

How to work?

There are 2 types

in this we have 15 small types

for example:

WH_KEYBOARD: Allow messenger of keyboard
WH_MOUSE: Allow event from mouse
....

Step1 :

Create dll have your function:


LRESULT CALLBACK <Function name>(int nCode, WPARAM wParam, LPARAM lParam)

in your function, we can do everything, but you need follow some rules
- if nCode < 0, dont do anything, call back CallNextHookEx() and return defaul value
- Function must return other value, not 0

Step 2: Create a hook
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId)

All agrument have this meaning

+ idHook Your hook type
+ lpfn address hook
+ hMod handle of your dll
+ dwThreadID determine your range of hook

Unhook your function: BOOL UnhookWindowsHookEx(HHOOK hHook)

After all step, you need export hook function then call it from other process
use EXPORTS with a def file

Hook is very difficle , you need learn more to improve your skill

0 comments:

Post a Comment