[NTOS:KE/x64] Handle extended processor state on context switch

This commit is contained in:
Timo Kreuzer 2023-11-14 16:51:04 +02:00
parent d6874fe7b9
commit 294eb31cfd

View file

@ -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;