MiHugePageOperation

VOID __fastcall MiHugePageOperation(INT64 a1){
  int v1; 
  INT64 v2; 
  __int64 v3; 
  signed __int32 v4; 
  unsigned __int8 CurrentIrql; 
  unsigned __int64 UltraMapping; 
  UINT64 *v7; 
  unsigned __int64 v8; 
  __int64 v9; 
  INT64 v10; 
  __int128 v11; 
  INT64 result[23]; 
  int v13; 
  INT64 v14[16]; 
  v1 = a1;
  memset((INT64)result, 0i64);
  v11 = 0i64;
  memset((INT64)v14, 0i64);
  v2 = (unsigned __int64)(v1 & 0x3FFFF) << 18;
  LODWORD(v3) = MiSearchNumaNodeTable((PVOID)v2);
  MiInitializePageColorBase(
    *((_QWORD *)KeGetCurrentThread() + 23) + 1664i64,
    (unsigned int)(*(_DWORD *)(v3 + 8) + 1),
    (INT64)&v11);
  v4 = _InterlockedExchangeAdd((volatile signed __int32 *)v11, 1u);
  v10 = 0i64;
  CurrentIrql = 17;
  if( (unsigned int)MiCreateUltraThreadContext((INT64)v14, DWORD2(v11) & (unsigned int)v4 | HIDWORD(v11), 1i64) )
  {
    UltraMapping = MiGetUltraMapping((unsigned __int64 *)v14, 0, 0x40000i64, 0);
    v7 = (UINT64 *)((char *)MmGetPdpteBase() + ((UltraMapping >> 27) & 0x1FFFF8));
  }
  else
  {
    v7 = 0i64;
    MmMapIoSpaceEx((_LARGE_INTEGER)(v2 << 12), 0x40000000ui64, 4ui64);
    UltraMapping = v8;
    if( v8 )
      goto LABEL_7;
    CurrentIrql = KeGetCurrentIrql();
    __writecr8(2ui64);
    v10 = *((_QWORD *)KeGetCurrentPrcb() + 4095);
    UltraMapping = MiGetUltraMapping((unsigned __int64 *)(v10 + 12352), 0, 0x40000i64, 0);
    v7 = (UINT64 *)((char *)MmGetPdpteBase() + ((UltraMapping >> 27) & 0x1FFFF8));
    *(_QWORD *)(v10 + 12344) = v7;
  }
  if( v7 )
    *v7 = MiMakeValidPte((UINT64)v7, v2, 2214592516i64);
LABEL_7:
  if( KeGetCurrentIrql() >= 2u )
  {
    KeZeroPages((PVOID)UltraMapping, 0x40000000ui64);
  }
  else
  {
    LODWORD(v9) = MiSearchNumaNodeTable((PVOID)v2);
    MiInitializeDpcGang((INT64)result, *(unsigned int *)(v9 + 8), 1);
    v13 |= 8u;
    result[0] = v2;
    result[1] = 0x40000i64;
    result[20] = UltraMapping;
    MiStartDpcGang((UINT64 *)result);
    MiEndDpcGang((INT64)result);
  }
  if( v7 )
  {
    *v7 = ZeroPte;
    if( CurrentIrql == 17 )
    {
      MiDeleteUltraThreadContext((INT64)v14);
    }
    else
    {
      *(_QWORD *)(v10 + 12344) = 0i64;
      __writecr8(CurrentIrql);
    }
  }
  else
  {
    MmUnmapIoSpace((PVOID)UltraMapping, 0x40000000ui64);
  }
}

Referenced by:

MiGetHugeRangeFromNode
MiHotAddHugeRange