diff --git a/patches/msvcr110-__crtCapturePreviousContext/0001-msvcr110-Add-__crtCaptureCurrentContext-implementation.txt b/patches/msvcr110-__crtCapturePreviousContext/0001-msvcr110-Add-__crtCaptureCurrentContext-implementation.txt new file mode 100644 index 00000000..85d89191 --- /dev/null +++ b/patches/msvcr110-__crtCapturePreviousContext/0001-msvcr110-Add-__crtCaptureCurrentContext-implementation.txt @@ -0,0 +1,54 @@ +From d03c4fba17c177b3be775915ae77aa565a78187f Mon Sep 17 00:00:00 2001 +From: Piotr Caban +Date: Fri, 23 Mar 2018 20:57:12 +0100 +Subject: [PATCH 1/2] msvcr110: Add __crtCaptureCurrentContext implementation +To: wine-devel + +--- + dlls/msvcr110/msvcr110.spec | 2 +- + dlls/msvcr120/msvcr120.spec | 2 +- + dlls/msvcr120_app/msvcr120_app.spec | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec +index 27b3508e03..1a041614e2 100644 +--- a/dlls/msvcr110/msvcr110.spec ++++ b/dlls/msvcr110/msvcr110.spec +@@ -904,7 +904,7 @@ + @ cdecl __clean_type_info_names_internal(ptr) + @ cdecl -arch=i386 __control87_2(long long ptr ptr) + @ cdecl __create_locale(long str) MSVCRT__create_locale +-@ stub -arch=win64 __crtCaptureCurrentContext ++@ cdecl -arch=win64 -norelay __crtCaptureCurrentContext(ptr) ntdll.RtlCaptureContext + @ stub -arch=win64 __crtCapturePreviousContext + @ cdecl __crtCompareStringA(long long str long str long) + @ stub -arch=i386,win64 __crtCompareStringEx +diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec +index 254040a4bf..f65669caac 100644 +--- a/dlls/msvcr120/msvcr120.spec ++++ b/dlls/msvcr120/msvcr120.spec +@@ -889,7 +889,7 @@ + @ cdecl __clean_type_info_names_internal(ptr) + @ cdecl -arch=i386 __control87_2(long long ptr ptr) + @ cdecl __create_locale(long str) MSVCRT__create_locale +-@ stub -arch=win64 __crtCaptureCurrentContext ++@ cdecl -arch=win64 -norelay __crtCaptureCurrentContext(ptr) ntdll.RtlCaptureContext + @ stub -arch=win64 __crtCapturePreviousContext + @ cdecl __crtCompareStringA(long long str long str long) + @ stub -arch=i386,win64 __crtCompareStringEx +diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec +index 473905530e..0ba1780078 100644 +--- a/dlls/msvcr120_app/msvcr120_app.spec ++++ b/dlls/msvcr120_app/msvcr120_app.spec +@@ -883,7 +883,7 @@ + @ cdecl __clean_type_info_names_internal(ptr) msvcr120.__clean_type_info_names_internal + @ cdecl -arch=i386 __control87_2(long long ptr ptr) msvcr120.__control87_2 + @ cdecl __create_locale(long str) msvcr120.__create_locale +-@ stub -arch=win64 __crtCaptureCurrentContext ++@ cdecl -arch=win64 -norelay __crtCaptureCurrentContext(ptr) msvcr120.__crtCaptureCurrentContext + @ stub -arch=win64 __crtCapturePreviousContext + @ stub __crtCloseWinRTThreadHandle + @ cdecl __crtCompareStringA(long long str long str long) msvcr120.__crtCompareStringA +-- +2.16.1 + diff --git a/patches/msvcr110-__crtCapturePreviousContext/0002-msvcr110-Add-__crtCapturePreviousContext-implementatio.txt b/patches/msvcr110-__crtCapturePreviousContext/0002-msvcr110-Add-__crtCapturePreviousContext-implementatio.txt new file mode 100644 index 00000000..51277663 --- /dev/null +++ b/patches/msvcr110-__crtCapturePreviousContext/0002-msvcr110-Add-__crtCapturePreviousContext-implementatio.txt @@ -0,0 +1,102 @@ +From de4f0940ee3fe0770e214441aa9bb2e5efbd8658 Mon Sep 17 00:00:00 2001 +From: Piotr Caban +Date: Fri, 23 Mar 2018 21:05:45 +0100 +Subject: [PATCH 2/2] msvcr110: Add __crtCapturePreviousContext implementation +To: wine-devel + +--- + dlls/msvcr110/msvcr110.spec | 2 +- + dlls/msvcr120/msvcr120.spec | 2 +- + dlls/msvcr120_app/msvcr120_app.spec | 2 +- + dlls/msvcrt/except_x86_64.c | 38 +++++++++++++++++++++++++++++++++++++ + 4 files changed, 41 insertions(+), 3 deletions(-) + +diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec +index 1a041614e2..3572664443 100644 +--- a/dlls/msvcr110/msvcr110.spec ++++ b/dlls/msvcr110/msvcr110.spec +@@ -905,7 +905,7 @@ + @ cdecl -arch=i386 __control87_2(long long ptr ptr) + @ cdecl __create_locale(long str) MSVCRT__create_locale + @ cdecl -arch=win64 -norelay __crtCaptureCurrentContext(ptr) ntdll.RtlCaptureContext +-@ stub -arch=win64 __crtCapturePreviousContext ++@ cdecl -arch=x86_64 -norelay __crtCapturePreviousContext(ptr) + @ cdecl __crtCompareStringA(long long str long str long) + @ stub -arch=i386,win64 __crtCompareStringEx + @ cdecl __crtCompareStringW(long long wstr long wstr long) +diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec +index f65669caac..9e0c3957b5 100644 +--- a/dlls/msvcr120/msvcr120.spec ++++ b/dlls/msvcr120/msvcr120.spec +@@ -890,7 +890,7 @@ + @ cdecl -arch=i386 __control87_2(long long ptr ptr) + @ cdecl __create_locale(long str) MSVCRT__create_locale + @ cdecl -arch=win64 -norelay __crtCaptureCurrentContext(ptr) ntdll.RtlCaptureContext +-@ stub -arch=win64 __crtCapturePreviousContext ++@ cdecl -arch=x86_64 -norelay __crtCapturePreviousContext(ptr) + @ cdecl __crtCompareStringA(long long str long str long) + @ stub -arch=i386,win64 __crtCompareStringEx + @ cdecl __crtCompareStringW(long long wstr long wstr long) +diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec +index 0ba1780078..a732118849 100644 +--- a/dlls/msvcr120_app/msvcr120_app.spec ++++ b/dlls/msvcr120_app/msvcr120_app.spec +@@ -884,7 +884,7 @@ + @ cdecl -arch=i386 __control87_2(long long ptr ptr) msvcr120.__control87_2 + @ cdecl __create_locale(long str) msvcr120.__create_locale + @ cdecl -arch=win64 -norelay __crtCaptureCurrentContext(ptr) msvcr120.__crtCaptureCurrentContext +-@ stub -arch=win64 __crtCapturePreviousContext ++@ cdecl -arch=x86_64 -norelay __crtCapturePreviousContext(ptr) msvcr120.__crtCapturePreviousContext + @ stub __crtCloseWinRTThreadHandle + @ cdecl __crtCompareStringA(long long str long str long) msvcr120.__crtCompareStringA + @ cdecl __crtCompareStringW(long long wstr long wstr long) msvcr120.__crtCompareStringW +diff --git a/dlls/msvcrt/except_x86_64.c b/dlls/msvcrt/except_x86_64.c +index 77c519dc50..9cd19398a8 100644 +--- a/dlls/msvcrt/except_x86_64.c ++++ b/dlls/msvcrt/except_x86_64.c +@@ -798,4 +798,42 @@ int __cdecl _fpieee_flt(ULONG exception_code, EXCEPTION_POINTERS *ep, + return EXCEPTION_CONTINUE_SEARCH; + } + ++#if _MSVCR_VER>=110 && _MSVCR_VER<=120 ++/********************************************************************* ++ * __crtCapturePreviousContext (MSVCR110.@) ++ */ ++void __cdecl get_prev_context(CONTEXT *ctx, DWORD64 rip) ++{ ++ ULONG64 frame, image_base; ++ RUNTIME_FUNCTION *rf; ++ void *data; ++ ++ TRACE("(%p)\n", ctx); ++ ++ ctx->Rip = rip; ++ ctx->Rsp += 3*8; /* Rip, Rcx, return address */ ++ ++ rf = RtlLookupFunctionEntry(ctx->Rip, &image_base, NULL); ++ if(!rf) { ++ FIXME("RtlLookupFunctionEntry failed\n"); ++ return; ++ } ++ ++ RtlVirtualUnwind(UNW_FLAG_NHANDLER, image_base, ctx->Rip, ++ rf, ctx, &data, &frame, NULL); ++} ++ ++__ASM_GLOBAL_FUNC( __crtCapturePreviousContext, ++ "pushq (%rsp)\n\t" /* save Rip */ ++ __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t") ++ "pushq %rcx\n\t" ++ __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t") ++ "call " __ASM_NAME("RtlCaptureContext") "\n\t" ++ "popq %rcx\n\t" ++ __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") ++ "popq %rdx\n\t" ++ __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") ++ "jmp " __ASM_NAME("get_prev_context") ); ++#endif ++ + #endif /* __x86_64__ */ +-- +2.16.1 + diff --git a/patches/msvcr110-__crtCapturePreviousContext/definition b/patches/msvcr110-__crtCapturePreviousContext/definition new file mode 100644 index 00000000..c3823b7d --- /dev/null +++ b/patches/msvcr110-__crtCapturePreviousContext/definition @@ -0,0 +1 @@ +Fixes: [43051] Implement __crtCapturePreviousContext and __crtCaptureCurrentContext