PnpRequestDeviceRemovalWorker

VOID __stdcall PnpRequestDeviceRemovalWorker(
        _DEVICE_NODE *TargetDeviceNode,
        _DEVICE_NODE *DeviceNode,
        UINT8 TreeDeletion,
        _DEVICE_RELATION_LEVEL RelationLevel){
  UINT8 v5; 
  char IsDevNodeDNStarted; 
  _DEVICE_NODE *i; 
  LIST_ENTRY *DependentList; 
  LIST_ENTRY *Flink; 
  _PNP_DEVNODE_STATE *v12; 
  DEVICE_OBJECT *Dependent; 
  UINT64 DependencyTypes; 
  char v15; 
  Dependent = 0i64;
  v5 = TreeDeletion;
  if( RelationLevel != RELATION_LEVEL_DIRECT_DESCENDANT && !v15 )
  {
    IsDevNodeDNStarted = PipIsDevNodeDNStarted(DeviceNode);
    goto LABEL_5;
  }
  TreeDeletion = 1;
  if( *((_DWORD *)DeviceNode + 75) == 782 )
    goto LABEL_11;
  if( *((_DWORD *)DeviceNode + 75) == 783 )
  {
    if( v5 )
    {
      PipRestoreDevNodeState((__int64)DeviceNode, (UINT64)DeviceNode);
      PipSetDevNodeState(DeviceNode, DeviceNodeAwaitingQueuedDeletion, v12);
    }
LABEL_11:
    TreeDeletion = 0;
  }
  IsDevNodeDNStarted = TreeDeletion;
LABEL_5:
  if( IsDevNodeDNStarted )
  {
    PipSetDevNodeState(DeviceNode, (_PNP_DEVNODE_STATE)(783 - (v5 != 0)), (_PNP_DEVNODE_STATE *)TreeDeletion);
    for( i = (_DEVICE_NODE *)*((_QWORD *)DeviceNode + 1); i; i = *(_DEVICE_NODE **)i )
      PnpRequestDeviceRemovalWorker(TargetDeviceNode, i, 1u, RelationLevel);
    DependentList = PiGetDependentList(*((DEVICE_OBJECT **)DeviceNode + 4));
    Flink = DependentList->Flink;
    while( Flink != DependentList )
    {
      PiEnumerateDependentListEntry(Flink, &Dependent, &DependencyTypes);
      Flink = Flink->Flink;
      if( Dependent )
        PnpRequestDeviceRemovalWorker(
          TargetDeviceNode,
          *(_DEVICE_NODE **)(*((_QWORD *)Dependent + 39) + 40i64),
          0,
          RELATION_LEVEL_DEPENDENT);
    }
  }
}

Referenced by:

PnpRequestDeviceRemoval
PnpRequestDeviceRemovalWorker