一、EXE的情况,把代码放在工程文件
procedure Halt0;
begin
Halt;
end;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
asm
xor edx, edx
push ebp
push OFFSET @@safecode
push dword ptr fs:[edx]
mov fs:[edx],esp
call Halt0
jmp @@exit;
@@safecode:
call Halt0;
@@exit:
end;
end.
二、DLL的情况,把代码放在工程文件里
procedure Halt0;
begin
Halt;
end;
var
OldProc: Pointer;
procedure DLLEntryPoint(dwReason: DWord);
begin
if (dwReason = DLL_PROCESS_DETACH) Then
Begin
asm
xor edx, edx
push ebp
push OFFSET @@safecode
push dword ptr fs:[edx]
mov fs:[edx],esp
call Halt0
jmp @@exit;
@@safecode:
call Halt0;
@@exit:
end;
end;
end;
begin
DllProc := @DLLEntryPoint;
DllProcEX := @DLLEntryPoint;
end.