MiReleaseVadEventBlocks

void __fastcall MiReleaseVadEventBlocks(__int64 a1, int a2){
  int v3; 
  _EPROCESS *v4; 
  __int64 *VadWakeList; 
  int v6; 
  __int64 *v7; 
  _QWORD *v8; 
  INT64 v9; 
  INT64 AweInfoPartition; 
  UINT64 v11; 
  int v12; 
  v3 = 0;
  v4 = (_EPROCESS *)*((_QWORD *)KeGetCurrentThread() + 23);
  VadWakeList = MiGetVadWakeList(a1, -34);
  if( VadWakeList )
  {
    do
    {
      v6 = *((_DWORD *)VadWakeList + 16);
      v7 = (__int64 *)*VadWakeList;
      if( (v6 & 0x10) != 0 )
      {
        v3 = 1;
        MiFreeLargePageView(v4, (_MMVAD_SHORT *)a1, (UINT64)VadWakeList);
        v6 = *((_DWORD *)VadWakeList + 16);
      }
      if( (v6 & 8) != 0 )
      {
        MiFreeRotateVadEvent((INT64)VadWakeList);
        v6 = *((_DWORD *)VadWakeList + 16);
      }
      if( (v6 & 4) != 0 )
      {
        MiFreeVadEventBitmapCharges((ULONG_PTR)v4, (__int64)VadWakeList);
        v6 = *((_DWORD *)VadWakeList + 16);
      }
      if( (v6 & 0x40) != 0 )
      {
        MiFreeVadEventBitmapCharges((ULONG_PTR)v4, (__int64)VadWakeList);
        v6 = *((_DWORD *)VadWakeList + 16);
      }
      if( (v6 & 0x100) != 0 )
      {
        v8 = (_QWORD *)VadWakeList[4];
        v9 = VadWakeList[5];
        if( (*v8 != -2i64 || v8[1] != -2i64 || v8[2] != -2i64)
          && MiComputeAweCharges((INT64)v8, (INT64)(VadWakeList + 1)) )
        {
          AweInfoPartition = MiGetAweInfoPartition(v9);
          MiReturnResident(AweInfoPartition, v11);
        }
        if( (*(_DWORD *)v9 & 1) == 0 )
          MiDereferenceControlArea(*(_QWORD *)(v9 + 32));
      }
      if( (*((_DWORD *)VadWakeList + 16) & 0x80u) != 0 )
        MiFreePlaceholderVadEvent((INT64)VadWakeList);
      ExFreePoolWithTag(VadWakeList, 0);
      VadWakeList = v7;
    }
    while( v7 );
  }
  v12 = *(_DWORD *)(a1 + 48);
  if( (v12 & 0x100000) != 0 && ((v12 & 0xC0000u) >= 0x80000 || (v12 & 0x400000) != 0) && (v12 & 0x70) == 0 && !v3 )
    MiFreeLargePageView(v4, (_MMVAD_SHORT *)a1, 0i64);
  MiFreePhysicalView((__int64)v4, a1);
}

Referenced by:

MiMapViewOfImageSection
MiRemoveVadCharges
MiReserveUserMemory