Checks for context flags containing CONTEXT_XSTATE were incorrect at two places.
The issue was that CONTEXT_XSTATE is not a single bit flag, but contains two
bits set - it is CONTEXT_AMD64 | 0x40. So testing the flag using
(contextFlags & CONTEXT_XSTATE) != 0 was always true, since context flags
on AMD64 always contain CONTEXT_AMD64 and so the `&` result is always non-zero.
// TODO: Enable for all Unix systems
#if defined(_AMD64_) && defined(__linux__)
- if ((lpContext->ContextFlags & CONTEXT_XSTATE) != 0)
+ if ((lpContext->ContextFlags & CONTEXT_XSTATE) == CONTEXT_XSTATE)
{
_ASSERTE(FPREG_HasExtendedState(native));
memcpy_s(FPREG_Xstate_Ymmh(native), sizeof(M128A) * 16, lpContext->VectorRegister, sizeof(M128A) * 16);
// TODO: Enable for all Unix systems
#if defined(_AMD64_) && defined(__linux__)
- if ((contextFlags & CONTEXT_XSTATE) != 0)
+ if ((contextFlags & CONTEXT_XSTATE) == CONTEXT_XSTATE)
{
if (FPREG_HasExtendedState(native))
{