setupapi: Move Go<>Windows struct marshaling to types_windows.go
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
99a3b628e9
commit
7b636380e5
@ -41,11 +41,7 @@ func SetupDiGetDeviceInfoListDetail(DeviceInfoSet DevInfo) (DeviceInfoSetDetailD
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return &DevInfoListDetailData{
|
return _data.toGo(), nil
|
||||||
ClassGUID: _data.ClassGUID,
|
|
||||||
RemoteMachineHandle: _data.RemoteMachineHandle,
|
|
||||||
RemoteMachineName: windows.UTF16ToString(_data.RemoteMachineName[:]),
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceInfoListDetail method retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name.
|
// GetDeviceInfoListDetail method retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name.
|
||||||
@ -247,15 +243,7 @@ func SetupDiGetDeviceInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEV
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return &DevInstallParams{
|
return _data.toGo(), nil
|
||||||
Flags: _data.Flags,
|
|
||||||
FlagsEx: _data.FlagsEx,
|
|
||||||
hwndParent: _data.hwndParent,
|
|
||||||
InstallMsgHandler: _data.InstallMsgHandler,
|
|
||||||
InstallMsgHandlerContext: _data.InstallMsgHandlerContext,
|
|
||||||
FileQueue: _data.FileQueue,
|
|
||||||
DriverPath: windows.UTF16ToString(_data.DriverPath[:]),
|
|
||||||
}, 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.
|
||||||
@ -275,23 +263,12 @@ func (DeviceInfoSet DevInfo) GetClassInstallParams(DeviceInfoData *SP_DEVINFO_DA
|
|||||||
|
|
||||||
// SetupDiSetDeviceInstallParams function sets device installation parameters for a device information set or a particular device information element.
|
// SetupDiSetDeviceInstallParams function sets device installation parameters for a device information set or a particular device information element.
|
||||||
func SetupDiSetDeviceInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, DeviceInstallParams *DevInstallParams) (err error) {
|
func SetupDiSetDeviceInstallParams(DeviceInfoSet DevInfo, DeviceInfoData *SP_DEVINFO_DATA, DeviceInstallParams *DevInstallParams) (err error) {
|
||||||
_data := _SP_DEVINSTALL_PARAMS{
|
_data, err := DeviceInstallParams.toWindows()
|
||||||
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
|
||||||
}
|
}
|
||||||
copy(_data.DriverPath[:], driverPathUTF16)
|
|
||||||
|
|
||||||
return setupDiSetDeviceInstallParams(DeviceInfoSet, DeviceInfoData, &_data)
|
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.
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
package setupapi
|
package setupapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,6 +49,14 @@ type _SP_DEVINFO_LIST_DETAIL_DATA struct {
|
|||||||
RemoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16
|
RemoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_data _SP_DEVINFO_LIST_DETAIL_DATA) toGo() *DevInfoListDetailData {
|
||||||
|
return &DevInfoListDetailData{
|
||||||
|
ClassGUID: _data.ClassGUID,
|
||||||
|
RemoteMachineHandle: _data.RemoteMachineHandle,
|
||||||
|
RemoteMachineName: windows.UTF16ToString(_data.RemoteMachineName[:]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DevInfoListDetailData is a structure for detailed information on a device information set (used for SetupDiGetDeviceInfoListDetail which supercedes the functionality of SetupDiGetDeviceInfoListClass).
|
// DevInfoListDetailData is a structure for detailed information on a device information set (used for SetupDiGetDeviceInfoListDetail which supercedes the functionality of SetupDiGetDeviceInfoListClass).
|
||||||
type DevInfoListDetailData struct {
|
type DevInfoListDetailData struct {
|
||||||
ClassGUID windows.GUID
|
ClassGUID windows.GUID
|
||||||
@ -111,6 +122,18 @@ type _SP_DEVINSTALL_PARAMS struct {
|
|||||||
DriverPath [windows.MAX_PATH]uint16
|
DriverPath [windows.MAX_PATH]uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_data _SP_DEVINSTALL_PARAMS) toGo() *DevInstallParams {
|
||||||
|
return &DevInstallParams{
|
||||||
|
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)
|
// DevInstallParams is device installation parameters structure (associated with a particular device information element, or globally with a device information set)
|
||||||
type DevInstallParams struct {
|
type DevInstallParams struct {
|
||||||
Flags DI_FLAGS
|
Flags DI_FLAGS
|
||||||
@ -122,6 +145,26 @@ type DevInstallParams struct {
|
|||||||
DriverPath string
|
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 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
copy(_data.DriverPath[:], driverPathUTF16)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// DI_FLAGS is SP_DEVINSTALL_PARAMS.Flags values
|
// DI_FLAGS is SP_DEVINSTALL_PARAMS.Flags values
|
||||||
type DI_FLAGS uint32
|
type DI_FLAGS uint32
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user