PnpQueryID

__int64 __fastcall PnpQueryID(_DEVICE_NODE *DeviceNode, int a2, UINT64 *a3, _DWORD *a4){
  _DEVICE_OBJECT *PhysicalDeviceObject; 
  int ID; 
  unsigned int v10; 
  unsigned int v11; 
  int v12; 
  int v13; 
  _DEVICE_NODE *Parent; 
  const VOID **p_ServiceName; 
  const VOID *v17[5]; 

  HIDWORD(v17[0]) = 0;
  PhysicalDeviceObject = DeviceNode->PhysicalDeviceObject;
  *a4 = 0;
  ID = PnpIrpQueryID(PhysicalDeviceObject, a2, a3);
  if( ID < 0 )
  {
LABEL_15:
    if( ID == -1073479624 || !a2 || a2 == 3 && ID == -1073741670 )
    {
      PipSetDevNodeProblem(DeviceNode, 9ui64, ID);
      Parent = DeviceNode->Parent;
      if( (Parent->Flags & 0x200000) == 0 )
      {
        PipSetDevNodeFlags(Parent, 0x200000ui64);
        PnpSetInvalidIDEvent((const VOID **)&DeviceNode->Parent->InstancePath);
      }
    }
    if( ID != -1073479624 && !a2 && ID != -1073741670 && ID != -1073741810 )
    {
      p_ServiceName = (const VOID **)&DeviceNode->Parent->ServiceName;
      LODWORD(v17[0]) = 5242958;
      v17[1] = L"failed IRP_MN_QUERY_ID-BusQueryDeviceID";
      PnpLogEvent(p_ServiceName, v17, ID, 0i64, 0);
    }
    if( *a3 )
    {
      ExFreePoolWithTag((PVOID)*a3, 0);
      *a3 = 0i64;
      *a4 = 0;
    }
    return(unsigned int)ID;
  }
  if( !a2 )
  {
    v10 = 1;
LABEL_7:
    v12 = 0;
    v11 = 200;
    goto LABEL_8;
  }
  if( a2 > 0 )
  {
    if( a2 <= 2 )
    {
      v10 = -1;
      v11 = 1024;
      v12 = 1;
LABEL_8:
      v13 = PnpFixupID((int *)*a3, v11, v12, v10, (const VOID **)&DeviceNode->Parent->ServiceName);
      goto LABEL_9;
    }
    if( a2 == 3 )
    {
      v10 = 0;
      goto LABEL_7;
    }
  }
  v13 = 0;
LABEL_9:
  *a4 = 2 * v13;
  if( !(2 * v13) )
    ID = -1073479624;
  if( ID < 0 )
    goto LABEL_15;
  return(unsigned int)ID;
}

Referenced by:

PiProcessNewDeviceNode
PipProcessStartPhase3