[NTOS:KE] Use multi-processor-aware KeGetPcr() instead of the legacy PCR.

This commit is contained in:
Hermès Bélusca-Maïto 2019-04-27 17:57:49 +02:00
parent 04906f2abb
commit 4d5a2dd0f3
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -477,8 +477,8 @@ KiTrap02Handler(VOID)
_disable(); _disable();
/* Get the current TSS, thread, and process */ /* Get the current TSS, thread, and process */
Tss = PCR->TSS; Tss = KeGetPcr()->TSS;
Thread = ((PKIPCR)PCR)->PrcbData.CurrentThread; Thread = ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread;
Process = Thread->ApcState.Process; Process = Thread->ApcState.Process;
/* Save data usually not present in the TSS */ /* Save data usually not present in the TSS */
@ -498,7 +498,7 @@ KiTrap02Handler(VOID)
* Note that in reality, we are already on the NMI TSS -- we just * Note that in reality, we are already on the NMI TSS -- we just
* need to update the PCR to reflect this. * need to update the PCR to reflect this.
*/ */
PCR->TSS = NmiTss; KeGetPcr()->TSS = NmiTss;
__writeeflags(__readeflags() &~ EFLAGS_NESTED_TASK); __writeeflags(__readeflags() &~ EFLAGS_NESTED_TASK);
TssGdt->HighWord.Bits.Dpl = 0; TssGdt->HighWord.Bits.Dpl = 0;
TssGdt->HighWord.Bits.Pres = 1; TssGdt->HighWord.Bits.Pres = 1;
@ -523,7 +523,7 @@ KiTrap02Handler(VOID)
TrapFrame.Esi = Tss->Esi; TrapFrame.Esi = Tss->Esi;
TrapFrame.Edi = Tss->Edi; TrapFrame.Edi = Tss->Edi;
TrapFrame.SegFs = Tss->Fs; TrapFrame.SegFs = Tss->Fs;
TrapFrame.ExceptionList = PCR->NtTib.ExceptionList; TrapFrame.ExceptionList = KeGetPcr()->NtTib.ExceptionList;
TrapFrame.PreviousPreviousMode = (ULONG)-1; TrapFrame.PreviousPreviousMode = (ULONG)-1;
TrapFrame.Eax = Tss->Eax; TrapFrame.Eax = Tss->Eax;
TrapFrame.Ecx = Tss->Ecx; TrapFrame.Ecx = Tss->Ecx;
@ -547,10 +547,10 @@ KiTrap02Handler(VOID)
* the normal APIs here as playing with the IRQL could change the system * the normal APIs here as playing with the IRQL could change the system
* state. * state.
*/ */
OldIrql = PCR->Irql; OldIrql = KeGetPcr()->Irql;
PCR->Irql = HIGH_LEVEL; KeGetPcr()->Irql = HIGH_LEVEL;
HalHandleNMI(NULL); HalHandleNMI(NULL);
PCR->Irql = OldIrql; KeGetPcr()->Irql = OldIrql;
} }
/* /*
@ -560,14 +560,14 @@ KiTrap02Handler(VOID)
* We have to make sure we're still in our original NMI -- a nested NMI * We have to make sure we're still in our original NMI -- a nested NMI
* will point back to the NMI TSS, and in that case we're hosed. * will point back to the NMI TSS, and in that case we're hosed.
*/ */
if (PCR->TSS->Backlink == KGDT_NMI_TSS) if (KeGetPcr()->TSS->Backlink == KGDT_NMI_TSS)
{ {
/* Unhandled: crash the system */ /* Unhandled: crash the system */
KiSystemFatalException(EXCEPTION_NMI, NULL); KiSystemFatalException(EXCEPTION_NMI, NULL);
} }
/* Restore original TSS */ /* Restore original TSS */
PCR->TSS = Tss; KeGetPcr()->TSS = Tss;
/* Set it back to busy */ /* Set it back to busy */
TssGdt->HighWord.Bits.Dpl = 0; TssGdt->HighWord.Bits.Dpl = 0;