setupapi: Merge _SP_DEVINSTALL_PARAMS and DevInstallParams
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
05d25fd1b7
commit
bd963497da
@ -332,19 +332,14 @@ func (deviceInfoSet DevInfo) SetDeviceRegistryProperty(deviceInfoData *DevInfoDa
|
|||||||
return SetupDiSetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property, propertyBuffers)
|
return SetupDiSetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property, propertyBuffers)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *_SP_DEVINSTALL_PARAMS) (err error) = setupapi.SetupDiGetDeviceInstallParamsW
|
//sys setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) = setupapi.SetupDiGetDeviceInstallParamsW
|
||||||
|
|
||||||
// SetupDiGetDeviceInstallParams function retrieves device installation parameters for a device information set or a particular device information element.
|
// SetupDiGetDeviceInstallParams function retrieves device installation parameters for a device information set or a particular device information element.
|
||||||
func SetupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (deviceInstallParams *DevInstallParams, err error) {
|
func SetupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (*DevInstallParams, error) {
|
||||||
var _data _SP_DEVINSTALL_PARAMS
|
params := &DevInstallParams{}
|
||||||
_data.Size = uint32(unsafe.Sizeof(_data))
|
params.size = uint32(unsafe.Sizeof(*params))
|
||||||
|
|
||||||
err = setupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, &_data)
|
return params, setupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, params)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return _data.toGo(), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element.
|
// GetDeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element.
|
||||||
@ -360,17 +355,7 @@ func (deviceInfoSet DevInfo) GetClassInstallParams(deviceInfoData *DevInfoData,
|
|||||||
return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize)
|
return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys setupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *_SP_DEVINSTALL_PARAMS) (err error) = setupapi.SetupDiSetDeviceInstallParamsW
|
//sys SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) = setupapi.SetupDiSetDeviceInstallParamsW
|
||||||
|
|
||||||
// SetupDiSetDeviceInstallParams function sets device installation parameters for a device information set or a particular device information element.
|
|
||||||
func SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) {
|
|
||||||
_data, err := deviceInstallParams.toWindows()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return setupDiSetDeviceInstallParams(deviceInfoSet, deviceInfoData, _data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDeviceInstallParams member sets device installation parameters for a device information set or a particular device information element.
|
// SetDeviceInstallParams member sets device installation parameters for a device information set or a particular device information element.
|
||||||
func (deviceInfoSet DevInfo) SetDeviceInstallParams(deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) error {
|
func (deviceInfoSet DevInfo) SetDeviceInstallParams(deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) error {
|
||||||
|
@ -361,6 +361,12 @@ func TestSetupDiGetDeviceInstallParams(t *testing.T) {
|
|||||||
t.Errorf("Error calling SetupDiGetDeviceInstallParams: %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceInstallParams: %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params := &DevInstallParams{}
|
||||||
|
params.SetDriverPath("foobar")
|
||||||
|
if params.GetDriverPath() != "foobar" {
|
||||||
|
t.Error("DevInstallParams.(Get|Set)DriverPath() differ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupDiClassNameFromGuidEx(t *testing.T) {
|
func TestSetupDiClassNameFromGuidEx(t *testing.T) {
|
||||||
|
@ -123,8 +123,9 @@ const (
|
|||||||
DIF_FINISHINSTALL_ACTION DI_FUNCTION = 0x0000002A
|
DIF_FINISHINSTALL_ACTION DI_FUNCTION = 0x0000002A
|
||||||
)
|
)
|
||||||
|
|
||||||
type _SP_DEVINSTALL_PARAMS struct {
|
// DevInstallParams is device installation parameters structure (associated with a particular device information element, or globally with a device information set)
|
||||||
Size uint32
|
type DevInstallParams struct {
|
||||||
|
size uint32
|
||||||
Flags DI_FLAGS
|
Flags DI_FLAGS
|
||||||
FlagsEx DI_FLAGSEX
|
FlagsEx DI_FLAGSEX
|
||||||
hwndParent uintptr
|
hwndParent uintptr
|
||||||
@ -133,50 +134,20 @@ type _SP_DEVINSTALL_PARAMS struct {
|
|||||||
FileQueue HSPFILEQ
|
FileQueue HSPFILEQ
|
||||||
_ uintptr
|
_ uintptr
|
||||||
_ uint32
|
_ uint32
|
||||||
DriverPath [windows.MAX_PATH]uint16
|
driverPath [windows.MAX_PATH]uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_data *_SP_DEVINSTALL_PARAMS) toGo() *DevInstallParams {
|
func (params *DevInstallParams) GetDriverPath() string {
|
||||||
return &DevInstallParams{
|
return windows.UTF16ToString(params.driverPath[:])
|
||||||
Flags: _data.Flags,
|
|
||||||
FlagsEx: _data.FlagsEx,
|
|
||||||
hwndParent: _data.hwndParent,
|
|
||||||
InstallMsgHandler: _data.InstallMsgHandler,
|
|
||||||
InstallMsgHandlerContext: _data.InstallMsgHandlerContext,
|
|
||||||
FileQueue: _data.FileQueue,
|
|
||||||
DriverPath: windows.UTF16ToString(_data.DriverPath[:]),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DevInstallParams is device installation parameters structure (associated with a particular device information element, or globally with a device information set)
|
func (params *DevInstallParams) SetDriverPath(driverPath string) error {
|
||||||
type DevInstallParams struct {
|
str, err := syscall.UTF16FromString(driverPath)
|
||||||
Flags DI_FLAGS
|
|
||||||
FlagsEx DI_FLAGSEX
|
|
||||||
hwndParent uintptr
|
|
||||||
InstallMsgHandler uintptr
|
|
||||||
InstallMsgHandlerContext uintptr
|
|
||||||
FileQueue HSPFILEQ
|
|
||||||
DriverPath string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (DeviceInstallParams *DevInstallParams) toWindows() (_data *_SP_DEVINSTALL_PARAMS, err error) {
|
|
||||||
_data = &_SP_DEVINSTALL_PARAMS{
|
|
||||||
Flags: DeviceInstallParams.Flags,
|
|
||||||
FlagsEx: DeviceInstallParams.FlagsEx,
|
|
||||||
hwndParent: DeviceInstallParams.hwndParent,
|
|
||||||
InstallMsgHandler: DeviceInstallParams.InstallMsgHandler,
|
|
||||||
InstallMsgHandlerContext: DeviceInstallParams.InstallMsgHandlerContext,
|
|
||||||
FileQueue: DeviceInstallParams.FileQueue,
|
|
||||||
}
|
|
||||||
_data.Size = uint32(unsafe.Sizeof(*_data))
|
|
||||||
|
|
||||||
driverPathUTF16, err := syscall.UTF16FromString(DeviceInstallParams.DriverPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
copy(_data.DriverPath[:], driverPathUTF16)
|
copy(params.driverPath[:], str)
|
||||||
|
return nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DI_FLAGS is SP_DEVINSTALL_PARAMS.Flags values
|
// DI_FLAGS is SP_DEVINSTALL_PARAMS.Flags values
|
||||||
|
@ -273,7 +273,7 @@ func setupDiSetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *Dev
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *_SP_DEVINSTALL_PARAMS) (err error) {
|
func setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procSetupDiGetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams)))
|
r1, _, e1 := syscall.Syscall(procSetupDiGetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams)))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
@ -297,7 +297,7 @@ func SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *_SP_DEVINSTALL_PARAMS) (err error) {
|
func SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procSetupDiSetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams)))
|
r1, _, e1 := syscall.Syscall(procSetupDiSetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams)))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user