首页  编辑  

调用堆栈

Tags: /超级猛料/Language.Object Pascal/内嵌汇编、函数、过程/   Date Created:

function CallerOfCaller: pointer;        //with stack frames !

asm

       cmp ebp, 0        //this can happen when there are no stack frames

       je @@EndOfStack

       mov eax, [EBP]

       cmp eax, ebp

       jb @@EndOfStack

       mov eax, [eax + 4]

       sub eax, 4

       ret

       @@EndOfStack:

       mov eax, $FFFF

end;

function Caller: pointer;        //with stack frame !

asm

       cmp ebp, 0        //this can happen when there are no stack frames

       je @@EndOfStack

       mov eax, [ebp + 4]

       sub eax, 4

       ret

       @@EndOfStack:

       mov eax, $FFFF

end;