PopQueueQuerySetIrp

VOID __stdcall PopQueueQuerySetIrp(IRP *Irp){
  __int64 v1; 
  char v2; 
  IRP *v3; 
  __int64 v4; 
  __int64 v5; 
  __int64 v6; 
  _DEVICE_OBJECT *v7; 
  int v8; 
  __int64 v9; 
  IRP **v10; 
  IRP *v11; 
  IRP *v12; 
  KIRQL v13; 
  _DEVICE_OBJECT *v14; 
  _QWORD *v15; 
  _QWORD *v16; 
  __int64 i; 
  __int64 v18; 
  IRP **v19; 
  struct _KLOCK_QUEUE_HANDLE LockHandle; 
  v1 = *((_QWORD *)Irp + 23);
  v2 = 0;
  memset(&LockHandle, 0, sizeof(LockHandle));
  v3 = Irp;
  v4 = *((_QWORD *)Irp + 9 * *((char *)Irp + 66) + 25);
  v5 = *(_QWORD *)(v4 + 24);
  if( v5 )
    v6 = *(_QWORD *)(*(_QWORD *)(v5 + 312) + 40i64);
  else
    v6 = 0i64;
  v7 = *(_DEVICE_OBJECT **)(v4 + 32);
  if( *(_BYTE *)(v4 + 184) == 2
    && *(_DWORD *)(v4 + 188) == 1
    && _InterlockedIncrement(&PopPendingSetPowerDeviceIrps) == 1 )
  {
    PopDeepSleepSetDisengageReason(2i64);
  }
  v8 = *(_DWORD *)(v4 + 188);
  v9 = 264i64;
  if( v8 != 1 )
    v9 = 280i64;
  v10 = (IRP **)(v6 + v9);
  if( v8 == 1 && *(_BYTE *)(v4 + 184) == 2 && *(_DWORD *)(v1 - 48) == 1 )
  {
    v13 = KeAcquireQueuedSpinLock(0xAui64);
    v14 = v7;
    if( v7 )
    {
      while( (*((_DWORD *)v14 + 12) & 0x4000) == 0 )
      {
        v14 = *(_DEVICE_OBJECT **)(*((_QWORD *)v14 + 39) + 48i64);
        if( !v14 )
          goto LABEL_23;
      }
      v2 = 1;
    }
LABEL_23:
    KeReleaseQueuedSpinLock(0xAui64, v13);
  }
  *((_QWORD *)v3 + 15) = 0i64;
  KeAcquireInStackQueuedSpinLock(&PopIrpLock, &LockHandle);
  if( v2 )
  {
    v15 = (_QWORD *)qword_140C239D8;
    v16 = (_QWORD *)((char *)v3 + 168);
    if( *(__int64 **)qword_140C239D8 != &PopInrushIrpList )
      goto LABEL_37;
    *v16 = &PopInrushIrpList;
    *((_QWORD *)v3 + 22) = v15;
    *v15 = v16;
    qword_140C239D8 = (__int64)v3 + 168;
  }
  v11 = v10[1];
  if( v11 )
  {
    for( i = *((_QWORD *)v11 + 15); i; i = *(_QWORD *)(i + 120) )
      v11 = (IRP *)i;
    *((_QWORD *)v11 + 15) = v3;
  }
  else
  {
    v10[1] = v3;
    if( !*v10 )
    {
      if( !v2 )
      {
LABEL_14:
        v10[1] = 0i64;
        *v10 = v3;
        goto LABEL_15;
      }
      if( !PopInrushIrp )
      {
        PopInrushIrp = (__int64)v3;
        v18 = *((_QWORD *)v3 + 21);
        v19 = (IRP **)*((_QWORD *)v3 + 22);
        if( *(IRP **)(v18 + 8) == (IRP *)((char *)v3 + 168) && *v19 == (IRP *)((char *)v3 + 168) )
        {
          *v19 = (IRP *)v18;
          *(_QWORD *)(v18 + 8) = v19;
          goto LABEL_14;
        }
LABEL_37:
        __fastfail(3u);
      }
    }
  }
  v3 = 0i64;
LABEL_15:
  KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
  __writecr8(LockHandle.OldIrql);
  if( v3 )
  {
    PopDiagTraceIrpStart(v12, v3);
    PopEnableIrpWatchdog(v3);
    IofCallDriver(v7, v3);
  }
}

Referenced by:

PopNotifyDevice
PopRequestPowerIrp