Commit 34e49897 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

wow64: Support generic xstate in call_user_exception_dispatcher().

parent ff97d397
...@@ -197,17 +197,12 @@ static void __attribute__((used)) call_user_exception_dispatcher( EXCEPTION_RECO ...@@ -197,17 +197,12 @@ static void __attribute__((used)) call_user_exception_dispatcher( EXCEPTION_RECO
ULONG context_ptr; /* 004 */ ULONG context_ptr; /* 004 */
EXCEPTION_RECORD32 rec; /* 008 */ EXCEPTION_RECORD32 rec; /* 008 */
I386_CONTEXT context; /* 058 */ I386_CONTEXT context; /* 058 */
CONTEXT_EX32 context_ex; /* 324 */
BYTE xstate[sizeof(XSTATE)+64]; /* 33c */
DWORD align; /* 4bc */
} *stack; } *stack;
I386_CONTEXT ctx = { CONTEXT_I386_ALL }; I386_CONTEXT ctx = { CONTEXT_I386_ALL };
CONTEXT_EX *context_ex, *src_ex = NULL; CONTEXT_EX *context_ex, *src_ex = NULL;
ULONG flags; ULONG flags, context_length;
C_ASSERT( offsetof(struct exc_stack_layout32, context) == 0x58 ); C_ASSERT( offsetof(struct exc_stack_layout32, context) == 0x58 );
C_ASSERT( offsetof(struct exc_stack_layout32, xstate) == 0x33c );
C_ASSERT( sizeof(struct exc_stack_layout32) == 0x4c0 );
pBTCpuGetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx ); pBTCpuGetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx );
...@@ -231,29 +226,20 @@ static void __attribute__((used)) call_user_exception_dispatcher( EXCEPTION_RECO ...@@ -231,29 +226,20 @@ static void __attribute__((used)) call_user_exception_dispatcher( EXCEPTION_RECO
flags = ctx.ContextFlags; flags = ctx.ContextFlags;
if (src_ex) flags |= CONTEXT_I386_XSTATE; if (src_ex) flags |= CONTEXT_I386_XSTATE;
stack = (struct exc_stack_layout32 *)ULongToPtr( ctx.Esp & ~3 ) - 1; RtlGetExtendedContextLength( flags, &context_length );
stack = (struct exc_stack_layout32 *)ULongToPtr( (ctx.Esp - offsetof(struct exc_stack_layout32, context) - context_length) & ~3 );
stack->rec_ptr = PtrToUlong( &stack->rec ); stack->rec_ptr = PtrToUlong( &stack->rec );
stack->context_ptr = PtrToUlong( &stack->context ); stack->context_ptr = PtrToUlong( &stack->context );
stack->rec = *rec; stack->rec = *rec;
stack->context = ctx; stack->context = ctx;
RtlInitializeExtendedContext( &stack->context, flags, &context_ex ); RtlInitializeExtendedContext( &stack->context, flags, &context_ex );
if (src_ex) RtlCopyExtendedContext( context_ex, WOW64_CONTEXT_XSTATE, src_ex );
/* adjust Eip for breakpoints in software emulation (hardware exceptions already adjust Rip) */ /* adjust Eip for breakpoints in software emulation (hardware exceptions already adjust Rip) */
if (rec->ExceptionCode == EXCEPTION_BREAKPOINT && (wow64info->CpuFlags & WOW64_CPUFLAGS_SOFTWARE)) if (rec->ExceptionCode == EXCEPTION_BREAKPOINT && (wow64info->CpuFlags & WOW64_CPUFLAGS_SOFTWARE))
stack->context.Eip--; stack->context.Eip--;
if (src_ex)
{
XSTATE *src_xs = (XSTATE *)((char *)src_ex + src_ex->XState.Offset);
XSTATE *dst_xs = (XSTATE *)((char *)context_ex + context_ex->XState.Offset);
dst_xs->Mask = src_xs->Mask & ~(ULONG64)3;
dst_xs->CompactionMask = src_xs->CompactionMask;
if ((dst_xs->Mask & 4) &&
src_ex->XState.Length >= sizeof(XSTATE) &&
context_ex->XState.Length >= sizeof(XSTATE))
memcpy( &dst_xs->YmmContext, &src_xs->YmmContext, sizeof(dst_xs->YmmContext) );
}
ctx.Esp = PtrToUlong( stack ); ctx.Esp = PtrToUlong( stack );
ctx.Eip = pLdrSystemDllInitBlock->pKiUserExceptionDispatcher; ctx.Eip = pLdrSystemDllInitBlock->pKiUserExceptionDispatcher;
ctx.EFlags &= ~(0x100|0x400|0x40000); ctx.EFlags &= ~(0x100|0x400|0x40000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment