MiInsertViewOfPhysicalSection

VOID __fastcall MiInsertViewOfPhysicalSection(_EPROCESS *Process, _MMVAD *Vad){
  UINT64 v2; 
  UINT64 v4; 
  _MMPTE *PteBase; 
  unsigned int v7; 
  UINT64 v8; 
  _ETHREAD *CurrentThread; 
  UINT64 v10; 
  char *v11; 
  UINT8 v12; 
  _MMPTE *v13; 
  INT64 v14; 
  INT64 v15; 
  int v16; 
  INT64 v17; 
  INT64 v18; 
  CHAR v19; 
  char *v20; 
  _ETHREAD *v21; 
  v4 = v2;
  PteBase = MmGetPteBase();
  v7 = (*((_DWORD *)Vad + 12) >> 7) & 0x1F;
  v8 = (UINT64)PteBase
     + 8 * ((*((unsigned int *)Vad + 6) | ((unsigned __int64)*((unsigned __int8 *)Vad + 32) << 32)) & 0xFFFFFFFFFi64);
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v10 = 0i64;
  v20 = (char *)PteBase
      + 8 * ((*((unsigned int *)Vad + 7) | ((unsigned __int64)*((unsigned __int8 *)Vad + 33) << 32)) & 0xFFFFFFFFFi64);
  v21 = CurrentThread;
  v11 = (char *)Process + 1664;
  --*((_WORD *)CurrentThread + 243);
  ExAcquirePushLockExclusiveEx((UINT64)Vad + 40, 0i64);
  *((_BYTE *)CurrentThread + 1304) |= 0x80u;
  MiInsertVad((INT64)Vad, (INT64)Process, 1);
  v12 = MiLockWorkingSetShared((INT64)v11);
  if( v8 > (unsigned __int64)v20 )
    goto LABEL_9;
  v13 = MmGetPteBase();
  do
  {
    if( !v10 )
      goto LABEL_10;
    if( (v8 & 0xFFF) == 0 )
    {
      MiUnlockPageTableInternal((INT64)v11, v10);
LABEL_10:
      MiMakeSystemAddressValid(v8, 0i64, (*((_DWORD *)Vad + 12) >> 12) & 0x3F, v12, 0);
      v10 = (UINT64)v13 + ((v8 >> 9) & 0x7FFFFFFFF8i64);
    }
    MiInsertPhysicalPteMapping(v8, v4, v7);
    v8 += 8i64;
    if( (v8 & 0x78) == 0 )
    {
      if( MiWorkingSetIsContended((INT64)v11)
        || (MiPageTableLockIsContended((INT64)v11, v10, v14, v15, v17, v18, v19), v16)
        || KeShouldYieldProcessor() )
      {
        MiUnlockPageTableInternal((INT64)v11, v10);
        MiUnlockWorkingSetShared((INT64)v11, v12);
        v10 = 0i64;
        MiLockWorkingSetShared((INT64)v11);
      }
    }
    ++v4;
  }
  while( v8 <= (unsigned __int64)v20 );
  CurrentThread = v21;
  if( v10 )
    MiUnlockPageTableInternal((INT64)v11, v10);
LABEL_9:
  MiUnlockWorkingSetShared((INT64)v11, v12);
  MiUnlockVad((__int64)CurrentThread, (__int64)Vad);
}

Referenced by:

MiMapViewOfPhysicalSection