msvcr110: Add __crtCapturePreviousContext implementation.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2018-04-05 21:02:47 +02:00 committed by Alexandre Julliard
parent a2a258f4be
commit 19bb93ec10
4 changed files with 41 additions and 3 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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__ */