internal DeviceNode(int devinst)
        {
            _devinst   = devinst;
            InstanceId = DeviceUtils.GetDeviceNodeId(devinst);
            Name       = DeviceUtils.GetDeviceName(devinst);
            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = InstanceId;
            }
            PDOName   = DeviceUtils.GetPropertyString(devinst, DevicePropertyKeys.DEVPKEY_Device_PDOName);
            INFName   = DeviceUtils.GetPropertyString(devinst, DevicePropertyKeys.DEVPKEY_Device_DriverInfPath);
            SessionId = DeviceUtils.GetPropertyUInt32(devinst, DevicePropertyKeys.DEVPKEY_Device_SessionId);
            Service   = GetServiceName(DeviceUtils.GetPropertyString(devinst, DevicePropertyKeys.DEVPKEY_Device_Service));
            if (string.IsNullOrEmpty(INFName))
            {
                INFPath = string.Empty;
            }
            else
            {
                INFPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "INF", INFName);
            }

            DeviceStackPaths = DeviceUtils.GetPropertyStringList(devinst, DevicePropertyKeys.DEVPKEY_Device_Stack);
            _device_stack    = new Lazy <IReadOnlyList <DeviceStackEntry> >(BuildDeviceStack);
            _parent          = new Lazy <DeviceNode>(GetParent);
            Class            = DeviceUtils.GetPropertyGuid(devinst, DevicePropertyKeys.DEVPKEY_Device_ClassGuid);
            IsPresent        = DeviceUtils.GetPropertyBoolean(devinst, DevicePropertyKeys.DEVPKEY_Device_IsPresent);
            UpperFilters     = DeviceUtils.GetPropertyStringList(devinst, DevicePropertyKeys.DEVPKEY_Device_UpperFilters);
            LowerFilters     = DeviceUtils.GetPropertyStringList(devinst, DevicePropertyKeys.DEVPKEY_Device_LowerFilters);
            ContainerId      = DeviceUtils.GetPropertyGuid(devinst, DevicePropertyKeys.DEVPKEY_Device_ContainerId);
            BusType          = DeviceUtils.GetPropertyGuid(devinst, DevicePropertyKeys.DEVPKEY_Device_BusTypeGuid);
            _sd           = new Lazy <SecurityDescriptor>(GetSecurityDescriptor);
            _properties   = new Lazy <List <DeviceProperty> >(GetAllProperties);
            _service_info = new Lazy <ServiceInformation>(GetServiceInformation);
        }
Ejemplo n.º 2
0
 internal DeviceInterfaceClass(Guid guid, bool all_devices)
 {
     Class     = guid;
     Instances = DeviceUtils.GetDeviceInterfaceList(guid, null, all_devices)
                 .Select(s => new DeviceInterfaceInstance(s, guid)).ToList().AsReadOnly();
     Name        = DeviceUtils.GetDeviceInterfaceName(Class);
     _properties = new Lazy <List <DeviceProperty> >(GetAllProperties);
 }
 internal DeviceInterfaceInstance(string link_path, Guid class_guid)
 {
     SymbolicLinkPath = link_path;
     Class            = class_guid;
     InstanceId       = DeviceUtils.GetProperty(link_path,
                                                DevicePropertyKeys.DEVPKEY_Device_InstanceId).GetString();
     _device_path = new Lazy <string>(MapWin32ToDevicePath);
     _properties  = new Lazy <List <DeviceProperty> >(GetAllProperties);
 }
Ejemplo n.º 4
0
 internal DeviceSetupClass(Guid class_guid)
 {
     Class              = class_guid;
     FriendlyName       = DeviceUtils.GetClassString(class_guid, false, DevicePropertyKeys.DEVPKEY_DeviceClass_Name, false).GetResultOrDefault(class_guid.ToString());
     Name               = DeviceUtils.GetClassString(class_guid, false, DevicePropertyKeys.DEVPKEY_DeviceClass_ClassName, false).GetResultOrDefault(class_guid.ToString());
     DeviceType         = (FileDeviceType)DeviceUtils.GetClassInt(class_guid, false, DevicePropertyKeys.DEVPKEY_DeviceClass_DevType, false).GetResultOrDefault(0);
     Characteristics    = (FileDeviceCharacteristics)DeviceUtils.GetClassInt(class_guid, false, DevicePropertyKeys.DEVPKEY_DeviceClass_Characteristics, false).GetResultOrDefault(0);
     SecurityDescriptor = DeviceUtils.GetDeviceSecurityDescriptor(class_guid, false).GetResultOrDefault();
     UpperFilters       = DeviceUtils.GetClassStringList(class_guid, false, DevicePropertyKeys.DEVPKEY_DeviceClass_UpperFilters);
     LowerFilters       = DeviceUtils.GetClassStringList(class_guid, false, DevicePropertyKeys.DEVPKEY_DeviceClass_LowerFilters);
     _properties        = new Lazy <List <DeviceProperty> >(GetAllProperties);
 }
Ejemplo n.º 5
0
 private List <DeviceProperty> GetAllProperties()
 {
     return(DeviceUtils.GetDeviceProperties(Class, true).ToList());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Get device instances.
 /// </summary>
 /// <param name="all_devices">Return all devices.</param>
 /// <returns>The list of devices instances.</returns>
 public IReadOnlyList <DeviceNode> GetInstances(bool all_devices)
 {
     return(DeviceUtils.GetDeviceNodeList(Class, all_devices).ToList().AsReadOnly());
 }
 private static Guid GetDeviceInterfaceClass(string link_path)
 {
     return(DeviceUtils.GetProperty(link_path,
                                    DevicePropertyKeys.DEVPKEY_DeviceInterface_ClassGuid).GetGuid()
            ?? throw new ArgumentException("Unknown device interface instance."));
 }
 private List <DeviceProperty> GetAllProperties()
 {
     return(DeviceUtils.GetInterfaceInstanceProperties(SymbolicLinkPath).ToList());
 }
 private List <DeviceProperty> GetAllProperties()
 {
     return(DeviceUtils.GetDeviceProperties(_devinst).ToList());
 }
 private SecurityDescriptor GetSecurityDescriptor()
 {
     return(DeviceUtils.GetProperty(_devinst,
                                    DevicePropertyKeys.DEVPKEY_Device_Security)?.GetSecurityDescriptor());
 }
 /// <summary>
 /// Get the setup class for this instance.
 /// </summary>
 /// <returns>Returns the setup class.</returns>
 /// <exception cref="ArgumentException">Thrown if invalid setup GUID.</exception>
 public DeviceSetupClass GetSetupClass()
 {
     return(DeviceUtils.GetDeviceSetupClass(Class));
 }