Sridhar
2009-09-07 06:18:01 UTC
HI Friends,
I am trying to hook notepad and i want to get which menu items in
notepad is clicked etc..i wrote one simple dll.i am using wh_callwndproc
hook. the problem is.. it is running fine for some time..after that showing
notepad encounter a problem..message i am getting then i have to close
notepad.
here is my dll code where i am hooking..
DECLDIR bool InstallMsgHookProc()
{
hWnd=FindWindow("NotePad",NULL);
/*
if(NULL==hWnd)
{
hWnd=GetForegroundWindow();
}
*/
processId=GetWindowThreadProcessId(hWnd,&processId);
bool bSuccess=false;
if(!ghKeyHook)
{
//ghWndMain=hWnd;
glpfnHookProc=(HOOKPROC)MsgHookProc;
bSuccess=(NULL!= (ghKeyHook=
::SetWindowsHookEx(WH_CALLWNDPROC,glpfnHookProc,ghInstance,processId)));
}
return bSuccess;
}
please tell me what i am doing wrong..from two weeks i am trying for this...
i put one break point in filter function but it is not hitting..
and also if you know plz tell me using which books or site to learn windows
hooking is best.
Thanks in advance..
I am trying to hook notepad and i want to get which menu items in
notepad is clicked etc..i wrote one simple dll.i am using wh_callwndproc
hook. the problem is.. it is running fine for some time..after that showing
notepad encounter a problem..message i am getting then i have to close
notepad.
here is my dll code where i am hooking..
DECLDIR bool InstallMsgHookProc()
{
hWnd=FindWindow("NotePad",NULL);
/*
if(NULL==hWnd)
{
hWnd=GetForegroundWindow();
}
*/
processId=GetWindowThreadProcessId(hWnd,&processId);
bool bSuccess=false;
if(!ghKeyHook)
{
//ghWndMain=hWnd;
glpfnHookProc=(HOOKPROC)MsgHookProc;
bSuccess=(NULL!= (ghKeyHook=
::SetWindowsHookEx(WH_CALLWNDPROC,glpfnHookProc,ghInstance,processId)));
}
return bSuccess;
}
please tell me what i am doing wrong..from two weeks i am trying for this...
i put one break point in filter function but it is not hitting..
and also if you know plz tell me using which books or site to learn windows
hooking is best.
Thanks in advance..
--
--------------------------------------------
At last i learned something for today...:)
--------------------------------------------
At last i learned something for today...:)