PiEventBuildPdoList

INT64 __fastcall PiEventBuildPdoList(
        _RELATION_LIST *RelationList,
        _PNP_DEVICE_DELETE_TYPE DeleteType,
        _PNP_DEVICE_EVENT_ENTRY *DeviceEvent,
        UINT *PdoListCount,
        _DEVICE_OBJECT ***PdoListOut,
        UINT8 *PossibleProfileChangeInProgress,
        UINT8 *SubsumingProfileChange){
  UINT8 *v7; 
  unsigned int v8; 
  UINT8 *v9; 
  _DEVICE_OBJECT_LIST *DeviceObjectList; 
  _DEVICE_OBJECT **CriticalMemory; 
  _DEVICE_OBJECT *v16; 
  __int64 v17; 
  int v18; 
  __int64 v19; 
  INT64 result; 
  _PNP_VETO_TYPE v21; 
  _QWORD a3[2]; 
  int a4; 
  v7 = PossibleProfileChangeInProgress;
  v8 = 0;
  v9 = SubsumingProfileChange;
  a3[0] = 0i64;
  a4 = 0;
  DeviceObjectList = RelationList->DeviceObjectList;
  *PossibleProfileChangeInProgress = 0;
  *v9 = 0;
  CriticalMemory = (_DEVICE_OBJECT **)PnpAllocateCriticalMemory(
                                        (unsigned int)DeleteType,
                                        NonPagedPoolNx,
                                        8i64 * DeviceObjectList->Count,
                                        0x4E706E50ui64);
  if( CriticalMemory )
  {
    *PdoListCount = 0;
    PossibleProfileChangeInProgress = (UINT8 *)1;
    while( 1 )
    {
      do
      {
        if( !IopEnumerateRelations(
                (unsigned int **)RelationList,
                (int *)&PossibleProfileChangeInProgress,
                a3,
                &a4,
                0i64) )
          goto LABEL_14;
      }
      while( !a4 && DeleteType != EjectDevice && DeleteType );
      v16 = (_DEVICE_OBJECT *)a3[0];
      if( a3[0] )
        v17 = *(_QWORD *)(*(_QWORD *)(a3[0] + 312i64) + 40i64);
      else
        v17 = 0i64;
      if( DeleteType == RemoveDevice )
        goto LABEL_12;
      if( DeleteType )
        break;
LABEL_18:
      if( (*(_DWORD *)(v17 + 396) & 0x1000) != 0 )
      {
        v21 = PNP_VetoLegacyDevice;
        goto LABEL_25;
      }
      if( *(_DWORD *)(v17 + 300) == 785 )
      {
        v21 = PNP_VetoOutstandingOpen;
LABEL_25:
        PnpFinalizeVetoedRemove(DeviceEvent, v21, (_UNICODE_STRING *)(v17 + 40));
        v8 = -2147483608;
        goto LABEL_14;
      }
LABEL_13:
      v19 = *PdoListCount;
      CriticalMemory[v19] = v16;
      *PdoListCount = v19 + 1;
    }
    v18 = *(_DWORD *)(v17 + 568);
    if( v18 == 1 )
    {
      *v7 = 1;
    }
    else if( v18 )
    {
      *v9 = 1;
    }
LABEL_12:
    if( (DeleteType & 0xFFFFFFFB) != 0 )
      goto LABEL_13;
    goto LABEL_18;
  }
  v8 = -1073741670;
LABEL_14:
  result = v8;
  *PdoListOut = CriticalMemory;
  return result;
}

Referenced by:

PnpProcessQueryRemoveAndEject