MiSetVadBits

VOID __stdcall MiSetVadBits(_MMVAD_SHORT *Vad){
  unsigned int v1; 
  unsigned __int64 v2; 
  unsigned __int64 v3; 
  _EPROCESS *Process; 
  __int64 p_NextPteToAge; 
  __int64 v6; 
  _RTL_BITMAP_EX *v7; 
  unsigned __int64 v8; 
  unsigned __int64 v9; 
  int v10; 
  __int64 v11; 
  unsigned __int64 v12; 

  v1 = 0;
  v2 = ((unsigned __int64)Vad->StartingVpn >> 4) | ((unsigned __int64)Vad->StartingVpnHigh << 28);
  v3 = ((unsigned __int64)Vad->EndingVpn >> 4) | ((unsigned __int64)Vad->EndingVpnHigh << 28);
  Process = KeGetCurrentThread()->ApcState.Process;
  p_NextPteToAge = (__int64)&Process->Vm.Instance.VmWorkingSetList[1].NextPteToAge;
  if( *(_QWORD *)&Process->Vm.Instance.VmWorkingSetList[6].LastAccessClearingRemainder )
  {
    v6 = 0i64;
    do
    {
      v7 = (_RTL_BITMAP_EX *)(p_NextPteToAge + 72 * v6);
      v8 = 8 * ((__int64)v7->Buffer - *(&stru_140C4DB30 + 174));
      if( v3 >= v8 )
      {
        v9 = v8 + v7->SizeOfBitMap;
        if( v2 < v9 )
        {
          v10 = 0;
          v11 = v2;
          if( v2 < v8 )
          {
            v11 = 8 * ((__int64)v7->Buffer - *(&stru_140C4DB30 + 174));
            v10 = 1;
          }
          if( v3 >= v9 )
            v10 = 1;
          v12 = v9 - 1;
          if( v3 < v9 )
            v12 = v3;
          RtlSetBitsEx(v7, v11 - v8, v12 - v11 + 1);
          if( !v10 )
            break;
        }
      }
      v6 = ++v1;
    }
    while( (unsigned __int64)v1 < *(_QWORD *)(p_NextPteToAge + 216) );
  }
}

Referenced by:

MiInsertVadCharges
MiUpdateVadBits