PDA

View Full Version : hooking a process's keyboard input


2_a_day
March 10th, 2002, 07:37
I hook a process like so…

hhk = SetWindowsHookEx (WH_KEYBOARD, KeyboardProc, NULL, ThreadId);

Works well, but there is one problem: calls to WriteProcessMemory, when writing memory of the hooked process, fail when called from inside the KeyboardProc callback function. I am able to write the memory A. before the process is hooked and B. when the process is hooked and I am not calling WriteProcessMemory within KeybordProc .

Any ideas? (BTW, my “target” for now is windows calculator)

Maybe someone can suggest an alternate method. My goal is to modify a part of memory on a WM_KEYDOWN, then restore it on the corresponding WM_KEYUP.

Thanks.