AlpcpFlushMessagesByRequestor

VOID __fastcall AlpcpFlushMessagesByRequestor(
        _ALPC_PORT *RequestorPort,
        _ALPC_PORT *QueuePort,
        _LIST_ENTRY *Queue,
        UINT64 QueueType){
  unsigned int v5; 
  __int64 v8; 
  _LIST_ENTRY *i; 
  volatile INT64 *v10; 
  volatile INT64 *v11; 
  __int64 v12; 
  v5 = QueueType;
  if( (unsigned int)QueueType <= 2 )
  {
    v8 = 136i64;
  }
  else
  {
    v8 = 176i64;
    if( (_DWORD)QueueType != 3 )
      v8 = 200i64;
  }
  ExAcquirePushLockExclusiveEx((UINT64)QueuePort + v8, 0i64);
LABEL_5:
  for( i = Queue->Flink; i != Queue; i = i->Flink )
  {
    if( (_ALPC_PORT *)i[1].Blink == RequestorPort || ((__int64)i[2].Blink & 0x8000) != 0 )
    {
      AlpcpReferenceBlob(i);
      if( v5 > 2 )
      {
        if( v5 == 3 )
          v11 = (volatile INT64 *)((char *)QueuePort + 176);
        else
          v11 = (volatile INT64 *)((char *)QueuePort + 200);
      }
      else
      {
        v11 = (volatile INT64 *)((char *)QueuePort + 136);
      }
      if( (_InterlockedExchangeAdd64(v11, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
        ExfTryToWakePushLock(v11);
      KeAbPostRelease((PVOID)v11);
      AlpcpLockForCachedReferenceBlob(i);
      --WORD1(i[-2].Flink);
      if( (_ALPC_PORT *)i[1].Blink == RequestorPort )
        AlpcpCancelMessage(QueuePort, (_KALPC_MESSAGE *)i, 0x10000ui64);
      else
        AlpcpUnlockMessage((ULONG_PTR)i);
      if( v5 > 2 )
      {
        v12 = 176i64;
        if( v5 != 3 )
          v12 = 200i64;
      }
      else
      {
        v12 = 136i64;
      }
      ExAcquirePushLockExclusiveEx((UINT64)QueuePort + v12, 0i64);
      goto LABEL_5;
    }
  }
  if( v5 > 2 )
  {
    if( v5 == 3 )
      v10 = (volatile INT64 *)((char *)QueuePort + 176);
    else
      v10 = (volatile INT64 *)((char *)QueuePort + 200);
  }
  else
  {
    v10 = (volatile INT64 *)((char *)QueuePort + 136);
  }
  if( (_InterlockedExchangeAdd64(v10, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock(v10);
  KeAbPostRelease((PVOID)v10);
}

Referenced by:

AlpcpFlushMessagesPort