delphi 使用INT3进行HOOK处理  
官方Delphi 学习QQ群: 682628230(三千人)
频道

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

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.041390895843506 seconds