究竟是怎么回事儿?一个关于hook的问题>>>>>>>> :((100分)

  • 主题发起人 主题发起人 movax
  • 开始时间 开始时间
M

movax

Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个监视windows发向某个窗口的所有message的hook。hook是写在dll里。由监视程序运行是动态的load。可是监视程序一运行,不仅监视不到messge,连自己也死掉了。<br>hook的部分代码如下:<br>.....<br>&nbsp;p_InspectMessage : pCWPSTRUCT;<br>.....<br>function SystemMessageHook(nCode: Integer; wParam,lParam: Longint): Longint; stdcall;<br>begin<br>&nbsp;case nCode of<br>&nbsp;HC_ACTION :<br>&nbsp;begin<br>&nbsp; p_InspectMessage := @lParam; &nbsp; <br>&nbsp; if p_InspectMessage.Hwnd=TargetHwnd then<br>// 往指定的地方写监视消息...<br>&nbsp; &nbsp; &nbsp;sendMessage(ShowHwnd,WM_Char,*****,0);<br>&nbsp; &nbsp;Result:= CallNextHookEx(HookHandle,nCode,wParam,lParam);<br>&nbsp;end;<br>&nbsp;else<br>&nbsp; &nbsp; Result:= CallNextHookEx(HookHandle,nCode,wParam,lParam);<br>&nbsp;end; //end of case<br>end;<br><br>procedure SetHook;stdcall;<br>begin<br>&nbsp;try<br>&nbsp; HookHandle:= SetWindowsHookEx(WH_CallWNDPROC,SystemMessageHook,fHinstance,0);<br>&nbsp;except<br>&nbsp; &nbsp;ShowMessage('SetHook Error!');<br>&nbsp;end;<br>end;<br><br>....
 
1、请问HookHandle:= SetWindowsHookEx(WH_CallWNDPROC,SystemMessageHook,fHinstance,0);<br>中的fHinstance是什么?<br>2、function SystemMessageHook(nCode: Integer; wParam,lParam: Longint): Longint; stdcall;<br>中的返回类型改为:<br>function SystemMessageHook(PCode :integer; Pwparam :WPARAM; Plparam :LPARAM) :LRESULT;
 
要弄成DLL,在主程序里调用吧。
 
接受答案了.
 
后退
顶部