MiInitializeSystemPtes

UINT64 __fastcall MiInitializeSystemPtes(){
  void *PagesPerBit; 
  CHAR *AnyMultiplexedVm; 
  CHAR *v2; 
  unsigned int v3; 
  __int64 v4; 
  int v5; 
  INT64 *v6; 
  PagesPerBit = (void *)qword_140C4F838;
  AnyMultiplexedVm = MiGetAnyMultiplexedVm(3i64);
  if( !(unsigned int)MiInitializeSystemWorkingSetList(&MiSystemPartition, (INT64)AnyMultiplexedVm, 5i64, 0i64) )
    return 0i64;
  v2 = MiGetAnyMultiplexedVm(4i64);
  if( !(unsigned int)MiInitializeSystemWorkingSetList(&MiSystemPartition, (INT64)v2, 6i64, 0i64) )
    return 0i64;
  *((_QWORD *)KeGetCurrentPrcb() + 4278) = -1i64;
  v3 = ((dword_140CFA17C & 2) << 8) | 0x101;
  v4 = (__int64)PagesPerBit + 0x200000 * (0x800000 - (v3 + (ExGenRandom(1i64) & 0x3FFF)));
  qword_140C4DDE0 = v4;
  MiInitializePteInfo(
    (_MI_SYSTEM_PTE_TYPE *)&qword_140C4EC80,
    MiVaSystemPtes,
    (VOID *)(v4 + 0x100000),
    9ui64,
    (UINT64)PagesPerBit);
  if( !v5 )
    return 0i64;
  dword_140C4EC98 |= 1u;
  qword_140C4ECD0 = qword_140C4E828;
  AnyMultiplexedVm[184] = AnyMultiplexedVm[184] & 0xF8 | 5;
  if( (dword_140CFA17C & 2) != 0
    && (unsigned int)MiInitializeDynamicBitmap(&BitMap, (PVOID)(v4 + 537919488), 0x200000000ui64, 9ui64) != 1 )
  {
    dword_140CFA17C &= ~2u;
  }
  v6 = MiSystemVaToDynamicBitmap(9i64);
  if( MiBuildDynamicRegion((RTL_BITMAP *)v6, PagesPerBit, 0x100000000000ui64)
    && (MiObtainSystemVa(v3, 13i64),
        MiFlags |= 0x20000000u,
        qword_140C4E908 = 0i64,
        (qword_140C4E928 = MiReservePtes((INT64)&qword_140C4EC80, 1ui64)) != 0) )
  {
    return 1i64;
  }
  else
  {
    return 0i64;
  }
}

Referenced by:

MiInitNucleus