delphi 使用INT3进行HOOK处理


本文整理自网络,侵删。

 
原理:设置异常捕获,然后将需要HOOK的代码直接修改成INT3即可
用的一个关键的API:SetUnhandledExceptionFilter

//异常处理函数  
function MyInt3(CONST P:EXCEPTION_POINTERS):Integer;cdecl;  
var  
 add:Pointer;  
begin  
  OutputDebugString(PChar(inttohex(P.ExceptionRecord.ExceptionCode,2)));  
  Add:=p.ExceptionRecord.ExceptionAddress;  
  OutputDebugString(PChar(Format('Address:%x ',[Cardinal(Add)])));  
  inc(p.ContextRecord.Eip);  
  result:=-1;  
end;  
执行  SetUnhandledExceptionFilter(@MyInt3);

为了防止DELPHI自身捕获到异常,先要对其进行清除

asm  
   @Loop:  
    mov eax,fs:[0]  
    cmp dword ptr [eax],$FFFFFFFF  
    je @SEHCleared  
    mov eax,[eax]  
    mov fs:[0],eax  
    jmp @Loop  
   @SEHCleared:  
end;  

来源:http://blog.csdn.net/yoie01/article/details/8702257

相关阅读 >>

Delphi 获取其它软件的tlistbox句柄,怎么取得listbox中的数据

Delphi之屏幕和窗口的坐标

Delphi 2009 之 tcategorypanelgroup[1]: chevronalignment 等

Delphi 2009 之 tbuttonededit

java2op.exe,Delphi安卓原生桥接文件生成器

Delphi 构建时间 -encodedatetime … tryencodedatetime

Delphi 进程之间传递cmd参数

Delphi 获取局域网所有ip

Delphi10 一段汇编程序

Delphi 判断iso文件,iso文件头, iso filehead

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...