终于写好了 Hook API 的控件了,发分庆贺~~(200分)

  • 主题发起人 主题发起人 白河愁
  • 开始时间 开始时间
2006手上没有,只要能支持标准dll的都可以吧,<br>可以加我 msn kryso@ff18.com ,不过不一定在线
 
楼主,期待你的例子,最好有关于textout、textouta之类函数的。
 
to 16cy: 想做屏幕取词?建议去看深入 Windows 下的核心编程 Delphi 版,本控件没有考虑对16位函数的支持,也不支持win9x
 
AA.API.DllName:= 'gdi32.dll';<br> &nbsp;AA.API.DllFunction:= 'TextOutA';<br> &nbsp;AA.API.Params:= 5; //API 的参数数量<br> &nbsp;AA.API.OnAPIHookProc:= AA.HookAPIAPIHookProc; //API 执行后发生的事件<br><br>这样设置就可以 Hook TextOutA 了
 
楼主可不可以用免费版的turbo delphi编译一个for bds版本的
 
turbo delphi 那里有下?大不大?
 
楼主快放分阿,祝贺你
 
明天结分吧...
 
http://www.turboexplorer.com/<br>或者用baidu或google找
 
这里是注册文件:http://www.ccrun.com/view.asp?id=297
 
老白,帮忙看看这个问题,关于消息拦截的。谢谢!<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=3591460
 
呵呵,楼主高手,看看
 
拦截消息只需要hook sendmessage postmessage 就可以了.
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp; <br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br> &nbsp;hProcess: THandle;<br> &nbsp;pFnMsgBox: DWord;<br> &nbsp;dwOld: DWord;<br> &nbsp;jmp: array[1..5] of Byte;<br> &nbsp;enter: array[1..5] of Byte;<br> &nbsp;procedure SetupHook;<br> &nbsp;procedure RemoveHook;<br> &nbsp;function MessageBoxProxy(hWnd: THandle; lpText: Pchar; lpcStr: PChar; uType: Word): Integer; stdcall;<br> &nbsp;<br>implementation<br><br>{$R *.dfm}<br><br>function MessageBoxProxy(hWnd: THandle; lpText: PAnsichar; lpcStr: PAnsichar; uType: Word): Integer; stdcall;<br>begin<br> &nbsp;Result := 0;<br> &nbsp;ShowMessage('先登录吧!');<br> &nbsp;CopyMemory(Pointer(pfnMsgBox), @enter, 5); &nbsp;//恢复入口指令<br> &nbsp;FlushInstructionCache(hWnd, Pointer(pfnMsgBox), 5);<br> &nbsp;Result := MessageBox(hWnd, lpText, lpcStr, uType); //调用原函数<br> &nbsp;CopyMemory(Pointer(pfnMsgBox), @jmp, 5); &nbsp;//写入跳转指令<br> &nbsp;FlushInstructionCache(hProcess,Pointer(pfnMsgBox),5);<br>end;<br><br>procedure RemoveHook;<br>var<br> &nbsp;dwTemp: DWord;<br>begin<br> &nbsp;CopyMemory(Pointer(pfnMsgBox), @enter, 5);<br> &nbsp;FlushInstructionCache(hProcess, Pointer(pfnMsgBox), 5);<br> &nbsp;VirtualProtect(Pointer(pfnMsgBox), 5, dwOld, @dwTemp);<br>end;<br><br>procedure SetupHook;<br>begin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp;pFnMsgBox := DWord(GetProcAddress(GetModuleHandle(Pchar('user32.dll')),PChar('MessageBoxA')));<br> &nbsp;ZeroMemory(pChar(@enter),sizeof(enter));<br> &nbsp;CopyMemory(@enter, Pointer(pfnMsgBox), 5); &nbsp;//保存入口指令<br> &nbsp;ZeroMemory(pChar(@jmp),sizeof(jmp));<br><br> &nbsp;jmp[1]:= $E9;<br> &nbsp;PInteger(@jmp[2])^ := (Integer(@MessageBoxProxy)-(Integer(pfnMsgBox)+5));<br> &nbsp;VirtualProtect(Pointer(pfnMsgBox), 5, PAGE_EXECUTE_READWRITE,@dwOld);<br> &nbsp;CopyMemory(Pointer(pfnMsgBox), @jmp, 5);<br>end;<br><br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> &nbsp; hProcess:=GetCurrentProcess();<br> &nbsp; SetupHook();<br> &nbsp; MessageBox(handle,Pchar('Hook Demo!'), Pchar('API Hook'),MB_ICONINFORMATION);<br> <br> &nbsp; RemoveHook();<br> &nbsp; MessageBox(handle, Pchar('Hook Demo2!'), Pchar('API Hook2'),MB_ICONINFORMATION);<br>end;<br><br><br><br>end.
 
楼上的代码不错,不过如果不封装起来,估计初学者都是不会用的。
 
楼主快放分阿,
 
不错,学习一下。
 
呵呵,走过路过,祝贺.<br>下载下来.谢谢.楼主.
 
好了,结帖发分。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部