Module: wine Branch: master Commit: de5f640abf800cbb4674ab0c55f30fc9acb9085a URL: https://gitlab.winehq.org/wine/wine/-/commit/de5f640abf800cbb4674ab0c55f30fc...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Aug 11 14:19:24 2022 +0200
wow64: Directly use CPU area in Wow64KiUserCallbackDispatcher for I386_CONTEXT.
NtSetInformationThread for i386 causes WOW64_CPURESERVED_FLAG_RESET_STATE to be set, which makes subsequent syscall to restore the state instead of returning its result.
---
dlls/wow64/syscall.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index bc6d46258ed..73fb84c6d2e 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -865,13 +865,14 @@ NTSTATUS WINAPI Wow64KiUserCallbackDispatcher( ULONG id, void *args, ULONG len, { case IMAGE_FILE_MACHINE_I386: { - I386_CONTEXT orig_ctx, ctx = { CONTEXT_I386_FULL }; + I386_CONTEXT orig_ctx, *ctx; void *args_data; ULONG *stack;
- NtQueryInformationThread( GetCurrentThread(), ThreadWow64Context, &ctx, sizeof(ctx), NULL ); + RtlWow64GetCurrentCpuArea( NULL, (void **)&ctx, NULL ); + orig_ctx = *ctx;
- stack = args_data = ULongToPtr( (ctx.Esp - len) & ~15 ); + stack = args_data = ULongToPtr( (ctx->Esp - len) & ~15 ); memcpy( args_data, args, len ); *(--stack) = 0; *(--stack) = len; @@ -879,16 +880,13 @@ NTSTATUS WINAPI Wow64KiUserCallbackDispatcher( ULONG id, void *args, ULONG len, *(--stack) = id; *(--stack) = 0xdeadbabe;
- orig_ctx = ctx; - ctx.Esp = PtrToUlong( stack ); - ctx.Eip = pLdrSystemDllInitBlock->pKiUserCallbackDispatcher; - NtSetInformationThread( GetCurrentThread(), ThreadWow64Context, &ctx, sizeof(ctx) ); + ctx->Esp = PtrToUlong( stack ); + ctx->Eip = pLdrSystemDllInitBlock->pKiUserCallbackDispatcher;
if (!__wine_setjmpex( &frame.jmpbuf, NULL )) cpu_simulate(); else - NtSetInformationThread( GetCurrentThread(), ThreadWow64Context, - &orig_ctx, sizeof(orig_ctx) ); + *ctx = orig_ctx; } break;