[fpc-devel]Stack verifying ...

Ingmar Tulva juss_it at ut.ee
Tue May 7 10:55:40 CEST 2002


On Mon, 6 May 2002, Michail A.Baikov wrote:

}Maybe you don't understand me ...

I really didn't, sorry. Not sure if I do understand now but let's try:

{$asmmode Intel}
function CorruptsStack : Boolean;
 const { "Locals" are typed constants because they must not be in stack. }
   JBuf : Jmp_buf = ();
   ESP_Before : DWord = 0;
   ESP_After : DWord = 0;
 begin
   if SetJump(JBuf)=0 then begin
     asm
       mov [ESP_Before],ESP
     end;
     call_something_suspicious;
     asm
       mov [ESP_After],ESP
     end;
     if ESP_Before<>ESP_After then LongJump(JBuf,1);
       { in fact, if ESP_After>ESP_Before, we are still in trouble }
   end
   else Exit(True);
   Result:=False;
 end;

This is probably not exactly what you need but it should help if I got
you right.

------

Ingmar

------

"Salamanders can survive up to six hours outside a fire if regularly fed
pepper" (Scamander 1927).






More information about the fpc-devel mailing list