MiCreateLargePageVad

NTSTATUS __stdcall MiCreateLargePageVad(_EPROCESS *TargetProcess, _MMVAD_SHORT *Vad){
  void *v2; 
  int v3; 
  __int64 v4; 
  void *v5; 
  _ETHREAD *CurrentThread; 
  _EPROCESS *v9; 
  __int64 v10; 
  __int64 v12; 
  unsigned __int64 v13; 
  int v14; 
  NTSTATUS v15; 
  v3 = 1;
  v4 = 1i64;
  v5 = v2;
  if( (*((_DWORD *)Vad + 12) & 0x100000) != 0 )
    v4 = -(__int64)(v2 != 0i64) & 1;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v9 = (_EPROCESS *)*((_QWORD *)CurrentThread + 23);
  if( v4 )
  {
    LODWORD(v10) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
    v4 = v10;
    if( !v10 )
      return -1073741670;
  }
  v12 = *((unsigned int *)Vad + 13);
  LODWORD(v12) = v12 & 0x7FFFFFFF;
  v13 = v12 | ((unsigned __int64)*((unsigned __int8 *)Vad + 34) << 31);
  if( !v13 )
  {
    if( !v5 )
      goto LABEL_24;
LABEL_23:
    ObfReferenceObjectWithTag(v5, 0x746C6644u);
    *(_QWORD *)(v4 + 24) = v5;
    goto LABEL_24;
  }
  if( !(unsigned int)MiChargeProcessPhysicalPages(
                        (__int64)TargetProcess,
                        v12 | ((unsigned __int64)*((unsigned __int8 *)Vad + 34) << 31)) )
  {
    if( v4 )
      ExFreePoolWithTag((PVOID)v4, 0);
    return -1073741523;
  }
  if( v5 )
    goto LABEL_23;
  if( v14 || v9 != TargetProcess )
    v3 = 0;
  else
    LOCK_ADDRESS_SPACE_SHARED(CurrentThread, TargetProcess);
  v15 = MiChargeFullProcessCommitment((ULONG_PTR)TargetProcess, v13);
  if( v3 )
    UNLOCK_ADDRESS_SPACE_SHARED((__int64)CurrentThread, (__int64)TargetProcess);
  if( v15 < 0 )
  {
    _InterlockedExchangeAdd64((volatile signed __int64 *)TargetProcess + 254, -(__int64)v13);
    if( v4 )
      ExFreePoolWithTag((PVOID)v4, 0);
    return v15;
  }
LABEL_24:
  if( v4 )
  {
    *(_DWORD *)(v4 + 64) = 16;
    MiInsertVadEvent(Vad, (_MI_VAD_EVENT_BLOCK *)v4, 0i64);
  }
  return 0;
}

Referenced by:

MiAllocateChildVads
MiMapViewOfImageSection
MiReserveUserMemory