MiReplacePfnWithGapMapping

VOID __stdcall MiReplacePfnWithGapMapping(INT64 *a1, INT64 a2){
  unsigned int v3; 
  char v4; 
  INT64 bf_0; 
  int v6; 
  INT64 v7; 
  _MI_TB_FLUSH_LIST TbFlushList[48]; 

  v3 = a2;
  if( *(&stru_140C4DB30 + 507) == *(&stru_140C4DB30 + 508) )
  {
    memset(TbFlushList, 0i64, 0xB8u);
    v4 = MI_READ_PTE_LOCK_FREE((INT64)a1);
    *(_QWORD *)&TbFlushList[6] = 0i64;
    TbFlushList[2] = 20;
    if( v3 && v4 < 0 )
      MiInsertLargeTbFlushEntry(TbFlushList, v3, (INT64)a1);
    else
      MiInsertRecursiveTbFlushEntries(TbFlushList, v3, (INT64)a1);
    bf_0 = ZeroPte.u.Hard._bf_0;
    LOBYTE(v6) = MiPteInShadowRange((UINT64)a1);
    if( v6 && (KeGetCurrentThread()->ApcState.Process->Flags3 & 0x1000) != 0 && (ZeroPte.u.Long & 1) != 0 )
      bf_0 = ZeroPte.u.Long | 0x8000000000000000ui64;
    *a1 = bf_0;
    MiFlushTbList(TbFlushList);
  }
  else
  {
    LODWORD(v7) = MiMakeValidPte(
                    (_XSTATE_CONFIGURATION *)a1,
                    *((_QWORD *)&stru_140C4DB30 + (int)a2 + 507),
                    (_DWORD)a2 != 0 ? -1476395004 : 536870913);
    MiTransformValidPteInPlace(a1, (UINT64)a1, v7, v3);
  }
}

Referenced by:

MiPfnRangeIsZero