diff --git a/ntoskrnl/ke/amd64/thrdini.c b/ntoskrnl/ke/amd64/thrdini.c index a1f9d614508..e4cbdff084b 100644 --- a/ntoskrnl/ke/amd64/thrdini.c +++ b/ntoskrnl/ke/amd64/thrdini.c @@ -167,9 +167,21 @@ KiSwapContextResume( PKPROCESS OldProcess, NewProcess; /* Setup ring 0 stack pointer */ - Pcr->TssBase->Rsp0 = (ULONG64)NewThread->InitialStack; // FIXME: NPX save area? + Pcr->TssBase->Rsp0 = (ULONG64)NewThread->InitialStack; Pcr->Prcb.RspBase = Pcr->TssBase->Rsp0; + /* Save old thread's extended state */ + if (OldThread->NpxState != 0) + { + KiSaveXState(OldThread->StateSaveArea, OldThread->NpxState); + } + + /* Load new thread's extended state */ + if (NewThread->NpxState != 0) + { + KiRestoreXState(NewThread->StateSaveArea, NewThread->NpxState); + } + /* Now we are the new thread. Check if it's in a new process */ OldProcess = OldThread->ApcState.Process; NewProcess = NewThread->ApcState.Process;