PipSetDevNodeState

VOID __stdcall PipSetDevNodeState(_DEVICE_NODE *DeviceNode, _PNP_DEVNODE_STATE State){
  int v4; 
  _BOOL4 v5; 
  char v6; 
  unsigned __int8 v7; 
  _PNP_DEVNODE_STATE v8; 
  unsigned __int64 v9; 
  _BOOL4 IsDevNodeDNStarted; 
  __int64 StateHistoryEntry; 
  _PNP_DEVNODE_STATE v12; 
  INT64 v13; 
  WCHAR *v14; 
  INT64 v15; 

  v4 = 0;
  v5 = 0;
  v6 = 0;
  v7 = KeAcquireSpinLockRaiseToDpc((UINT64 *)&PnpReplaceEvent + 50);
  v8 = DeviceNode->State;
  v9 = v7;
  if( v8 != State )
  {
    v4 = PipAreDriversLoadedWorker(v8, DeviceNode->PreviousState);
    IsDevNodeDNStarted = PipIsDevNodeDNStarted((__int64)DeviceNode);
    StateHistoryEntry = DeviceNode->StateHistoryEntry;
    v5 = IsDevNodeDNStarted;
    DeviceNode->PreviousState = v12;
    DeviceNode->State = State;
    v6 = 1;
    DeviceNode->StateHistory[StateHistoryEntry] = v12;
    DeviceNode->StateHistoryEntry = (DeviceNode->StateHistoryEntry + 1) % 0x14;
  }
  KxReleaseSpinLock((UINT64 *)&PnpReplaceEvent + 50);
  __writecr8(v9);
  if( v6
    && DeviceNode->InstancePath.Buffer
    && ((unsigned int)PipAreDriversLoadedWorker(DeviceNode->State, DeviceNode->PreviousState) != v4
     || PipIsDevNodeDNStarted((__int64)DeviceNode) != v5) )
  {
    PnpRaiseNtPlugPlayDevicePropertyChangeEvent(v13, v14, 11);
    if( PipIsDevNodeDNStarted((__int64)DeviceNode) != v5 )
      PnpRaiseNtPlugPlayDevicePropertyChangeEvent(v15, DeviceNode->InstancePath.Buffer, 26);
  }
  if( State == DeviceNodeDeleted )
    PnpRemoveDeviceActionRequests((_LIST_ENTRY *)DeviceNode->PhysicalDeviceObject);
}

Referenced by:

IoReportDetectedDevice
IopInitializeDeviceInstanceKey
IopInitializePlugPlayServices
IopLegacyResourceAllocation
PiInitializeDevice
PiProcessNewDeviceNode
PipCallDriverAddDevice
PipCallDriverAddDeviceQueryRoutine
PipEnumerateCompleted
PipEnumerateDevice
PipProcessRestartPhase2
PipProcessStartPhase2
PipProcessStartPhase3
PnpDeviceCompletionProcessCompletedRequest
PnpDriverLoadingFailed
PnpProcessAssignResources
PnpQueryRemoveLockedDeviceNode
PnpQueryStopDeviceNode
PnpRemoveLockedDeviceNode
PnpRequestDeviceRemovalWorker
PnpRestartDeviceNode
PnpStartDeviceNode
PnpStopDeviceSubtree
PnpSurpriseRemoveLockedDeviceNode