MiMapSinglePage

NTSTATUS __stdcall MiMapSinglePage(PVOID VirtualAddress, UINT64 PageFrameIndex, UINT64 Priority){
  char v3; 
  char v4; 
  int v5; 
  __int64 v7; 
  INT64 v8; 
  _QWORD *v9; 
  _MMPFN *v10; 
  UINT64 v11; 
  int ProtectionPfnCompatible; 
  UINT64 ValidPte; 
  v4 = v3;
  v5 = Priority;
  v7 = (__int64)VirtualAddress;
  if( VirtualAddress )
  {
    v9 = (_QWORD *)((char *)MmGetPteBase() + (((unsigned __int64)VirtualAddress >> 9) & 0x7FFFFFFFF8i64));
    if( MI_READ_PTE_LOCK_FREE((INT64)v9) )
    {
      *v9 = ZeroPte;
      KeFlushSingleTb(v7, 0i64, 1i64);
    }
LABEL_4:
    v10 = (_MMPFN *)((char *)MmGetPfnDb() + 48 * PageFrameIndex);
    v11 = (((v5 >> 31) & 0xFFFFFFFD) + 4) | 2;
    if( (v5 & 0x40000000) != 0 )
      v11 = ((v5 >> 31) & 0xFFFFFFFD) + 4;
    ProtectionPfnCompatible = MiMakeProtectionPfnCompatible(v11, v10);
    ValidPte = MiMakeValidPte((UINT64)v9, PageFrameIndex, ProtectionPfnCompatible | 0xA0000000);
    goto LABEL_7;
  }
  v8 = MiReservePtes((INT64)&qword_140C4EC80, 1ui64);
  v9 = (_QWORD *)v8;
  if( !v8 )
    return v8;
  v7 = ((v8 << 25) - ((_QWORD)MmGetPteBase() << 25)) >> 16;
  if( (v4 & 2) == 0 )
    goto LABEL_4;
  ValidPte = ZeroPte;
LABEL_7:
  *v9 = ValidPte;
  LODWORD(v8) = v7;
  return v8;
}

Referenced by:

MiFillCombinePage
MiInitializeForkMaps
MiUpdateForkMaps