PiRestartDevice

NTSTATUS __stdcall PiRestartDevice(_PNP_DEVICE_ACTION_ENTRY *Request){
  _DEVICE_NODE *DeviceNode; 
  _PNP_DEVNODE_STATE State; 
  UINT64 ReallocateResources; 
  UINT64 Synchronous; 
  UINT64 ProcessOnlyIntermediateStates; 
  _ADD_CONTEXT AddContext; 

  AddContext = 0i64;
  DeviceNode = (_DEVICE_NODE *)Request->DeviceObject->DeviceObjectExtension->DeviceNode;
  State = DeviceNode->State;
  if( (unsigned int)(State - 787) <= 1 )
    return -1073741738;
  if( (DeviceNode->Flags & 0x6000) != 0 )
    return -1073741823;
  switch( State )
  {
    case DeviceNodeUninitialized:
    case DeviceNodeDriversAdded:
    case DeviceNodeResourcesAssigned:
    case DeviceNodeStartCompletion:
    case DeviceNodeStartPostWork:
    case DeviceNodeEnumerateCompletion:
      goto LABEL_4;
    case DeviceNodeInitialized:
    case DeviceNodeRemoved:
      PnpRestartDeviceNode(DeviceNode);
LABEL_4:
      if( Request->RequestType == StartDevice )
      {
        AddContext.LoadDriver = *(&PnpReplaceEvent + 6682);
        AddContext.DriverStartType = 3;
        ObfReferenceObject(DeviceNode->PhysicalDeviceObject);
        LOBYTE(ProcessOnlyIntermediateStates) = 0;
        LOBYTE(Synchronous) = 0;
        LOBYTE(ReallocateResources) = 0;
        PipProcessDevNodeTree(
          DeviceNode,
          Request,
          &AddContext,
          EnumTypeNone,
          ReallocateResources,
          Synchronous,
          ProcessOnlyIntermediateStates);
      }
      break;
    case DeviceNodeStartPending:
    case DeviceNodeStarted:
    case DeviceNodeQueryStopped:
    case DeviceNodeStopped:
    case DeviceNodeRestartCompletion:
    case DeviceNodeEnumeratePending:
      return 0;
    default:
      return -1073741823;
  }
  return 0;
}

Referenced by:

PnpDeviceActionWorker