Add support for setupapi.SetupDi(Get|Set)ClassInstallParams()
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
f1d5db6547
commit
a5a1ece32f
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user