MiMakeZeroedPageTablesEx

INT64 __fastcall MiMakeZeroedPageTablesEx(INT64 a1, INT64 a2, UINT64 a3, INT64 a4, INT64 a5){
  unsigned int v5; 
  int v8; 
  int v9; 
  char v10; 
  unsigned int v11; 
  __int64 v12; 
  int v13; 
  INT64 v14; 
  unsigned __int64 v15; 
  CHAR *AnyMultiplexedVm; 
  unsigned int v17; 
  unsigned int v18; 
  INT64 v19; 
  __int64 v20; 
  INT64 v21; 
  _MMPFN *PfnDb; 
  unsigned int v24; 
  unsigned int v25; 
  unsigned int v26; 
  unsigned int v27; 
  unsigned int v28; 
  INT64 *SharedVm; 
  INT64 v30[7]; 
  int v31; 
  unsigned int v32; 
  unsigned int v33; 
  int v34; 
  int a6; 
  __int16 v36; 
  __int64 v37; 
  __int64 v38; 
  __int64 v39; 
  int v40; 
  INT64 v41[2]; 
  __int64 v42; 
  __int16 result; 
  char result_2; 
  UINT8 result_6; 
  CHAR *v46; 
  unsigned __int64 v47; 
  INT64 v48; 
  INT64(__fastcall *v49)(INT64, UINT64, INT64); 
  INT64(__fastcall *v50)(INT64); 
  INT64 *v51; 
  v5 = a3;
  v8 = a4;
  memset((INT64)&result, 0i64);
  memset((INT64)v30, 0i64);
  if( (v5 & 4) != 0 )
  {
    v34 = 3;
    v9 = 3;
    v10 = 3;
  }
  else if( (v5 & 2) != 0 )
  {
    v34 = 2;
    v9 = 2;
    v10 = 2;
  }
  else
  {
    v9 = 0;
    v10 = 0;
    if( (v5 & 0x20) == 0 )
    {
      v34 = 1;
      v9 = 1;
      v10 = 1;
    }
  }
  v11 = v5 & 0xFFFFFF7F;
  if( !v9 )
    v11 = v5;
  result_2 = 4 * v10;
  v12 = (_QWORD)MmGetPteBase() << 25;
  v13 = 0;
  v14 = (((a2 << 25) - v12) >> 16) + 4095;
  v15 = ((a1 << 25) - v12) >> 16;
  v31 = v8;
  AnyMultiplexedVm = MiGetAnyMultiplexedVm(5i64);
  if( v8 <= 9 )
  {
    if( v8 == 9 )
    {
LABEL_9:
      v19 = v18;
LABEL_10:
      AnyMultiplexedVm = MiGetAnyMultiplexedVm(v19);
      goto LABEL_11;
    }
    if( v8 != v17 )
    {
      v24 = v8 - v17 - v17;
      if( !v24 )
      {
        v13 = v17;
        AnyMultiplexedVm = (CHAR *)(*((_QWORD *)KeGetCurrentThread() + 23) + 1664i64);
        goto LABEL_11;
      }
      v25 = v24 - v17;
      if( v25 )
      {
        v26 = v25 - v18;
        if( !v26 )
        {
          v19 = 2i64;
          goto LABEL_10;
        }
        if( v26 == 2 )
        {
          v19 = 0i64;
          goto LABEL_10;
        }
        goto LABEL_11;
      }
LABEL_28:
      v19 = v17;
      goto LABEL_10;
    }
LABEL_31:
    v13 = 2;
    AnyMultiplexedVm = (CHAR *)(*(_QWORD *)(*((_QWORD *)KeGetCurrentThread() + 23) + 1368i64) + 256i64);
    goto LABEL_11;
  }
  if( v8 == 11 )
  {
    if( (unsigned int)MiGetSystemRegionType(v15) != 1 )
      goto LABEL_11;
    goto LABEL_31;
  }
  v27 = v8 - 11 - v17;
  if( !v27 )
    goto LABEL_28;
  v28 = v27 - v17;
  if( !v28 )
    goto LABEL_9;
  if( v28 == v17 )
  {
    v19 = 4i64;
    goto LABEL_10;
  }
LABEL_11:
  v20 = -1i64;
  v30[4] = *(_QWORD *)(qword_140C4E388 + 8i64 * *((unsigned __int16 *)AnyMultiplexedVm + 87));
  v21 = (unsigned int)a5;
  v32 = a5;
  v33 = v11;
  v42 = -1i64;
  if( (v11 & 0x40) != 0 )
  {
    MiSetLeafFillToUninitializedWsle((INT64)v30);
    v21 = v32;
  }
  else
  {
    PfnDb = MmGetPfnDb();
    if( v15 >= (unsigned __int64)PfnDb )
    {
      if( v15 < (unsigned __int64)PfnDb + 0x30000000000i64 )
        v20 = v11 & 0x40;
      v42 = v20;
    }
  }
  MiInitializeColorBase(v15, v21, (INT64)v41);
  if( (v11 & 0x80u) == 0 || (unsigned int)MiGetLargePagesForSystemMapping((INT64)v30, v15) || (v11 & 0x100) == 0 )
  {
    a6 = v13;
    result = 18439;
    v47 = v15;
    v49 = MiCreateSystemPageTable;
    v48 = v14;
    v50 = MiCreateSystemPageTableTail;
    v51 = v30;
    v37 = 20i64;
    v36 = 0;
    v38 = 0i64;
    v39 = 0i64;
    v46 = AnyMultiplexedVm;
    result_6 = MiLockWorkingSetShared((INT64)AnyMultiplexedVm);
    MiWalkPageTables((INT64)&result);
    MiUnlockWorkingSetShared((INT64)AnyMultiplexedVm, result_6);
    if( (v11 & 0x40) != 0 && v31 != 2 )
    {
      SharedVm = MiGetSharedVm((INT64)AnyMultiplexedVm);
      _InterlockedExchangeAdd64(SharedVm + 6, v30[6]);
    }
    MiCleanupPageTablePages((INT64)v30);
    if( v40 >= 0 )
      return 1i64;
    if( (v11 & 0x200) == 0 )
      MiDeleteSystemPageTables((INT64)AnyMultiplexedVm, (unsigned int)v8, v15, v14, 0, (INT64)&a6);
  }
  else
  {
    MiCleanupPageTablePages((INT64)v30);
  }
  return 0i64;
}

Referenced by:

MiCommitPoolMemory
MiCreateTopLevelUltraMappings
MiExpandPtes
MiExpandSystemCache
MiGetPageTablesForLargeMap
MiInitializeKernelCfg
MiMakeZeroedPageTables
MiMapBBTMemory
MiMapNewPfns
MiSplitBitmapPages