![]() |
[c++] windows keyboard hooks
Can someone give me a basic description of how to make a simple keyboard hook? I have looked in the msdn library and am still unclear about how to implement the SetWindowsHookEx() function.
Thanks |
Wow it seems like nobody that uses the tfp knows anything about windows hook programming :-/
|
Java... Unless it's interactive I don't really need anything else.
|
I've screwed around with it trying to inject code into another process on Windows 9x (on NT you can just use VirtualAllocEx and CreateRemoteThread but the latter isn't implemented on 9x), but I couldn't get it working and stopped bothering because I figure everyone should be using 2000 or XP by now anyway. ;-) It is kind of confusing and I'm not sure why I couldn't do it before but some code I just wrote seems to work.
Basically you need a LRESULT CALLBACK HookProc(int, WPARAM, LPARAM), called by Windows when the thread(s) you are monitoring get whatever type of message, and then you have to call SetWindowsHookEx with a pointer to that function, the handle to the DLL the function is in if necessary, the type of hook, and which threads. If you want the hook on another process you have to put the callback function in a DLL. First the driver program, as simple as it gets: Code:
#include <windows.h> Code:
#include <windows.h> |
All times are GMT -8. The time now is 07:28 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project