From dc63fbf98d1af6396533a9af2cfb1eb996a18035 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 24 Jul 2017 10:59:45 +0200 Subject: [PATCH] ntdll: Use RtlCaptureContext also in RtlUnwind. Signed-off-by: Alexandre Julliard --- .../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 2922b1c1427..428fd06bb75 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 68f2e86b08b..a037b0d2601 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 141f50d6d02..68d7f22b192 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 ead1d56442f..9d7b7261f80 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 1f60f61fa50..0da60b54570 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