不好意思,贴代码上来有点占篇幅。由于确实是在测试时出了问题,才贴出来的。
我在以下代码(TestHaveException.dpr)中使用“函数过程列表”专家时,Delphi7停止了响应。
program TestHaveException;
{$APPTYPE CONSOLE}
uses
SysUtils;
function HaveException : boolean;
const
{$WRITEABLECONST ON}
IsFinally : LongInt = 0;
procedure GetFinallyReturnAddr;
begin
try
try
asm xor eax, eax; idiv eax end;
finally
asm pop [IsFinally]; push [IsFinally] end;
end;
except
end;
end;
asm
CMP IsFinally, 0
JNE @@CHECK
CALL GetFinallyReturnAddr
@@CHECK:
MOV EAX, [ESP + 4]
CMP IsFinally, EAX
JE @@DONE
MOV EAX, 0
@@DONE:
end;
function HaveException_beta : boolean;
asm
end;
var
i : integer;
begin
try
i := 3;
i := 5 div i;
finally
Writeln(BoolToStr(HaveException, True));
end;
try
i := 0;
i := 5 div i;
finally
Writeln(BoolToStr(HaveException, True));
end;
end.
|