PnpUnregisterPlugPlayNotification

NTSTATUS __stdcall PnpUnregisterPlugPlayNotification(PVOID NotificationEntry, UINT8 AcquireEntryLock){
  _FAST_MUTEX *v2; 
  char v5; 
  _ETHREAD *CurrentThread; 
  PVOID *v8; 
  PVOID *v9; 
  PVOID *v10; 
  PVOID *v11; 
  PVOID **v12; 
  v2 = (_FAST_MUTEX *)*((_QWORD *)NotificationEntry + 8);
  v5 = 0;
  ExAcquireFastMutex(&PnpNotificationInProgressLock);
  if( BYTE2(NlsMbCodePageTag) )
  {
    ExAcquireFastMutex(&PnpDeferredRegistrationLock);
    v8 = (PVOID *)PnpDeferredRegistrationList;
    while( v8 != &PnpDeferredRegistrationList )
    {
      v9 = v8 + 2;
      v10 = v8;
      if( v8[2] == NotificationEntry )
      {
        v5 = 1;
        if( v2 )
          ExAcquireFastMutex(v2);
        v11 = (PVOID *)*v8;
        v8 = v11;
        if( v11[1] != v10 || (v12 = (PVOID **)v10[1], *v12 != v10) )
          __fastfail(3u);
        *v12 = v11;
        v11[1] = v12;
        PnpDereferenceNotify(*v9);
        if( v2 )
          KeReleaseGuardedMutex(v2);
        ExFreePoolWithTag(v10, 0x37706E50u);
      }
      else
      {
        v8 = (PVOID *)*v8;
      }
    }
    KeReleaseGuardedMutex(&PnpDeferredRegistrationLock);
  }
  KeReleaseGuardedMutex(&PnpNotificationInProgressLock);
  if( AcquireEntryLock )
  {
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    --*((_WORD *)CurrentThread + 242);
    ExAcquireResourceExclusiveLite(*((ERESOURCE **)NotificationEntry + 9), 1u);
  }
  else if( v2 )
  {
    ExAcquireFastMutex(v2);
  }
  if( !*((_BYTE *)NotificationEntry + 58) || v5 )
  {
    *((_BYTE *)NotificationEntry + 58) = 1;
    if( AcquireEntryLock )
    {
      ExReleaseResourceLite(*((PERESOURCE *)NotificationEntry + 9));
      KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
      if( v2 )
        ExAcquireFastMutex(v2);
    }
    PnpDereferenceNotify(NotificationEntry);
  }
  else if( AcquireEntryLock )
  {
    ExReleaseResourceLite(*((PERESOURCE *)NotificationEntry + 9));
    KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
    return 0;
  }
  if( v2 )
    KeReleaseGuardedMutex(v2);
  return 0;
}

Referenced by:

IoUnregisterPlugPlayNotification
IoUnregisterPlugPlayNotificationEx
PopCleanCoolingExtension
PopPolicyDeviceTargetChange
SmKmFileInfoCleanup