From 682555b37e32af2a4caca2c449562daaf24b793a Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 18 Nov 2008 00:39:39 +0000 Subject: [PATCH] RtlWalkFrameChain: - stop when we leave the stack or Rip gets 0 svn path=/branches/ros-amd64-bringup/; revision=37428 --- reactos/lib/rtl/amd64/unwind.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/reactos/lib/rtl/amd64/unwind.c b/reactos/lib/rtl/amd64/unwind.c index 8374b2bfa9f..733bd998860 100644 --- a/reactos/lib/rtl/amd64/unwind.c +++ b/reactos/lib/rtl/amd64/unwind.c @@ -336,11 +336,14 @@ RtlWalkFrameChain(OUT PVOID *Callers, PVOID HandlerData; INT i; PRUNTIME_FUNCTION FunctionEntry; -DPRINT1("RtlWalkFrameChain called\n"); - RtlCaptureContext(&Context); + DPRINT("Enter RtlWalkFrameChain\n"); + + /* Capture the current Context */ + RtlCaptureContext(&Context); ControlPc = Context.Rip; + /* Get the stack limits */ RtlpGetStackLimits(&StackLow, &StackHigh); /* Check if we want the user-mode stack frame */ @@ -374,13 +377,24 @@ DPRINT1("RtlWalkFrameChain called\n"); DPRINT("normal funtion, new Rip = %p, new Rsp = %p\n", (PVOID)Context.Rip, (PVOID)Context.Rsp); } + /* Check if new Rip is valid */ + if (!Context.Rip) + { + break; + } + + /* Check, if we have left our stack */ + if ((Context.Rsp < StackLow) || (Context.Rsp > StackHigh)) + { + break; + } + + /* Save this frame and continue with new Rip */ ControlPc = Context.Rip; - /* Save this frame */ - Callers[i] = (PVOID)ControlPc; - } + DPRINT("RtlWalkFrameChain returns %ld\n", i); return i; }