PiQueueDeviceRequest

INT64 __fastcall PiQueueDeviceRequest(INT64 a1, INT64 a2, INT64 a3, INT64 a4, INT64 a5){
  int v5; 
  _PNP_DEVICE_ACTION_REQUEST v6; 
  _DEVICE_OBJECT *v7; 
  _DEVICE_OBJECT *v8; 
  int v9; 
  struct _KEVENT Event; 
  v5 = a4;
  v6 = (int)a2;
  memset(&Event, 0, sizeof(Event));
  if( a5 )
    *(_DWORD *)a5 = 0;
  v7 = (_DEVICE_OBJECT *)PnpDeviceObjectFromDeviceInstanceWithTag(a1, 0x43706E50ui64);
  v8 = v7;
  if( v7 )
  {
    if( *(_QWORD *)(*((_QWORD *)v7 + 39) + 40i64) )
    {
      if( v5 )
        KeInitializeEvent(&Event, NotificationEvent, 0);
      v9 = PnpRequestDeviceAction(
             v8,
             v6,
             0,
             0i64,
             (_KEVENT *)((unsigned __int64)&Event & -(__int64)(v5 != 0)),
             (int *)(a5 & -(__int64)(v5 != 0)));
      if( v9 >= 0 )
      {
        if( v5 )
        {
          v9 = KeWaitForSingleObject(&Event, Executive, 0, 1u, 0i64);
          if( v9 == 257 )
          {
            if( (unsigned int)PnpRemoveDeviceActionRequestFromQueue(0i64) )
            {
              v9 = -1073741536;
            }
            else
            {
              PnpCancelDeviceActionRequest(0i64);
              v9 = KeWaitForSingleObject(&Event, Executive, 0, 0, 0i64);
            }
          }
        }
      }
    }
    else
    {
      v9 = -1073741810;
    }
    ObfDereferenceObjectWithTag(v8, 0x43706E50ui64);
  }
  else
  {
    return(unsigned int)-1073741810;
  }
  return(unsigned int)v9;
}

Referenced by:

PiCMDeleteDevice
PiCMDeviceAction
PiControlStartDevice