Quantcast
Viewing all articles
Browse latest Browse all 1449

Hook system wide with DLL in C++

Hello,

Even we are in 2015 and vb6 is old, it’s still great. As I had been in difficult to find a simple and efficient method to do hooking system wide, so I share my source code, here in zip attachment.

This project allow you to do global hook, system wide in Windows. The principle is to put the hook with a DLL, then get the message by subclassing our program. This hook system wide work only with 32 bits applications.

The DLL in attachment was compiled in C++. Which allow you to put hook system wide in Windows, then send to our program, with SendMessage, the message WM_USER and the hook code (nCode). With subclassing of our program, we can get the hook code by subtract WM_USER.

The hook provided from the DLL is not specific to our program but global in all Windows (system wide).

The DLL support these hooks types :
' WH_CALLWNDPROC = CallWndProc;
' WH_CALLWNDPROCRET = CallWndRetProc;
' WH_CBT = CBTProc;
' WH_DEBUG = DebugProc;
' WH_FOREGROUNDIDLE = ForegroundIdleProc;
' WH_GETMESSAGE = GetMsgProc;
' WH_JOURNALPLAYBACK = JournalPlaybackProc;
' WH_JOURNALRECORD = JournalRecordProc;
' WH_KEYBOARD = KeyboardProc;
' WH_KEYBOARD_LL = LowLevelKeyboardProc;
' WH_MSGFILTER = MessageProc;
' WH_MOUSE = MouseProc;
' WH_MOUSE_LL = LowLevelMouseProc;
' WH_SHELL = ShellProc;
' WH_SYSMSGFILTER = SysMsgProc;

This project provide a demo of these hooks system wide :
CBT / CreateWnd : get the name of the handle parent of the window to be created.
Keyboard = get the code of the keystroke.
Mouse = get the name of the handle pointed by the left click.

I’m not the author of the DLL, neither hooking and subclassing methods.
I took these three elements and make a simple project.
The DLL was coded in C++ by Renfield – 2007
Source code of subclassing by Renfield – 2010
Hooking routines by vbAccelerator – 2003

Have fun ;-)

-ZIP Removed By Moderator-

Viewing all articles
Browse latest Browse all 1449

Trending Articles