PnpRestartDeviceNode

__int64 __fastcall PnpRestartDeviceNode(_DEVICE_NODE *DeviceNode){
  unsigned int v2; 
  bool v3; 
  _IO_RESOURCE_REQUIREMENTS_LIST *ResourceRequirements; 

  PpDevNodeLockTree(PPL_TREEOP_BLOCK_READS_FROM_ALLOW);
  if( (DeviceNode->Flags & 0x10) != 0 )
  {
    PipClearDevNodeUserFlags(DeviceNode, 5ui64);
    PipClearDevNodeFlags(DeviceNode, 0x108000ui64);
    DeviceNode->StateFlags &= 0xFFFFBC03;
    v2 = 0;
    v3 = DeviceNode->State == DeviceNodeUninitialized;
    DeviceNode->PowerFlags = 0;
    DeviceNode->FxActivationCount = 0;
    DeviceNode->FxSleepCount = 0;
    if( !v3 )
    {
      PipClearDevNodeFlags(DeviceNode, 0x7C200D00ui64);
      if( DeviceNode->ServiceName.Length )
      {
        ExFreePoolWithTag(DeviceNode->ServiceName.Buffer, 0);
        *(_DWORD *)&DeviceNode->ServiceName.Length = 0;
        DeviceNode->ServiceName.Buffer = 0i64;
      }
      ExAcquireFastMutex((PFAST_MUTEX)((char *)&PnpReplaceEvent + 6336));
      ResourceRequirements = DeviceNode->ResourceRequirements;
      if( ResourceRequirements )
      {
        ExFreePoolWithTag(ResourceRequirements, 0);
        DeviceNode->ResourceRequirements = 0i64;
        PipClearDevNodeFlags(DeviceNode, 0x200ui64);
      }
      KeReleaseGuardedMutex((PKGUARDED_MUTEX)((char *)&PnpReplaceEvent + 6336));
    }
    DeviceNode->NumaNodeIndex = -1;
    PipSetDevNodeState(DeviceNode, DeviceNodeUninitialized);
  }
  else
  {
    v2 = -1073741823;
  }
  PpDevNodeUnlockTree(PPL_TREEOP_BLOCK_READS_FROM_ALLOW);
  return v2;
}

Referenced by:

PiProcessClearDeviceProblem
PiProcessQueryRemoveNoFdo
PiProfileUpdateDeviceTreeCallback
PiRestartDevice
PiRestartRemovalRelations
PnpProcessQueryRemoveAndEject