aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/setupapi/types_windows.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-07 22:35:03 +0100
committerSimon Rozman <simon@rozman.si>2019-02-07 23:50:30 +0100
commitbd963497da908d3910668dab9dab4ac7654a638a (patch)
treeaa723b40561155fff5bdaf9c6d07c9a891c0930c /tun/wintun/setupapi/types_windows.go
parentsetupapi: Merge _SP_DEVINFO_LIST_DETAIL_DATA and DevInfoListDetailData (diff)
downloadwireguard-go-bd963497da908d3910668dab9dab4ac7654a638a.tar.xz
wireguard-go-bd963497da908d3910668dab9dab4ac7654a638a.zip
setupapi: Merge _SP_DEVINSTALL_PARAMS and DevInstallParams
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun/wintun/setupapi/types_windows.go')
-rw-r--r--tun/wintun/setupapi/types_windows.go51
1 files changed, 11 insertions, 40 deletions
diff --git a/tun/wintun/setupapi/types_windows.go b/tun/wintun/setupapi/types_windows.go
index a37fdec..ae60bd0 100644
--- a/tun/wintun/setupapi/types_windows.go
+++ b/tun/wintun/setupapi/types_windows.go
@@ -123,8 +123,9 @@ const (
DIF_FINISHINSTALL_ACTION DI_FUNCTION = 0x0000002A
)
-type _SP_DEVINSTALL_PARAMS struct {
- Size uint32
+// DevInstallParams is device installation parameters structure (associated with a particular device information element, or globally with a device information set)
+type DevInstallParams struct {
+ size uint32
Flags DI_FLAGS
FlagsEx DI_FLAGSEX
hwndParent uintptr
@@ -133,50 +134,20 @@ type _SP_DEVINSTALL_PARAMS struct {
FileQueue HSPFILEQ
_ uintptr
_ uint32
- 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[:]),
- }
+ driverPath [windows.MAX_PATH]uint16
}
-// DevInstallParams is device installation parameters structure (associated with a particular device information element, or globally with a device information set)
-type DevInstallParams struct {
- Flags DI_FLAGS
- FlagsEx DI_FLAGSEX
- hwndParent uintptr
- InstallMsgHandler uintptr
- InstallMsgHandlerContext uintptr
- FileQueue HSPFILEQ
- DriverPath string
+func (params *DevInstallParams) GetDriverPath() string {
+ return windows.UTF16ToString(params.driverPath[:])
}
-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)
+func (params *DevInstallParams) SetDriverPath(driverPath string) error {
+ str, err := syscall.UTF16FromString(driverPath)
if err != nil {
- return
+ return err
}
- copy(_data.DriverPath[:], driverPathUTF16)
-
- return
+ copy(params.driverPath[:], str)
+ return nil
}
// DI_FLAGS is SP_DEVINSTALL_PARAMS.Flags values