您的位置:首页 > 其它

使用INT3进行HOOK处理

2013-03-21 17:25 78 查看
原理:设置异常捕获,然后将需要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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: