PipRemoveDevicesInRelationList

__int64 __fastcall PipRemoveDevicesInRelationList(PVOID P){
  __int64 v1; 
  __int64 v3; 
  bool v4; 
  unsigned int v5; 
  __int64 v6; 
  v1 = *((_QWORD *)P + 7);
  if( v1 )
    v3 = *(_QWORD *)(*(_QWORD *)(v1 + 312) + 40i64);
  else
    v3 = 0i64;
  if( v3 )
  {
    v4 = 0;
    if( (*(_DWORD *)(v3 + 396) & 0x10) == 0 )
      v4 = *(_QWORD *)(v3 + 16) != 0i64;
    v5 = IopSortRelationListForRemove(*((_QWORD *)P + 8));
    PnpDeleteLockedDeviceNodes(
      *((_DEVICE_OBJECT **)P + 7),
      *((_RELATION_LIST **)P + 8),
      RemoveDevice,
      0,
      *((_DWORD *)P + 21),
      0,
      0i64,
      0i64);
    if( v4 )
    {
      if( *(_DWORD *)(v3 + 300) == 782 )
        IopRemoveRelationFromList(*((__int64 **)P + 8), *((_QWORD *)P + 7));
      PnpUnlinkDeviceRemovalRelations(v6, *((_QWORD *)P + 8));
    }
  }
  else
  {
    v5 = -1073741823;
  }
  IopFreeRelationList(*((PVOID *)P + 8));
  ExFreePoolWithTag(P, 0);
  return v5;
}

Referenced by:

PnpDelayedRemoveWorker