Windows Userland Hooks

From Ggl's wiki

Jump to: navigation, search

Hooking with SetWindowsHookEx()

Good tutorial from MSDN: Using Hooks.

Basically to install a hook with SetWindowsHookEx():

HOOKPROC hkprcSysMsg; 
static HINSTANCE hinstDLL; 
static HHOOK hhookSysMsg; 
 
hinstDLL = LoadLibrary((LPCTSTR) "c:\\code\\hooks\myhook.dll"); 
hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "SysMessageProc"); 
hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0);
Personal tools