From: Jinoh Kang jinoh.kang.kr@gmail.com
Today, wow64 calls BTCpuGetContext() and BTCpuSetContext() when setting up WoW64 context for raising or dispatching exceptions.
The context flags include CONTEXT_I386_DEBUG_REGISTERS, which means that debug registers shall be accessed. This is undesirable, because:
1. This makes BTCpu{Get,Set}Context() fail on Linux when the WoW64 process is being ptrace()'d by a debugger (e.g., GDB).
2. Accessing debug registers forces a server call, which is a costly operation. This performance impact is not justified since wow64 never touches the debug registers anyway.
Fix this by excluding debug registers from the context flags. This matches the native exception dispatcher's behavior, since signal context doesn't have any debug registers. --- dlls/wow64/syscall.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 113e9f538fb..72dfe4468dc 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -204,7 +204,7 @@ static void call_user_exception_dispatcher( EXCEPTION_RECORD32 *rec, void *ctx32 EXCEPTION_RECORD32 rec; I386_CONTEXT context; } *stack; - I386_CONTEXT *context, ctx = { CONTEXT_I386_ALL }; + I386_CONTEXT *context, ctx = { CONTEXT_I386_ALL & ~CONTEXT_I386_DEBUG_REGISTERS }; CONTEXT_EX *context_ex, *src_ex = NULL; ULONG size, flags;
@@ -310,7 +310,7 @@ static void call_raise_user_exception_dispatcher( ULONG code ) { case IMAGE_FILE_MACHINE_I386: { - I386_CONTEXT ctx = { CONTEXT_I386_ALL }; + I386_CONTEXT ctx = { CONTEXT_I386_ALL & ~CONTEXT_I386_DEBUG_REGISTERS };
pBTCpuGetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx ); ctx.Esp -= sizeof(ULONG); @@ -1246,7 +1246,7 @@ NTSTATUS WINAPI Wow64RaiseException( int code, EXCEPTION_RECORD *rec ) { EXCEPTION_RECORD int_rec = { 0 };
- ctx32.i386.ContextFlags = CONTEXT_I386_ALL; + ctx32.i386.ContextFlags = CONTEXT_I386_ALL & ~CONTEXT_I386_DEBUG_REGISTERS; pBTCpuGetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx32.i386 ); if (code == -1) break; int_rec.ExceptionAddress = (void *)(ULONG_PTR)ctx32.i386.Eip;
This merge request was closed by Jinoh Kang.