MiExpandVadBitMap

NTSTATUS __stdcall MiExpandVadBitMap(_MI_VAD_ALLOCATION_CELL *VadSearchType, UINT64 BitsNeeded){
  unsigned __int64 v4; 
  _MMWSL_INSTANCE *VmWorkingSetList; 
  __int64 v6; 
  __int64 v7; 
  char *v8; 
  void *v9; 
  UINT64 v10; 
  UINT64 v11; 
  unsigned __int64 v12; 
  __int64 v13; 
  UINT64 v15; 

  v15 = 0i64;
  v4 = *(_QWORD *)VadSearchType;
  VmWorkingSetList = KeGetCurrentThread()->ApcState.Process->Vm.Instance.VmWorkingSetList;
  v6 = *((_QWORD *)VadSearchType + 1);
  v7 = *(_QWORD *)VadSearchType + 8 * (v6 - *(&stru_140C4DB30 + 174));
  if( BitsNeeded > *((_QWORD *)VadSearchType + 5) - v7 + 1 )
    return MiExpandVadBitMapDown((UINT64)VadSearchType);
  v8 = (char *)((v4 + 8 * (v6 - *(&stru_140C4DB30 + 174))) << 16);
  v9 = (void *)(v6 + (v4 >> 3));
  if( MiMakeHyperRangeAccessible(v9, (PVOID)(v6 + ((v4 + BitsNeeded - 1) >> 3)), &v15) < 0 )
    return 0;
  VmWorkingSetList[6].LockedEntries += v15;
  v10 = ((8 * ((BitsNeeded >> 6) + ((BitsNeeded & 0x3F) != 0))) >> 12)
      + (((8 * ((BitsNeeded >> 6) + ((BitsNeeded & 0x3F) != 0))) & 0xFFF) != 0);
  v11 = (v10 << 15) + *(_QWORD *)VadSearchType;
  v12 = (v10 << 15) + v7;
  *(_QWORD *)VadSearchType = v11;
  v13 = *((_QWORD *)VadSearchType + 5);
  if( v12 > v13 + 1 )
    *(_QWORD *)VadSearchType = v13 - v12 + v11 + 1;
  if( v9 == (void *)*(&stru_140C4DB30 + 174) )
  {
    **((_QWORD **)VadSearchType + 1) |= 1ui64;
    if( v4 )
      *((_QWORD *)VadSearchType + 2) = 1i64;
  }
  MiUpdateVadBits(v8, &v8[0x80000000 * v10]);
  return 1;
}

Referenced by:

MiFindEmptyAddressRange
MiInitializeVadBitMap