What does the DUnit2 CallerAddr function do and how to convert it to 64 bits?

I'm trying to get DUnit2 to work under 64 bits, but I'm stumped by what this method does, not to mention how to convert it to 64 bits. Pure Pascal is better, but since it belongs to the stack (ebp), this may not be possible.

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; 
+7
source share
2 answers
 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; 
+8
source
 function CallerAddr: Pointer; assembler; const CallerIP = $4; asm mov rax, rcx ;For int.. XMM0 for float call IsBadPointer test rax,rax jne @@Error mov rax, [rcx].CallerIP sub rax, 5 // 5 bytes for call push rax call IsBadPointer test rax,rax pop rax je @@Finish @@Error: xor rax, rax @@Finish: end; 
-one
source

All Articles