MiUnlockAndDereferenceVadShared

NTSTATUS __stdcall MiUnlockAndDereferenceVadShared(PVOID P){
  signed __int32 v2; 
  BOOL v3; 
  _ETHREAD *CurrentThread; 
  _QWORD *v5; 
  v2 = _InterlockedDecrement((volatile signed __int32 *)P + 9);
  if( v2 == -1 )
    __fastfail(0xEu);
  v3 = !v2 && (*((_DWORD *)P + 12) & 4) != 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  *((_BYTE *)CurrentThread + 1305) &= ~0x40u;
  if( _InterlockedCompareExchange64((volatile signed __int64 *)P + 5, 0i64, 17i64) != 17 )
    ExfReleasePushLockShared((INT64 *)P + 5);
  KeAbPostRelease((char *)P + 40);
  if( (*((_WORD *)CurrentThread + 243))++ == 0xFFFF )
  {
    v5 = (_QWORD *)((char *)CurrentThread + 152);
    if( (_QWORD *)*v5 != v5 )
      LODWORD(v5) = KiCheckForKernelApcDelivery();
  }
  if( v3 )
    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