PnpStartDeviceNode

__int64 __fastcall PnpStartDeviceNode(_DEVICE_NODE *DeviceNode, int a2, int a3){
  int v5; 
  VOID **v6; 
  __int64 v7; 
  __int64 v8; 
  int started; 
  __int64 v11; 
  __int64 v12; 
  __int128 Object; 
  __int64 v14; 
  int v15; 
  int v16; 

  v14 = 0i64;
  v16 = 0;
  Object = 0i64;
  v5 = a2 != 0 ? 5 : 0;
  if( !a2 && (unsigned int)IopGetSessionIdFromPDO(DeviceNode->PhysicalDeviceObject) != -1 )
    PpMarkDeviceStackExtensionFlag(DeviceNode->PhysicalDeviceObject, 0x400ui64, 1u);
  if( a3
    || (PnpAsyncOptions & 1) == 0
    || (DeviceNode->Flags & 0x400000) != 0
    || (DeviceNode->PhysicalDeviceObject->Flags & 0x4000) != 0
    || InitSafeBootMode
    || (v6 = PnpDeviceCompletionRequestCreate((__int64)DeviceNode, v5 + 774)) == 0i64 )
  {
    PnpDiagnosticTraceObject(&KMPnPEvt_DeviceStart_Start, &DeviceNode->InstancePath.Length);
    v12 = 0i64;
    v15 = -1073741823;
    KeInitializeEvent((INT64)&Object, 1, 0);
    started = PnpStartDevice(
                DeviceNode->PhysicalDeviceObject,
                (int(__fastcall *)(_DEVICE_OBJECT *, _IRP *, void *))PnpDiagnosticCompletionRoutine,
                (UINT64 *)&v12);
    if( started == 259 )
    {
      KeWaitForSingleObject((UINT64)&Object, 0, 0, 0, 0i64);
      started = v15;
    }
    if( started >= 0 )
    {
      PipUpdatePostStartCharacteristics(DeviceNode->PhysicalDeviceObject);
      PnpSetObjectProperty(
        *(&stru_140CF2E80 + 607),
        (INT64)DeviceNode->InstancePath.Buffer,
        1u,
        0i64,
        0i64,
        (__int64)&DEVPKEY_Device_DriverProblemDesc,
        0,
        0i64,
        0,
        0);
      PiSwProcessParentStartIrp(DeviceNode->PhysicalDeviceObject);
    }
    v11 = v12;
    DeviceNode->CompletionStatus = started;
    PnpTraceStartDevice((__int64)DeviceNode, started, v11);
    PipSetDevNodeState(DeviceNode, (_PNP_DEVNODE_STATE)(v5 + 774));
  }
  else
  {
    PnpDiagnosticTraceObject(&KMPnPEvt_DeviceStart_Start, &DeviceNode->InstancePath.Length);
    PipSetDevNodeState(DeviceNode, DeviceNodeStartPending);
    DeviceNode->CompletionStatus = 259;
    PnpDeviceCompletionQueueAddDispatchedRequest(v7, v6);
    started = PnpStartDevice(
                DeviceNode->PhysicalDeviceObject,
                (int(__fastcall *)(_DEVICE_OBJECT *, _IRP *, void *))PnpDeviceCompletionRoutine,
                (UINT64 *)v6);
    if( started == 259 )
    {
      PnpDiagnosticTraceObject(&KMPnPEvt_DeviceStart_Pend, &DeviceNode->InstancePath.Length);
    }
    else
    {
      PnpDeviceCompletionQueueRemoveCompletedRequest(v8, v6);
      return(unsigned int)PnpDeviceCompletionProcessCompletedRequest(v6);
    }
  }
  return(unsigned int)started;
}

Referenced by:

PipProcessRestartPhase1
PipProcessStartPhase1
PnpReallocateResources