PnpQueryRebalanceWorker

__int64 __fastcall PnpQueryRebalanceWorker(
        ULONG_PTR BugCheckParameter2,
        __int64 a2,
        _DWORD *a3,
        ULONG_PTR *a4,
        __int64 a5,
        char a6){
  int v6; 
  int v7; 
  _DWORD *v9; 
  int StopDeviceNode; 
  unsigned int v14; 
  __int64 v15; 
  INT64 v16; 
  INT64 v17; 
  unsigned __int64 v18; 
  unsigned int v19; 
  int v20; 
  UINT64 DeviceCount; 
  _DWORD *v23; 
  v23 = a3;
  LODWORD(DeviceCount) = 0;
  v6 = 0;
  v7 = *(_DWORD *)(BugCheckParameter2 + 300);
  v9 = (_DWORD *)a5;
  if( v7 == 776 )
  {
    if( (*(_DWORD *)(BugCheckParameter2 + 396) & 0x1000) == 0 )
    {
      StopDeviceNode = PnpQueryStopDeviceNode((_DEVICE_NODE *)BugCheckParameter2, a6);
      v6 = StopDeviceNode;
      if( StopDeviceNode < 0 )
      {
        PnpCancelStopDeviceNode(BugCheckParameter2);
        if( v9 )
          *v9 = 1;
      }
      else
      {
        if( StopDeviceNode == 281 )
          PipSetDevNodeFlags(BugCheckParameter2, 1024);
        v14 = *a3;
        v15 = *(_QWORD *)(BugCheckParameter2 + 32);
        v16 = a2 + ((unsigned __int64)v14 << 6);
        memset(v16, 0i64);
        *(_QWORD *)v16 = v15;
        *(_DWORD *)(v16 + 12) = 4;
        PnpGetResourceRequirementsForAssignTable(
          (_PNP_RESOURCE_REQUEST *)v16,
          (_PNP_RESOURCE_REQUEST *)(a2 + ((unsigned __int64)(v14 + 1) << 6)),
          &DeviceCount,
          v17);
        v18 = (unsigned __int64)(unsigned int)*v23 << 6;
        if( *(int *)(v18 + a2 + 56) < 0 )
        {
          v6 = *(_DWORD *)(v18 + a2 + 56);
          PnpCancelStopDeviceNode(BugCheckParameter2);
          if( v9 )
            *v9 = 2;
        }
        else if( (*(_DWORD *)(v18 + a2 + 8) & 0x20) == 0 )
        {
          ++*v23;
        }
      }
      goto LABEL_20;
    }
    goto LABEL_15;
  }
  v19 = v7 - 769;
  if( v19 > 0x11 || (v20 = 196871, !_bittest(&v20, v19)) )
  {
LABEL_15:
    if( (*(_DWORD *)(BugCheckParameter2 + 396) & 0x40000) == 0 )
    {
      v6 = -1073741823;
      if( a5 )
        *(_DWORD *)a5 = 3;
      goto LABEL_21;
    }
  }
  if( !a5 )
    goto LABEL_23;
  *(_DWORD *)a5 = 4;
LABEL_20:
  if( v6 < 0 )
  {
LABEL_21:
    if( a4 )
      *a4 = BugCheckParameter2;
    return(unsigned int)v6;
  }
LABEL_23:
  if( a4 )
    *a4 = 0i64;
  if( v9 )
    *v9 = 0;
  return(unsigned int)v6;
}

Referenced by:

PnpQueryRebalance