Changing Window Procedure
Hi
Is this code for changing an application's window procedure correct , cuz im having trouble with it
Code:
while(TRUE)
{
hwnd = GetForegroundWindow();
if((WNDPROC)GetWindowLong(hwnd,GWL_WNDPROC) != NULL)
OldWindowProc = (WNDPROC)GetWindowLong(hwnd,GWL_WNDPROC);
SetWindowLong(hwnd,GWL_WNDPROC,(LONG)fakeWinProc);
Sleep(5000);
}
Re: Changing Window Procedure
Quote:
cuz im having trouble with it
What's the trouble ?
Re: Changing Window Procedure
well basically i want to log all keystroke events...
From the debugger it is evident that i get the foreground window... (a call to showwindow(hwnd,SW_HIDE) works)
But the keystroke events in wndproc are not logged.. And the value in the OldWndProc is always 0x0000000.
Re: Changing Window Procedure
Have you looked into SetWindowsHookEx? If a keyboard hook is what you want, then why not set it up the usual way?
Re: Changing Window Procedure
Quote:
Originally Posted by
vinayak4gargya
From the debugger it is evident that i get the foreground window... (a call to showwindow(hwnd,SW_HIDE) works)...
But the keystroke events in wndproc are not logged.. And the value in the OldWndProc is always 0x0000000.
I presume the said code is executed in some process other than the foreground window belongs to. Well, to do that correct, the new window procedure must reside in the window's process. Otherwise the quoted code makes no sense.
Quote:
well basically i want to log all keystroke events...
Well basically they do that some other way... :)
Re: Changing Window Procedure
oooh thanks a lot! So i need to hook into a process first?? Could somebody please elaborate on 'hooking'.. Or link to an article probably?
Re: Changing Window Procedure