summaryrefslogtreecommitdiffhomepage
path: root/setupapi
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-01 14:58:59 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 12:59:42 +0100
commita5a1ece32f96416bba9515d22555c6df86a379bb (patch)
treeff6384a877c3eed473c5898101e313f863f2bded /setupapi
parentf1d5db6547738a24b660d766d0690bb9642cc1bb (diff)
Add support for setupapi.SetupDi(Get|Set)ClassInstallParams()
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi')
-rw-r--r--setupapi/setupapi_windows.go2
-rw-r--r--setupapi/types_windows.go52
-rw-r--r--setupapi/zsetupapi_windows.go26
3 files changed, 80 insertions, 0 deletions
diff --git a/setupapi/setupapi_windows.go b/setupapi/setupapi_windows.go
index 3fa0cbb..89fb3e4 100644
--- a/setupapi/setupapi_windows.go
+++ b/setupapi/setupapi_windows.go
@@ -20,6 +20,8 @@ import (
//sys setupDiOpenDevRegKey(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, Scope DICS_FLAG, HwProfile uint32, KeyType DIREG, samDesired uint32) (key windows.Handle, err error) [failretval==windows.InvalidHandle] = setupapi.SetupDiOpenDevRegKey
//sys setupDiGetDeviceInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, DeviceInstallParams *_SP_DEVINSTALL_PARAMS) (err error) = setupapi.SetupDiGetDeviceInstallParamsW
//sys setupDiSetDeviceInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, DeviceInstallParams *_SP_DEVINSTALL_PARAMS) (err error) = setupapi.SetupDiSetDeviceInstallParamsW
+//sys SetupDiGetClassInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, ClassInstallParams *SP_CLASSINSTALL_HEADER, ClassInstallParamsSize uint32, RequiredSize *uint32) (err error) = setupapi.SetupDiGetClassInstallParamsW
+//sys SetupDiSetClassInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, ClassInstallParams *SP_CLASSINSTALL_HEADER, ClassInstallParamsSize uint32) (err error) = setupapi.SetupDiSetClassInstallParamsW
// SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer.
func SetupDiGetClassDevsEx(ClassGUID *windows.GUID, Enumerator string, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName string) (handle DevInfo, err error) {
diff --git a/setupapi/types_windows.go b/setupapi/types_windows.go
index e8fe650..e2617a4 100644
--- a/setupapi/types_windows.go
+++ b/setupapi/types_windows.go
@@ -208,3 +208,55 @@ type DevInstallParams struct {
FileQueue HSPFILEQ
DriverPath string
}
+
+// DI_FUNCTION is function type for device installer
+type DI_FUNCTION uint32
+
+const (
+ DIF_SELECTDEVICE DI_FUNCTION = 0x00000001
+ DIF_INSTALLDEVICE DI_FUNCTION = 0x00000002
+ DIF_ASSIGNRESOURCES DI_FUNCTION = 0x00000003
+ DIF_PROPERTIES DI_FUNCTION = 0x00000004
+ DIF_REMOVE DI_FUNCTION = 0x00000005
+ DIF_FIRSTTIMESETUP DI_FUNCTION = 0x00000006
+ DIF_FOUNDDEVICE DI_FUNCTION = 0x00000007
+ DIF_SELECTCLASSDRIVERS DI_FUNCTION = 0x00000008
+ DIF_VALIDATECLASSDRIVERS DI_FUNCTION = 0x00000009
+ DIF_INSTALLCLASSDRIVERS DI_FUNCTION = 0x0000000A
+ DIF_CALCDISKSPACE DI_FUNCTION = 0x0000000B
+ DIF_DESTROYPRIVATEDATA DI_FUNCTION = 0x0000000C
+ DIF_VALIDATEDRIVER DI_FUNCTION = 0x0000000D
+ DIF_DETECT DI_FUNCTION = 0x0000000F
+ DIF_INSTALLWIZARD DI_FUNCTION = 0x00000010
+ DIF_DESTROYWIZARDDATA DI_FUNCTION = 0x00000011
+ DIF_PROPERTYCHANGE DI_FUNCTION = 0x00000012
+ DIF_ENABLECLASS DI_FUNCTION = 0x00000013
+ DIF_DETECTVERIFY DI_FUNCTION = 0x00000014
+ DIF_INSTALLDEVICEFILES DI_FUNCTION = 0x00000015
+ DIF_UNREMOVE DI_FUNCTION = 0x00000016
+ DIF_SELECTBESTCOMPATDRV DI_FUNCTION = 0x00000017
+ DIF_ALLOW_INSTALL DI_FUNCTION = 0x00000018
+ DIF_REGISTERDEVICE DI_FUNCTION = 0x00000019
+ DIF_NEWDEVICEWIZARD_PRESELECT DI_FUNCTION = 0x0000001A
+ DIF_NEWDEVICEWIZARD_SELECT DI_FUNCTION = 0x0000001B
+ DIF_NEWDEVICEWIZARD_PREANALYZE DI_FUNCTION = 0x0000001C
+ DIF_NEWDEVICEWIZARD_POSTANALYZE DI_FUNCTION = 0x0000001D
+ DIF_NEWDEVICEWIZARD_FINISHINSTALL DI_FUNCTION = 0x0000001E
+ DIF_UNUSED1 DI_FUNCTION = 0x0000001F
+ DIF_INSTALLINTERFACES DI_FUNCTION = 0x00000020
+ DIF_DETECTCANCEL DI_FUNCTION = 0x00000021
+ DIF_REGISTER_COINSTALLERS DI_FUNCTION = 0x00000022
+ DIF_ADDPROPERTYPAGE_ADVANCED DI_FUNCTION = 0x00000023
+ DIF_ADDPROPERTYPAGE_BASIC DI_FUNCTION = 0x00000024
+ DIF_TROUBLESHOOTER DI_FUNCTION = 0x00000026
+ DIF_POWERMESSAGEWAKE DI_FUNCTION = 0x00000027
+ DIF_ADDREMOTEPROPERTYPAGE_ADVANCED DI_FUNCTION = 0x00000028
+ DIF_UPDATEDRIVER_UI DI_FUNCTION = 0x00000029
+ DIF_FINISHINSTALL_ACTION DI_FUNCTION = 0x0000002A
+)
+
+// SP_CLASSINSTALL_HEADER is the first member of any class install parameters structure. It contains the device installation request code that defines the format of the rest of the install parameters structure.
+type SP_CLASSINSTALL_HEADER struct {
+ Size uint32
+ InstallFunction DI_FUNCTION
+}
diff --git a/setupapi/zsetupapi_windows.go b/setupapi/zsetupapi_windows.go
index a569219..d09c8dd 100644
--- a/setupapi/zsetupapi_windows.go
+++ b/setupapi/zsetupapi_windows.go
@@ -46,6 +46,8 @@ var (
procSetupDiOpenDevRegKey = modsetupapi.NewProc("SetupDiOpenDevRegKey")
procSetupDiGetDeviceInstallParamsW = modsetupapi.NewProc("SetupDiGetDeviceInstallParamsW")
procSetupDiSetDeviceInstallParamsW = modsetupapi.NewProc("SetupDiSetDeviceInstallParamsW")
+ procSetupDiGetClassInstallParamsW = modsetupapi.NewProc("SetupDiGetClassInstallParamsW")
+ procSetupDiSetClassInstallParamsW = modsetupapi.NewProc("SetupDiSetClassInstallParamsW")
)
func setupDiGetClassDevsEx(ClassGUID *windows.GUID, Enumerator *uint16, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName *uint16, reserved uintptr) (handle DevInfo, err error) {
@@ -133,3 +135,27 @@ func setupDiSetDeviceInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEV
}
return
}
+
+func SetupDiGetClassInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, ClassInstallParams *SP_CLASSINSTALL_HEADER, ClassInstallParamsSize uint32, RequiredSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procSetupDiGetClassInstallParamsW.Addr(), 5, uintptr(DeviceInfoSet), uintptr(unsafe.Pointer(DeviceInfoData)), uintptr(unsafe.Pointer(ClassInstallParams)), uintptr(ClassInstallParamsSize), uintptr(unsafe.Pointer(RequiredSize)), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func SetupDiSetClassInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, ClassInstallParams *SP_CLASSINSTALL_HEADER, ClassInstallParamsSize uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procSetupDiSetClassInstallParamsW.Addr(), 4, uintptr(DeviceInfoSet), uintptr(unsafe.Pointer(DeviceInfoData)), uintptr(unsafe.Pointer(ClassInstallParams)), uintptr(ClassInstallParamsSize), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}