internal DeviceStackEntry(string driver, string driver_path, DeviceStackEntryType type) { Driver = driver; DriverPath = driver_path; Type = type; }
private IReadOnlyList <DeviceStackEntry> BuildDeviceStack() { var setup_class = new DeviceSetupClass(Class); var parent = Parent; HashSet <string> upper_filters = new HashSet <string>(UpperFilters.Concat(setup_class.UpperFilters), StringComparer.OrdinalIgnoreCase); HashSet <string> lower_filters = new HashSet <string>(LowerFilters.Concat(setup_class.LowerFilters), StringComparer.OrdinalIgnoreCase); bool found_fdo = false; bool found_pdo = false; string service_name = GetServiceName(_service_info.Value.ServiceStartName); if (string.IsNullOrWhiteSpace(service_name)) { service_name = Service; } List <DeviceStackEntry> stack = new List <DeviceStackEntry>(); foreach (var driver_path in DeviceStackPaths) { DeviceStackEntryType type = DeviceStackEntryType.Unknown; string name = GetServiceName(driver_path); if (name.Equals(service_name, StringComparison.OrdinalIgnoreCase) && !found_fdo) { type = DeviceStackEntryType.Function; found_fdo = true; } else if (Parent != null && name.Equals(Parent.Service, StringComparison.OrdinalIgnoreCase) && !found_pdo) { type = DeviceStackEntryType.Bus; found_pdo = true; } else if (BusType == DeviceBusTypeGuids.GUID_BUS_TYPE_SW_DEVICE && !found_pdo && name.Equals("SoftwareDevice", StringComparison.OrdinalIgnoreCase)) { type = DeviceStackEntryType.Bus; found_pdo = true; } else if (name.Equals("PnpManager", StringComparison.OrdinalIgnoreCase)) { if (Parent == null) { type = DeviceStackEntryType.Function; found_fdo = true; } else { type = DeviceStackEntryType.Bus; found_pdo = true; } } else if (!found_fdo && upper_filters.Contains(name)) { type = DeviceStackEntryType.UpperFilter; } else if (found_fdo && lower_filters.Contains(name)) { type = DeviceStackEntryType.LowerFilter; } else { type = DeviceStackEntryType.Filter; } stack.Add(new DeviceStackEntry(name, driver_path, type)); } return(stack.AsReadOnly()); }