MiGetPageForHeader

VOID __fastcall MiGetPageForHeader(_MI_PARTITION *Partition, UINT64 PreferredNode){
  unsigned int v2; 
  _ETHREAD *CurrentThread; 
  _MMPFN *SystemPage; 
  char EffectivePagePriorityThread; 
  UINT8 v7; 
  char v8; 
  _MI_COLOR_BASE ColorBase[10]; 

  v2 = PreferredNode;
  *(_OWORD *)ColorBase = 0i64;
  if( MiObtainFaultCharges(Partition, 1ui64, 1) )
  {
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    MiInitializePageColorBase(&CurrentThread->Tcb.ApcState.Process->Vm.Instance, v2, ColorBase);
    SystemPage = MiGetSystemPage((ULONG_PTR *)&Partition->Core.PartitionId, ColorBase);
    if( SystemPage )
    {
      EffectivePagePriorityThread = MiGetEffectivePagePriorityThread(CurrentThread);
      v7 = MiLockPageInline(SystemPage);
      v8 = *((_BYTE *)&SystemPage->u3 + 3) ^ EffectivePagePriorityThread;
      SystemPage->PteLong = 0i64;
      *((_BYTE *)&SystemPage->u3 + 3) ^= v8 & 7;
      SystemPage->u2._bf_0 |= 0x4000000000000000ui64;
      SystemPage->u3.ReferenceCount = 1;
      SystemPage->OriginalPte = ZeroPte;
      _InterlockedAnd64(&SystemPage->u2.Lock, 0x7FFFFFFFFFFFFFFFui64);
      __writecr8(v7);
    }
    else
    {
      MiReturnFaultCharges(Partition, 1ui64, 1ui64);
    }
  }
}

Referenced by:

MiCreateMdl
MiInitializeImageProtos