MiExpandPartitionIds

VOID __stdcall MiExpandPartitionIds(){
  unsigned int v0; 
  _RTL_BITMAP *Pool; 
  int v2; 
  _RTL_BITMAP *v3; 
  _MMPTE *v4; 
  __int64 v5; 
  _MMPTE *PteAddress; 
  _KTBFLUSH_TYPE v7; 

  v0 = 512;
  if( (_UNKNOWN *)*(&stru_140C4DB30 + 267) != (_UNKNOWN *)((char *)&stru_140C4DB30 + 2128) )
    v0 = **(&stru_140C4DB30 + 263) + 512;
  if( v0 <= **(&stru_140C4DB30 + 263) || v0 > 0x400 )
  {
    v2 = 0;
    v3 = 0i64;
  }
  else
  {
    Pool = (_RTL_BITMAP *)MiAllocatePool(64i64, 8 * ((v0 >> 6) + ((v0 & 0x3F) != 0) + 2), 0x20206D4Dui64);
    v2 = 0;
    v3 = Pool;
    if( !Pool )
      return;
    Pool->SizeOfBitMap = v0;
    Pool->Buffer = &Pool[1].SizeOfBitMap;
  }
  if( v3 )
  {
    if( (_UNKNOWN *)*(&stru_140C4DB30 + 267) == (_UNKNOWN *)((char *)&stru_140C4DB30 + 2128) )
    {
      v4 = MiReservePtes((_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432), 2ui64);
      if( !v4 )
        goto LABEL_18;
      v5 = (__int64)(((_QWORD)v4 << 25) - ((_QWORD)MmGetPteBase() << 25)) >> 16;
      if( !v5 )
        goto LABEL_18;
    }
    else
    {
      v5 = *(&stru_140C4DB30 + 267) + 8i64 * (unsigned int)**(&stru_140C4DB30 + 263);
    }
    PteAddress = MiGetPteAddress((VOID *)v5);
    if( MiMakeZeroedPageTables(PteAddress, PteAddress, 0x21ui64, MiVaSystemPtes) )
    {
      memset((VOID *)v5, 0i64, 0x1000u);
      if( (_UNKNOWN *)*(&stru_140C4DB30 + 267) == (_UNKNOWN *)((char *)&stru_140C4DB30 + 2128) )
      {
        *(_QWORD *)v5 = **(&stru_140C4DB30 + 267);
        *(&stru_140C4DB30 + 267) = v5;
      }
      RtlClearAllBits(v3);
      LOBYTE(v2) = (**(&stru_140C4DB30 + 263) & 0x3F) != 0;
      memmove(
        v3->Buffer,
        *(const VOID **)(*(&stru_140C4DB30 + 263) + 8i64),
        8 * ((**(&stru_140C4DB30 + 263) >> 6) + v2));
      if( (_UNKNOWN *)*(&stru_140C4DB30 + 263) != (_UNKNOWN *)((char *)&stru_140C4DB30 + 2112) )
        ExFreePoolWithTag(*(&stru_140C4DB30 + 263), 0);
      *(&stru_140C4DB30 + 263) = v3;
      return;
    }
    if( (_UNKNOWN *)*(&stru_140C4DB30 + 267) == (_UNKNOWN *)((char *)&stru_140C4DB30 + 2128) )
      MiReleasePtes((_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432), PteAddress, 1ui64, v7);
LABEL_18:
    ExFreePoolWithTag(v3, 0);
  }
}

Referenced by:

MiAllocatePartitionId