KiWakeOtherQueueWaiters

VOID __stdcall KiWakeOtherQueueWaiters(_KPRCB *Prcb, _KQUEUE *Queue){
  _KQUEUE *Blink; 
  _KWAIT_BLOCK *v5; 
  unsigned __int8 WaitType; 
  _LIST_ENTRY *v7; 
  struct _KPRCB *CurrentPrcb; 
  INT64 WaitKey; 
  _ETHREAD *Thread; 
  _LIST_ENTRY *Flink; 
  __int64 v12; 
  UINT64 SpinCount; 
  Blink = (_KQUEUE *)Queue->Header.WaitListHead.Blink;
  do
  {
    v5 = (_KWAIT_BLOCK *)Blink;
    Blink = (_KQUEUE *)Blink->Header.WaitListHead.Flink;
    WaitType = v5->WaitType;
    if( WaitType == 2 )
    {
      Flink = v5->WaitListEntry.Flink;
      if( (_KWAIT_BLOCK *)v5->WaitListEntry.Flink->Blink != v5 || *(_KWAIT_BLOCK **)&Blink->Header.Lock != v5 )
        goto LABEL_19;
      *(_QWORD *)&Blink->Header.Lock = Flink;
      Flink->Blink = (_LIST_ENTRY *)Blink;
      v5->BlockState = 5;
      KiInsertQueueInternal(v5->NotificationQueue, &v5->WaitListEntry);
    }
    else
    {
      if( WaitType != 1 )
        return;
      v7 = v5->WaitListEntry.Flink;
      if( (_KWAIT_BLOCK *)v5->WaitListEntry.Flink->Blink != v5 || *(_KWAIT_BLOCK **)&Blink->Header.Lock != v5 )
LABEL_19:
        __fastfail(3u);
      *(_QWORD *)&Blink->Header.Lock = v7;
      v7->Blink = (_LIST_ENTRY *)Blink;
      CurrentPrcb = KeGetCurrentPrcb();
      WaitKey = v5->WaitKey;
      Thread = v5->Thread;
      LODWORD(SpinCount) = 0;
      while( _interlockedbittestandset64((volatile signed __int32 *)Thread + 16, 0i64) )
      {
        do
          KeYieldProcessorEx(&SpinCount);
        while( *((_QWORD *)Thread + 8) );
        v12 = *((_QWORD *)CurrentPrcb + 4247);
        if( v12 && *((_BYTE *)CurrentPrcb + 32) <= 1u )
          ++*(_DWORD *)(v12 + 24);
      }
      if( *((_BYTE *)Thread + 388) == 5 )
        KiSignalThread(Prcb, Thread, WaitKey, v5);
      *((_QWORD *)Thread + 8) = 0i64;
      ++v5->BlockState;
    }
  }
  while( Blink != (_KQUEUE *)&Queue->Header.WaitListHead );
}

Referenced by:

CcUnpinFileDataEx
ExpReleaseResourceExclusiveForThreadLite
ExpReleaseResourceSharedForThreadLite
IoSetIoCompletionEx
IoSetIoCompletionEx2
IopfCompleteRequest
KeDeleteMutant
KeInsertHeadQueue
KeInsertQueue
KeInsertQueueEx
KePulseEvent
KeRegisterObjectNotification
KeReleaseMutant
KeReleaseSemaphore
KeReleaseSemaphoreEx
KeRundownQueueCommon
KeSetEvent
KeSetEventBoostPriorityEx
KeSetProcess
KeSignalGate
KeTerminateThread
KeWakeWaitChain
KiExpireTimer2
KiInsertQueueInternal
KiResumeThread
KiRundownMutants
KiTimerWaitTest
NtAssociateWaitCompletionPacket
NtReleaseWorkerFactoryWorker
NtWaitForWorkViaWorkerFactory