MiUnlockAndDereferenceVadShared

NTSTATUS __stdcall MiUnlockAndDereferenceVadShared(PVOID P){
  signed __int32 v2; 
  _BOOL4 v3; 
  _ETHREAD *CurrentThread; 
  $F25F8C4BA33AF922A5F1AF68CD89DDDF *v5; 

  v2 = _InterlockedDecrement((volatile signed __int32 *)P + 9);
  if( v2 == -1 )
    __fastfail(0xEu);
  v3 = !v2 && (*((_DWORD *)P + 12) & 4) != 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  CurrentThread->_bf_1 &= ~0x40u;
  if( _InterlockedCompareExchange64((volatile signed __int64 *)P + 5, 0i64, 17i64) != 17 )
    ExfReleasePushLockShared((_EX_PUSH_LOCK *)P + 5);
  KeAbPostRelease((char *)P + 40);
  if( CurrentThread->Tcb.SpecialApcDisable++ == -1 )
  {
    v5 = &CurrentThread->Tcb.152;
    if( ($F25F8C4BA33AF922A5F1AF68CD89DDDF *)v5->ApcState.ApcListHead[0].Flink != v5 )
      KiCheckForKernelApcDelivery();
  }
  if( v3 )
    LODWORD(v5) = (unsigned int)ExFreePoolWithTag(P, 0);
  return(int)v5;
}

Referenced by:

MiCheckShadowStackOverflow
MiCleanCfg
MiFinishPlaceholderVadReplacement
MiGetWorkingSetInfoList
MiHandleEnclaveFault
MiHotPatchProcess
MiObtainReferencedVadEx
MiPrefetchPreallocatePages
MiProcessVaContiguityInformation
MiQueryMemoryPhysicalContiguity
MiSetImageHotPatchAllowed
MiWaitForRotateToComplete
MmFlushVirtualMemory
MmGetEnclaveModuleList
MmGetFileNameForAddress
MmQueryVirtualMemory
NtAreMappedFilesTheSame