setupapi

package
v0.0.0-...-9f4f02d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LineLength           = 256 // LINE_LEN
	MaxClassNameLength   = 32  // MAX_CLASS_NAME_LEN
	MaxProfileNameLength = 80  // MAX_PROFILE_LEN
)

Constants defined by the setupapi package.

Variables

View Source
var (
	// ErrEmptyBuffer is returned when a nil or zero-sized buffer is provided
	// to a system call.
	ErrEmptyBuffer = errors.New("nil or empty buffer provided")

	// ErrInvalidData is returned when a property isn't present or isn't valid.
	ErrInvalidData = syscall.Errno(13) // ERROR_INVALID_DATA

	// ErrInvalidClass indicates that an invalid class was specified.
	ErrInvalidClass = syscall.Errno(0xE0000209) // ERROR_INVALID_CLASS

)

Functions

func BuildDriverInfoList

func BuildDriverInfoList(devices syscall.Handle, device *DevInfoData, driverType uint32) error

BuildDriverInfoList builds a driver information list that contains drivers of the requested driver type. It calls the SetupDiBuildDriverInfoList windows API function.

The driver list will be affiliated with the device list identified by devices. Driver information can be retrieved from the list by calling the EnumDriverInfo function.

The driver list membership is influenced by four factors:

  1. The requested driver type
  2. The setup class associated with the device list, if any
  3. The installation and enumeration flags associated with the device list
  4. The provided device

It is the caller's responsibility to destroy the driver list when it is no longer needed by calling DestroyDriverInfoList with the same parameters.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdibuilddriverinfolist

func CallClassInstaller

func CallClassInstaller(function difunc.Function, devices syscall.Handle, device *DevInfoData) error

CallClassInstaller invokes a class installer function for a device. It calls the SetupDiCallClassInstaller windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdicallclassinstaller

func ClassGuidsFromNameEx

func ClassGuidsFromNameEx(className, machine string) (guids []windows.GUID, err error)

ClassGuidsFromNameEx returns the list of GUIDs associated with a class name. It calls the SetupDiClassGuidsFromNameEx windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdiclassguidsfromnameexw

func CreateDeviceInfoList

func CreateDeviceInfoList(guid *windows.GUID) (handle syscall.Handle, err error)

CreateDeviceInfoList creates an empty device information list. It calls the SetupDiCreateDeviceInfoList windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdicreatedeviceinfolist

func DestroyDeviceInfoList

func DestroyDeviceInfoList(devices syscall.Handle) error

DestroyDeviceInfoList destroys a device information list. It calls the SetupDiDestroyDeviceInfoList windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdidestroydeviceinfolist

func DestroyDriverInfoList

func DestroyDriverInfoList(devices syscall.Handle, device *DevInfoData, driverType uint32) error

DestroyDriverInfoList destroys a device information list. It calls the SetupDiDestroyDriverInfoList windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdidestroydriverinfolist

func GetClassDevsEx

func GetClassDevsEx(guid *windows.GUID, enumerator string, flags uint32, devices syscall.Handle, machineName string) (handle syscall.Handle, err error)

GetClassDevsEx builds and returns a device information list that contains devices matching the given parameters. It calls the SetupDiGetClassDevsEx windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetclassdevsexw

func GetDeviceInstanceID

func GetDeviceInstanceID(devices syscall.Handle, device DevInfoData) (id deviceid.DeviceInstance, err error)

GetDeviceInstanceID returns the device instance ID for a device. It calls the SetupDiGetDeviceInstanceIdW windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetdeviceinstanceidw

func GetDeviceProperty

func GetDeviceProperty(devices syscall.Handle, device DevInfoData, key deviceproperty.Key) (value deviceproperty.Value, err error)

GetDeviceProperty returns a device property for a device instance. It calls the SetupDiGetDevicePropertyW windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetdevicepropertyw

func GetDevicePropertyKeys

func GetDevicePropertyKeys(devices syscall.Handle, device DevInfoData) (keys []deviceproperty.Key, err error)

GetDevicePropertyKeys returns all of the property keys for a device instance. It calls the SetupDiGetDevicePropertyW windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetdevicepropertykeys

func GetDeviceRegistryProperty

func GetDeviceRegistryProperty(devices syscall.Handle, device DevInfoData, property deviceregistry.Code, buffer []byte) (dataType uint32, data []byte, err error)

GetDeviceRegistryProperty retrieves a member property from a device information list. It calls the SetupDiGetDeviceRegistryProperty windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetdeviceregistrypropertyw

func GetDeviceRegistryString

func GetDeviceRegistryString(devices syscall.Handle, device DevInfoData, property deviceregistry.Code) (value string, err error)

GetDeviceRegistryString retrieves a property from the registry as a string.

func GetDeviceRegistryStrings

func GetDeviceRegistryStrings(devices syscall.Handle, device DevInfoData, property deviceregistry.Code) (values []string, err error)

GetDeviceRegistryStrings retrieves a property from the registry as a slice of strings.

func GetDeviceRegistryUint32

func GetDeviceRegistryUint32(devices syscall.Handle, device DevInfoData, property deviceregistry.Code) (value uint32, err error)

GetDeviceRegistryUint32 retrieves a property from the registry as a uint32.

func GetInfClass

func GetInfClass(path string) (name string, guid windows.GUID, err error)

GetInfClass returns the device class name and GUID from an INF file. It calls the SetupDiGetINFClassW windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetinfclassw

