Alexandre Julliard : ntdll: Use RtlCaptureContext also in RtlUnwind.

Alexandre Julliard julliard at winehq.org
Mon Jul 24 15:51:20 CDT 2017


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jul 24 10:59:45 2017 +0200

ntdll: Use RtlCaptureContext also in RtlUnwind.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 .../api-ms-win-core-rtlsupport-l1-1-0.spec         |  2 +-
 .../api-ms-win-core-rtlsupport-l1-2-0.spec         |  2 +-
 dlls/ntdll/ntdll.spec                              |  2 +-
 dlls/ntdll/signal_i386.c                           | 29 +++++++++++++++++++++-
 dlls/ntoskrnl.exe/ntoskrnl.exe.spec                |  2 +-
 5 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/dlls/api-ms-win-core-rtlsupport-l1-1-0/api-ms-win-core-rtlsupport-l1-1-0.spec b/dlls/api-ms-win-core-rtlsupport-l1-1-0/api-ms-win-core-rtlsupport-l1-1-0.spec
index 2922b1c..428fd06 100644
--- a/dlls/api-ms-win-core-rtlsupport-l1-1-0/api-ms-win-core-rtlsupport-l1-1-0.spec
+++ b/dlls/api-ms-win-core-rtlsupport-l1-1-0/api-ms-win-core-rtlsupport-l1-1-0.spec
@@ -10,6 +10,6 @@
 @ stdcall RtlPcToFileHeader(ptr ptr) ntdll.RtlPcToFileHeader
 @ stdcall -norelay RtlRaiseException(ptr) ntdll.RtlRaiseException
 @ stdcall -arch=x86_64 RtlRestoreContext(ptr ptr) ntdll.RtlRestoreContext
-@ stdcall -register RtlUnwind(ptr ptr ptr ptr) ntdll.RtlUnwind
+@ stdcall -norelay RtlUnwind(ptr ptr ptr ptr) ntdll.RtlUnwind
 @ stdcall -arch=x86_64 RtlUnwindEx(ptr ptr ptr ptr ptr ptr) ntdll.RtlUnwindEx
 @ stdcall -arch=x86_64 RtlVirtualUnwind(long long long ptr ptr ptr ptr ptr) ntdll.RtlVirtualUnwind
diff --git a/dlls/api-ms-win-core-rtlsupport-l1-2-0/api-ms-win-core-rtlsupport-l1-2-0.spec b/dlls/api-ms-win-core-rtlsupport-l1-2-0/api-ms-win-core-rtlsupport-l1-2-0.spec
index 68f2e86..a037b0d 100644
--- a/dlls/api-ms-win-core-rtlsupport-l1-2-0/api-ms-win-core-rtlsupport-l1-2-0.spec
+++ b/dlls/api-ms-win-core-rtlsupport-l1-2-0/api-ms-win-core-rtlsupport-l1-2-0.spec
@@ -3,4 +3,4 @@
 @ stdcall RtlCompareMemory(ptr ptr long) ntdll.RtlCompareMemory
 @ stdcall RtlPcToFileHeader(ptr ptr) ntdll.RtlPcToFileHeader
 @ stdcall -norelay RtlRaiseException(ptr) ntdll.RtlRaiseException
-@ stdcall -register RtlUnwind(ptr ptr ptr ptr) ntdll.RtlUnwind
+@ stdcall -norelay RtlUnwind(ptr ptr ptr ptr) ntdll.RtlUnwind
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 141f50d..68d7f22 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -940,7 +940,7 @@
 # @ stub RtlUnlockBootStatusData
 @ stdcall RtlUnlockHeap(long)
 # @ stub RtlUnlockMemoryStreamRegion
-@ stdcall -register RtlUnwind(ptr ptr ptr ptr)
+@ stdcall -norelay RtlUnwind(ptr ptr ptr ptr)
 @ stdcall -arch=x86_64 RtlUnwindEx(ptr ptr ptr ptr ptr ptr)
 @ stdcall RtlUpcaseUnicodeChar(long)
 @ stdcall RtlUpcaseUnicodeString(ptr ptr long)
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index ead1d56..9d7b726 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -2667,6 +2667,11 @@ void WINAPI __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID ta
     pRecord->ExceptionFlags |= EH_UNWINDING | (pEndFrame ? 0 : EH_EXIT_UNWIND);
 
     TRACE( "code=%x flags=%x\n", pRecord->ExceptionCode, pRecord->ExceptionFlags );
+    TRACE( "eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n",
+           context->Eax, context->Ebx, context->Ecx, context->Edx, context->Esi, context->Edi );
+    TRACE( "ebp=%08x esp=%08x eip=%08x cs=%04x ds=%04x fs=%04x gs=%04x flags=%08x\n",
+           context->Ebp, context->Esp, context->Eip, LOWORD(context->SegCs), LOWORD(context->SegDs),
+           LOWORD(context->SegFs), LOWORD(context->SegGs), context->EFlags );
 
     /* get chain of exception frames */
     frame = NtCurrentTeb()->Tib.ExceptionList;
@@ -2697,8 +2702,30 @@ void WINAPI __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID ta
         }
         frame = __wine_pop_frame( frame );
     }
+
+    NtSetContextThread( GetCurrentThread(), context );
 }
-DEFINE_REGS_ENTRYPOINT( RtlUnwind, 4 )
+__ASM_STDCALL_FUNC( RtlUnwind, 16,
+                    "pushl %ebp\n\t"
+                    __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
+                    __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
+                    "movl %esp,%ebp\n\t"
+                    __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                    "leal -(0x2cc+8)(%esp),%esp\n\t" /* sizeof(CONTEXT) + alignment */
+                    "pushl %esp\n\t"                 /* context */
+                    "call " __ASM_NAME("RtlCaptureContext") __ASM_STDCALL(4) "\n\t"
+                    "leal 24(%ebp),%eax\n\t"
+                    "movl %eax,0xc4(%esp)\n\t"       /* context->Esp */
+                    "pushl %esp\n\t"
+                    "pushl 20(%ebp)\n\t"
+                    "pushl 16(%ebp)\n\t"
+                    "pushl 12(%ebp)\n\t"
+                    "pushl 8(%ebp)\n\t"
+                    "call " __ASM_NAME("__regs_RtlUnwind") __ASM_STDCALL(20) "\n\t"
+                    "leave\n\t"
+                    __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
+                    __ASM_CFI(".cfi_same_value %ebp\n\t")
+                    "ret $16" )  /* actually never returns */
 
 
 /*******************************************************************
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 1f60f61..0da60b5 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -1185,7 +1185,7 @@
 @ stdcall RtlUnicodeToMultiByteSize(ptr ptr long) ntdll.RtlUnicodeToMultiByteSize
 @ stdcall RtlUnicodeToOemN(ptr long ptr ptr long) ntdll.RtlUnicodeToOemN
 @ stub RtlUnlockBootStatusData
-@ stdcall -register RtlUnwind(ptr ptr ptr ptr) ntdll.RtlUnwind
+@ stdcall -norelay RtlUnwind(ptr ptr ptr ptr) ntdll.RtlUnwind
 @ stdcall -arch=x86_64 RtlUnwindEx(ptr ptr ptr ptr ptr ptr) ntdll.RtlUnwindEx
 @ stdcall RtlUpcaseUnicodeChar(long) ntdll.RtlUpcaseUnicodeChar
 @ stdcall RtlUpcaseUnicodeString(ptr ptr long) ntdll.RtlUpcaseUnicodeString




More information about the wine-cvs mailing list