DUnit2的CallerAddr函数有什么作用,如何将其转换为64位?

Nic*_*ing 7 delphi assembly 32bit-64bit

我试图让DUnit2在64位下工作,但我很难接受这个方法的功能,更不用说如何将它转换为64位.Pure Pascal会更好,但由于它指的是堆栈(ebp),它可能是不可能的.

function CallerAddr: Pointer; assembler;
const
  CallerIP = $4;
asm
   mov   eax, ebp
   call  IsBadPointer
   test  eax,eax
   jne   @@Error

   mov   eax, [ebp].CallerIP
   sub   eax, 5   // 5 bytes for call

   push  eax
   call  IsBadPointer
   test  eax,eax
   pop   eax
   je    @@Finish

@@Error:
   xor eax, eax
@@Finish:
end;
Run Code Online (Sandbox Code Playgroud)

pan*_*ani 8

function RtlCaptureStackBackTrace(FramesToSkip: ULONG; FramesToCapture: ULONG; 
  out BackTrace: Pointer; BackTraceHash: PULONG): USHORT; stdcall; 
  external 'kernel32.dll' name 'RtlCaptureStackBackTrace' delayed;

function CallerAddr: Pointer;
begin
  // Skip 2 Frames, one for the return of CallerAddr and one for the
  // return of RtlCaptureStackBackTrace
  if RtlCaptureStackBackTrace(2, 1, Result, nil) > 0 then
  begin
    if not IsBadPointer(Result) then
      Result := Pointer(NativeInt(Result) - 5)
    else
      Result := nil;
  end
  else
  begin
    Result := nil;
  end;
end;
Run Code Online (Sandbox Code Playgroud)