MiFinishLastForkPageTable

VOID __stdcall MiFinishLastForkPageTable(UINT64 PageFrameIndex, UINT64 a2){
  BOOL v3; 
  char *v4; 
  unsigned __int64 PteBase; 
  unsigned __int64 v6; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  __int64 v9; 
  UINT64 *v10; 
  v3 = 1;
  v4 = (char *)MmGetPfnDb() + 48 * a2;
  PteBase = (unsigned __int64)MmGetPteBase();
  v6 = *((_QWORD *)v4 + 1) | 0x8000000000000000ui64;
  v7 = (__int64)(((__int64)((v6 << 25) - (PteBase << 25)) >> 16 << 25) - (PteBase << 25)) >> 16;
  if( v7 >= PteBase )
    v3 = (unsigned __int64)MmGetPteLimit() < v7;
  v8 = (unsigned __int8)MiLockPageInline((INT64)v4);
  MiRemoveLockedPageChargeAndDecRef((_MMPFN *)v4);
  if( v3 )
  {
    if( (*((_QWORD *)v4 + 3) & 0x3FFFFFFFFFFFFFFFui64) <= 1 )
    {
      MiDecrementShareCount((UINT64)v4);
    }
    else
    {
      LODWORD(v9) = MiMapPageInHyperSpaceWorker(*((_QWORD *)v4 + 5) & 0xFFFFFFFFFi64, 0i64, 0x80000000ui64);
      v10 = (UINT64 *)(v9 + 8 * ((v6 >> 3) & 0x1FF));
      if( (MI_READ_PTE_LOCK_FREE((INT64)v10) & 1) == 0 )
        *v10 = MiMakeValidPte(v6, a2, 2147483652i64);
      MiUnmapPageInHyperSpaceWorker(v10, 0x11u, 0x80000000ui64);
    }
  }
  _InterlockedAnd64((volatile signed __int64 *)v4 + 3, 0x7FFFFFFFFFFFFFFFui64);
  __writecr8(v8);
}

Referenced by:

MiDoneWithThisPageGetAnother
MiFreeForkMaps