func OpenDevRegKey

func OpenDevRegKey(devices syscall.Handle, device DevInfoData, scope hwprofile.Scope, profile hwprofile.ID, keyType deviceregistry.KeyType, access deviceregistry.AccessMask) (key registry.Key, err error)

OpenDevRegKey opens a device registry key and returns a handle to it. It calls the SetupDiOpenDevRegKey windows API function.

It is the caller's respnosibility to close the registry key handle when finished with it.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdiopendevregkey

func SetClassInstallParams

func SetClassInstallParams(devices syscall.Handle, device *DevInfoData, header *difunc.ClassInstallHeader, size uint32) error

SetClassInstallParams updates the class installation parameters for a device or device information set. It calls the SetupDiSetClassInstallParams windows API function.

If a header is provided, it must be embedded within a params struct that is appropriate for the device installation function specified in the header.

If a non-zero size is provided, it must be the size of the enclosing params struct that contains the header. If a size of 0 is provided the installation parameters of the class will be cleared.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdisetdeviceinstallparamsw

func SetDeviceInstallParams

func SetDeviceInstallParams(devices syscall.Handle, device *DevInfoData, params DevInstallParams) error

SetDeviceInstallParams updates the installation parameters for a device or device information set. It calls the SetupDiSetDeviceInstallParams windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdisetdeviceinstallparamsw

func SetDeviceRegistryProperty

func SetDeviceRegistryProperty(devices syscall.Handle, device DevInfoData, property deviceregistry.Code, buffer []byte) (err error)

SetDeviceRegistryProperty sets a device registry property. It calls the SetupDiSetDeviceRegistryProperty windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdisetdeviceregistrypropertyw

func SetDeviceRegistryString

func SetDeviceRegistryString(devices syscall.Handle, device DevInfoData, property deviceregistry.Code, value string) (err error)

SetDeviceRegistryString sets a device registry property to a string value.

The value will be encoded in REG_SZ format.

func SetDeviceRegistryStrings

func SetDeviceRegistryStrings(devices syscall.Handle, device DevInfoData, property deviceregistry.Code, values []string) (err error)

SetDeviceRegistryStrings sets a device registry property to a set of string values.

The values will be encoded in REG_MULTI_SZ format.

Types

type DevInfoData

type DevInfoData struct {
	Size    uint32
	GUID    windows.GUID
	DevInst uint32
	// contains filtered or unexported fields
}

DevInfoData holds device information.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/ns-setupapi-sp_devinfo_data

func CreateDeviceInfo

func CreateDeviceInfo(devices syscall.Handle, name string, class windows.GUID, description string, flags devicecreation.Flags) (device DevInfoData, err error)

CreateDeviceInfo creates a new device and adds it to the device information set. It calls the SetupDiCreateDeviceInfoW windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdicreatedeviceinfow

func EnumDeviceInfo

func EnumDeviceInfo(devices syscall.Handle, index uint32) (info DevInfoData, err error)

EnumDeviceInfo returns information about a device in a device information list. It calls the SetupDiEnumDeviceInfo windows API function.

EnumDeviceInfo returns io.EOF when there are no more members in the list.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdienumdeviceinfo

type DevInstallParams

type DevInstallParams struct {
	Size                     uint32
	Flags                    diflag.Value
	FlagsEx                  diflagex.Value
	ParentWindow             syscall.Handle
	InstallMsgHandler        *func()
	InstallMsgHandlerContext *byte
	FileQueue                syscall.Handle
	ClassInstallReserved     uintptr

	DriverPath Path
	// contains filtered or unexported fields
}

DevInstallParams holds device installation parameters. It implements the SP_DEVINSTALL_PARAMS_W windows API structure.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/ns-setupapi-_sp_devinstall_params_w

func GetDeviceInstallParams

func GetDeviceInstallParams(devices syscall.Handle, device *DevInfoData) (params DevInstallParams, err error)

GetDeviceInstallParams returns the installation parameters for a device or device information set. It calls the SetupDiGetDeviceInstallParams windows API function.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdigetdeviceinstallparamsw

type DriverDate

type DriverDate windows.Filetime

DriverDate holds a device driver release date as a filetime.

func (DriverDate) String

func (date DriverDate) String() string

Value returns the driver date as a time value.

func (DriverDate) Value

func (date DriverDate) Value() time.Time

Value returns the driver date as a time value.

type DrvInfoData

type DrvInfoData struct {
	Size uint32
	Type drivertype.Value

	Description  Line
	MfgName      Line
	ProviderName Line
	Date         DriverDate
	Version      driverversion.Value
	// contains filtered or unexported fields
}

DrvInfoData holds driver information.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/ns-setupapi-_sp_drvinfo_data_v2_w

func EnumDriverInfo

func EnumDriverInfo(devices syscall.Handle, device *DevInfoData, driverType uint32, index uint32) (info DrvInfoData, err error)

EnumDriverInfo returns information about a driver in a driver information list. It calls the SetupDiEnumDriverInfo windows API function.

EnumDriverInfo returns io.EOF when there are no more members in the list.

https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdienumdriverinfow

type Line

type Line [LineLength]uint16

Line is a utf16 string of a predefined maximum length.

func (Line) String

func (line Line) String() string

String returns a string representation of the line.

type Path

type Path [syscall.MAX_PATH]uint16

Path is a utf16 string of a predefined maximum length.

func (Path) String

func (path Path) String() string

String returns a string representation of the path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL