Piotr Caban : ntdll: Pass updated context inside dispatch.ContextRecord in call_stack_handlers.

Alexandre Julliard julliard at winehq.org
Thu Aug 18 10:23:24 CDT 2016


Module: wine
Branch: master
Commit: 4af2012729b7ad656fe240838697eeb2ce5c924e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4af2012729b7ad656fe240838697eeb2ce5c924e

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Aug 17 12:48:24 2016 +0200

ntdll: Pass updated context inside dispatch.ContextRecord in call_stack_handlers.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/signal_x86_64.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 5633e0b..f5ecf80 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2312,7 +2312,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
     EXCEPTION_REGISTRATION_RECORD *teb_frame = NtCurrentTeb()->Tib.ExceptionList;
     UNWIND_HISTORY_TABLE table;
     DISPATCHER_CONTEXT dispatch;
-    CONTEXT context, new_context;
+    CONTEXT context;
     LDR_MODULE *module;
     NTSTATUS status;
 
@@ -2322,8 +2322,6 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
     dispatch.HistoryTable  = &table;
     for (;;)
     {
-        new_context = context;
-
         /* FIXME: should use the history table to make things faster */
 
         dispatch.ImageBase = 0;
@@ -2332,11 +2330,11 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
 
         /* first look for PE exception information */
 
-        if ((dispatch.FunctionEntry = lookup_function_info( context.Rip, &dispatch.ImageBase, &module )))
+        if ((dispatch.FunctionEntry = lookup_function_info( dispatch.ControlPc, &dispatch.ImageBase, &module )))
         {
             dispatch.LanguageHandler = RtlVirtualUnwind( UNW_FLAG_EHANDLER, dispatch.ImageBase,
-                                                         context.Rip, dispatch.FunctionEntry,
-                                                         &new_context, &dispatch.HandlerData,
+                                                         dispatch.ControlPc, dispatch.FunctionEntry,
+                                                         &context, &dispatch.HandlerData,
                                                          &dispatch.EstablisherFrame, NULL );
             goto unwind_done;
         }
@@ -2347,11 +2345,11 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
         {
             BOOL got_info = FALSE;
             struct dwarf_eh_bases bases;
-            const struct dwarf_fde *fde = _Unwind_Find_FDE( (void *)(context.Rip - 1), &bases );
+            const struct dwarf_fde *fde = _Unwind_Find_FDE( (void *)(dispatch.ControlPc - 1), &bases );
 
             if (fde)
             {
-                status = dwarf_virtual_unwind( context.Rip, &dispatch.EstablisherFrame, &new_context,
+                status = dwarf_virtual_unwind( dispatch.ControlPc, &dispatch.EstablisherFrame, &context,
                                                fde, &bases, &dispatch.LanguageHandler, &dispatch.HandlerData );
                 if (status != STATUS_SUCCESS) return status;
                 got_info = TRUE;
@@ -2359,7 +2357,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
 #ifdef HAVE_LIBUNWIND_H
             else
             {
-                status = libunwind_virtual_unwind( context.Rip, &got_info, &dispatch.EstablisherFrame, &new_context,
+                status = libunwind_virtual_unwind( dispatch.ControlPc, &got_info, &dispatch.EstablisherFrame, &context,
                                                    &dispatch.LanguageHandler, &dispatch.HandlerData );
                 if (status != STATUS_SUCCESS) return status;
             }
@@ -2378,11 +2376,9 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
         }
         else WARN( "exception data not found in %s\n", debugstr_w(module->BaseDllName.Buffer) );
 
-        /* no exception information, treat as a leaf function */
-
-        new_context.Rip = *(ULONG64 *)context.Rsp;
-        new_context.Rsp = context.Rsp + sizeof(ULONG64);
-        dispatch.EstablisherFrame = new_context.Rsp;
+        context.Rip = *(ULONG64 *)context.Rsp;
+        context.Rsp = context.Rsp + sizeof(ULONG64);
+        dispatch.EstablisherFrame = context.Rsp;
         dispatch.LanguageHandler = NULL;
 
     unwind_done:
@@ -2426,10 +2422,10 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
             }
         }
         /* hack: call wine handlers registered in the tib list */
-        else while ((ULONG64)teb_frame < new_context.Rsp)
+        else while ((ULONG64)teb_frame < context.Rsp)
         {
             TRACE( "found wine frame %p rsp %lx handler %p\n",
-                   teb_frame, new_context.Rsp, teb_frame->Handler );
+                    teb_frame, context.Rsp, teb_frame->Handler );
             dispatch.EstablisherFrame = (ULONG64)teb_frame;
             switch (call_teb_handler( rec, orig_context, &dispatch, teb_frame ))
             {
@@ -2459,8 +2455,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
             teb_frame = teb_frame->Prev;
         }
 
-        if (new_context.Rsp == (ULONG64)NtCurrentTeb()->Tib.StackBase) break;
-        context = new_context;
+        if (context.Rsp == (ULONG64)NtCurrentTeb()->Tib.StackBase) break;
     }
     return STATUS_UNHANDLED_EXCEPTION;
 }




More information about the wine-cvs mailing list