procedure PatchINT3; var NOP : Byte; NTDLL: THandle; BytesWritten: DWORD; Address: Pointer; begin if Win32Platform <> VER_PLATFORM_WIN32_NT then Exit; NTDLL := GetModuleHandle('NTDLL.DLL'); if NTDLL = 0 then Exit; Address := GetProcAddress(NTDLL, 'DbgBreakPoint'); if Address = nil then Exit; try if Char(Address^) <> #$CC then Exit; NOP := $90; if WriteProcessMemory(GetCurrentProcess, Address, @NOP, 1, BytesWritten) and (BytesWritten = 1) then FlushInstructionCache(GetCurrentProcess, Address, 1); except // Do not panic if you see an EAccessViolation here, it is perfectly harmless! on EAccessViolation do ; else raise; end; end; --- procedure TFormMain.FormCreate(Sender: TObject); begin PatchINT3; end;
郁闷
没有好办法
检查最可能的地方
尽量
try
......
except
end;
个人觉得,这种应该不是CPU问题
而是访问内存地址出错吧:)比如内存溢出...........
直到找到出错的准确范围,F5分析可能的原因,如果仍无解,Ctrl+Alt+C
var
NOP : Byte;
NTDLL: THandle;
BytesWritten: DWORD;
Address: Pointer;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT then Exit;
NTDLL := GetModuleHandle('NTDLL.DLL');
if NTDLL = 0 then Exit;
Address := GetProcAddress(NTDLL, 'DbgBreakPoint');
if Address = nil then Exit;
try
if Char(Address^) <> #$CC then Exit; NOP := $90;
if WriteProcessMemory(GetCurrentProcess, Address, @NOP, 1, BytesWritten) and
(BytesWritten = 1) then
FlushInstructionCache(GetCurrentProcess, Address, 1);
except
// Do not panic if you see an EAccessViolation here, it is perfectly harmless!
on EAccessViolation do ;
else raise;
end;
end;
---
procedure TFormMain.FormCreate(Sender: TObject);
begin
PatchINT3;
end;