MmDeleteShadowMapping

VOID __stdcall MmDeleteShadowMapping(VOID *Va, UINT64 a2){
  _MMPTE *PteAddress; 
  _MMPTE *v5; 
  _ETHREAD *CurrentThread; 
  _MMPTE *v7; 
  _EPROCESS *Process; 
  PEPROCESS v9; 
  _KAPC_STATE ApcState; 
  _MI_TB_FLUSH_LIST TbFlushList[48]; 

  memset(&ApcState, 0, sizeof(ApcState));
  memset(TbFlushList, 0i64, 0xB8u);
  PteAddress = MiGetPteAddress(Va);
  v5 = MiGetPteAddress((char *)Va + a2 - 1);
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v7 = v5;
  Process = CurrentThread->Tcb.ApcState.Process;
  MiInitializeTbFlushList(TbFlushList, FlushKernel, 0x14ui64);
  MiInsertTbFlushEntry(TbFlushList, (VOID *)((unsigned __int64)Va & 0xFFFFFFFFFFFFF000ui64), a2 >> 12, 0i64);
  v9 = PsInitialSystemProcess;
  if( Process != PsInitialSystemProcess )
    KiStackAttachProcess(PsInitialSystemProcess, 0i64, &ApcState);
  --CurrentThread->Tcb.SpecialApcDisable;
  ExAcquirePushLockExclusiveEx(&Lock, 0i64);
  while( PteAddress <= v7 )
    MiReadWriteAnyLevelShadowPte((unsigned __int64)PteAddress++, 0, 1, ZeroPte.u.Long);
  MiFlushTbList(TbFlushList);
  if( (_InterlockedExchangeAdd64(&Lock._bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock(&Lock);
  KeAbPostRelease(&Lock);
  KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
  if( Process != v9 )
    KiUnstackDetachProcess(&ApcState, 0i64);
}

Referenced by:

KeAllocateProcessorProfileStructures
KiShadowProcessorAllocation
KiUnshadowProcessorAllocation