From 555300d680ef689ad554abf8945db469f9329799 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 1 Oct 2017 14:34:26 +0000 Subject: [PATCH] [RTL/x64] Support frames to skip in flags to RtlWalkFrameChain svn path=/trunk/; revision=76019 --- reactos/sdk/lib/rtl/amd64/unwind.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/reactos/sdk/lib/rtl/amd64/unwind.c b/reactos/sdk/lib/rtl/amd64/unwind.c index c909250eaf3..f9af729ce88 100644 --- a/reactos/sdk/lib/rtl/amd64/unwind.c +++ b/reactos/sdk/lib/rtl/amd64/unwind.c @@ -524,11 +524,14 @@ RtlWalkFrameChain(OUT PVOID *Callers, ULONG64 ControlPc, ImageBase, EstablisherFrame; ULONG64 StackLow, StackHigh; PVOID HandlerData; - ULONG i; + ULONG i, FramesToSkip; PRUNTIME_FUNCTION FunctionEntry; DPRINT("Enter RtlWalkFrameChain\n"); + /* The upper bits in Flags define how many frames to skip */ + FramesToSkip = Flags >> 8; + /* Capture the current Context */ RtlCaptureContext(&Context); ControlPc = Context.Rip; @@ -537,12 +540,12 @@ RtlWalkFrameChain(OUT PVOID *Callers, RtlpGetStackLimits(&StackLow, &StackHigh); /* Check if we want the user-mode stack frame */ - if (Flags == 1) + if (Flags & 1) { } /* Loop the frames */ - for (i = 0; i < Count; i++) + for (i = 0; i < FramesToSkip + Count; i++) { /* Lookup the FunctionEntry for the current ControlPc */ FunctionEntry = RtlLookupFunctionEntry(ControlPc, &ImageBase, NULL); @@ -579,9 +582,14 @@ RtlWalkFrameChain(OUT PVOID *Callers, break; } - /* Save this frame and continue with new Rip */ + /* Continue with new Rip */ ControlPc = Context.Rip; - Callers[i] = (PVOID)ControlPc; + + /* Save value, if we are past the frames to skip */ + if (i >= FramesToSkip) + { + Callers[i - FramesToSkip] = (PVOID)ControlPc; + } } DPRINT("RtlWalkFrameChain returns %ld\n", i); @@ -605,14 +613,8 @@ RtlGetCallersAddress( * 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; - } + *CallersAddress = (Number >= 3) ? Callers[2] : NULL; + *CallersCaller = (Number == 4) ? Callers[3] : NULL; return; } -- 2.17.1