M
movax
Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个监视windows发向某个窗口的所有message的hook。hook是写在dll里。由监视程序运行是动态的load。可是监视程序一运行,不仅监视不到messge,连自己也死掉了。<br>hook的部分代码如下:<br>.....<br> p_InspectMessage : pCWPSTRUCT;<br>.....<br>function SystemMessageHook(nCode: Integer; wParam,lParam: Longint): Longint; stdcall;<br>begin<br> case nCode of<br> HC_ACTION :<br> begin<br> p_InspectMessage := @lParam; <br> if p_InspectMessage.Hwnd=TargetHwnd then<br>// 往指定的地方写监视消息...<br> sendMessage(ShowHwnd,WM_Char,*****,0);<br> Result:= CallNextHookEx(HookHandle,nCode,wParam,lParam);<br> end;<br> else<br> Result:= CallNextHookEx(HookHandle,nCode,wParam,lParam);<br> end; //end of case<br>end;<br><br>procedure SetHook;stdcall;<br>begin<br> try<br> HookHandle:= SetWindowsHookEx(WH_CallWNDPROC,SystemMessageHook,fHinstance,0);<br> except<br> ShowMessage('SetHook Error!');<br> end;<br>end;<br><br>....