Module: wine Branch: master Commit: 19bb93ec100785c6466f211165d2353e96f58d20 URL: https://source.winehq.org/git/wine.git/?a=commit;h=19bb93ec100785c6466f21116...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Apr 5 21:02:47 2018 +0200
msvcr110: Add __crtCapturePreviousContext implementation.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 1a04161..3572664 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 f65669c..9e0c395 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 0ba1780..a732118 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 77c519d..9cd1939 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__ */