From 83991b37500a18b072dc12a29e8d208265bf69e2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 17 Nov 2008 23:24:59 +0000 Subject: [PATCH] Implement RtlGetCallersAddress svn path=/branches/ros-amd64-bringup/; revision=37425 --- reactos/lib/rtl/amd64/unwind.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/reactos/lib/rtl/amd64/unwind.c b/reactos/lib/rtl/amd64/unwind.c index 20ed21fd976..8374b2bfa9f 100644 --- a/reactos/lib/rtl/amd64/unwind.c +++ b/reactos/lib/rtl/amd64/unwind.c @@ -332,7 +332,7 @@ RtlWalkFrameChain(OUT PVOID *Callers, { CONTEXT Context; ULONG64 ControlPc, ImageBase, EstablisherFrame; - ULONG64 StackBegin, StackEnd; + ULONG64 StackLow, StackHigh; PVOID HandlerData; INT i; PRUNTIME_FUNCTION FunctionEntry; @@ -341,7 +341,7 @@ DPRINT1("RtlWalkFrameChain called\n"); ControlPc = Context.Rip; - RtlpGetStackLimits(&StackBegin, &StackEnd); + RtlpGetStackLimits(&StackLow, &StackHigh); /* Check if we want the user-mode stack frame */ if (Flags == 1) @@ -384,3 +384,29 @@ DPRINT1("RtlWalkFrameChain called\n"); return i; } +// CHEKCME: return PVOID? +// http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Debug/RtlGetCallersAddress.html +VOID +NTAPI +RtlGetCallersAddress( + OUT PVOID *CallersAddress, + OUT PVOID *CallersCaller ) +{ + PVOID Callers[4]; + ULONG Number; + + /* Get callers: + * RtlWalkFrameChain -> RtlGetCallersAddress -> x -> y */ + Number = RtlWalkFrameChain(Callers, 4, 0); + + if (CallersAddress) + { + *CallersAddress = (Number >= 3) ? Callers[2] : NULL; + } + if (CallersCaller) + { + *CallersCaller = (Number == 4) ? Callers[3] : NULL; + } + + return; +}