本文整理自网络,侵删。
原理:设置异常捕获,然后将需要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 windows 编程[16] - 添加与删除菜单项:getmenu、appendmenu、deletemenu、drawmenubar
Delphi 不管什么datetime日期格式时间格式转换都不会错了
Delphi concat 连接两个或多个字符串为一个字符串
Delphi winapi: isiconic、iszoomed - 分别判断窗口是否已最小化、最大化
更多相关阅读请进入《Delphi》频道 >>