MiInsertChildVads

NTSTATUS __stdcall MiInsertChildVads(ULONG_PTR CurrentProcess, _MMVAD_SHORT *Vad){
  __int64 v3; 
  int v4; 
  _MMVAD_SHORT *v5; 
  union {unsigned int LongFlags;_MMVAD_FLAGS VadFlags;_MM_PRIVATE_VAD_FLAGS PrivateVadFlags;_MM_GRAPHICS_VAD_FLAGS GraphicsVadFlags;_MM_SHARED_VAD_FLAGS SharedVadFlags;volatile unsigned int VolatileVadLong;} *p_u; 
  int v7; 
  NTSTATUS inserted; 
  unsigned int LongFlags; 
  __int64 v10; 
  unsigned int v11; 
  _MMVAD_SHORT *NextVad; 
  _ETHREAD *CurrentThread; 
  __int64 v14; 
  bool v15; 
  _KAPC_STATE ApcState; 

  v3 = *(_QWORD *)&CurrentProcess;
  v4 = 0;
  memset(&ApcState, 0, sizeof(ApcState));
  KiStackAttachProcess(*(PVOID *)&CurrentProcess, 0i64, &ApcState);
  v5 = Vad;
  if( Vad )
  {
    while( 1 )
    {
      p_u = &Vad->u;
      if( (Vad->u.LongFlags & 0x100000) == 0 )
      {
        MiUpControlAreaRefs(Vad);
        v4 = v7;
        if( v7 < 0 )
          break;
      }
      v4 = MiCommitPageTableRangesForVad(Vad);
      if( v4 < 0 )
      {
        v15 = (p_u->LongFlags & 0x100000) == 0;
LABEL_22:
        if( v15 )
          MiUpControlAreaRefs(Vad);
        break;
      }
      inserted = MiInsertVadCharges(Vad, v3);
      LongFlags = p_u->LongFlags;
      v4 = inserted;
      if( inserted < 0 )
      {
        v15 = (LongFlags & 0x100000) == 0;
        goto LABEL_22;
      }
      Vad = Vad->NextVad;
      if( (LongFlags & 0xC0000) == 0x40000 )
      {
        v10 = *(_QWORD *)(v3 + 1680);
        if( (LongFlags & 0x100000) != 0 )
          ++*(_QWORD *)(v10 + 424);
        else
          ++*(_QWORD *)(v10 + 432);
      }
      v11 = p_u->LongFlags;
      if( (p_u->LongFlags & 0x100000) == 0 )
      {
        NextVad = v5[2].NextVad;
        if( NextVad )
        {
          ObfReferenceObject(NextVad);
          v11 = p_u->LongFlags;
        }
        if( (v11 & 0x100000) == 0 && (__int64)v5[1].EventList < 0 )
        {
          CurrentThread = (_ETHREAD *)KeGetCurrentThread();
          --CurrentThread->Tcb.SpecialApcDisable;
          ExAcquirePushLockExclusiveEx(&stru_140C4C6D0, 0i64);
          v14 = *(_QWORD *)(**(_QWORD **)v5[1].ExtraCreateInfo + 32i64);
          ++*(_DWORD *)(v14 + 8);
          if( (_InterlockedExchangeAdd64(&stru_140C4C6D0._bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
            ExfTryToWakePushLock(&stru_140C4C6D0);
          KeAbPostRelease(&stru_140C4C6D0);
          KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
        }
      }
      v5->VadNode.ParentValue = -2i64;
      MiGetWsAndInsertVad(v5);
      v5 = Vad;
      if( !Vad )
        goto LABEL_25;
    }
    MiDeletePartialCloneVads(Vad);
  }
LABEL_25:
  KiUnstackDetachProcess(&ApcState, 0i64);
  return v4;
}

Referenced by:

MiAllocateChildVads