msvcrt: Simplify stack layout in __crtCapturePreviousContext().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-08-21 13:54:46 +02:00
parent 451c8592b9
commit ed6aa17d98

View file

@ -732,9 +732,6 @@ void __cdecl get_prev_context(CONTEXT *ctx, DWORD64 rip)
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");
@ -746,16 +743,14 @@ void __cdecl get_prev_context(CONTEXT *ctx, DWORD64 rip)
}
__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") );
"movq %rcx,8(%rsp)\n\t"
"call " __ASM_NAME("RtlCaptureContext") "\n\t"
"movq 8(%rsp),%rcx\n\t" /* context */
"leaq 8(%rsp),%rax\n\t"
"movq %rax,0x98(%rcx)\n\t" /* context->Rsp */
"movq (%rsp),%rax\n\t"
"movq %rax,0xf8(%rcx)\n\t" /* context->Rip */
"jmp " __ASM_NAME("get_prev_context") )
#endif
#endif /* __x86_64__ */