diff options
author | Simon Rozman <simon@rozman.si> | 2019-02-07 22:23:03 +0100 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-02-07 23:49:50 +0100 |
commit | 05d25fd1b71aaad8f542999851d472d63b724ae2 (patch) | |
tree | 4d9d20b7e5ed80a154d8c522b4338e267c58de84 /tun/wintun/setupapi/types_windows.go | |
parent | setupapi: Rename SP_DEVINFO_DATA to DevInfoData (diff) | |
download | wireguard-go-05d25fd1b71aaad8f542999851d472d63b724ae2.tar.xz wireguard-go-05d25fd1b71aaad8f542999851d472d63b724ae2.zip |
setupapi: Merge _SP_DEVINFO_LIST_DETAIL_DATA and DevInfoListDetailData
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.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/tun/wintun/setupapi/types_windows.go b/tun/wintun/setupapi/types_windows.go index 23bee25..a37fdec 100644 --- a/tun/wintun/setupapi/types_windows.go +++ b/tun/wintun/setupapi/types_windows.go @@ -57,26 +57,25 @@ type DevInfoData struct { _ uintptr } -type _SP_DEVINFO_LIST_DETAIL_DATA struct { - Size uint32 +// DevInfoListDetailData is a structure for detailed information on a device information set (used for SetupDiGetDeviceInfoListDetail which supercedes the functionality of SetupDiGetDeviceInfoListClass). +type DevInfoListDetailData struct { + size uint32 ClassGUID windows.GUID RemoteMachineHandle windows.Handle - 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[:]), - } +func (data *DevInfoListDetailData) GetRemoteMachineName() string { + return 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). -type DevInfoListDetailData struct { - ClassGUID windows.GUID - RemoteMachineHandle windows.Handle - RemoteMachineName string +func (data *DevInfoListDetailData) SetRemoteMachineName(remoteMachineName string) error { + str, err := syscall.UTF16FromString(remoteMachineName) + if err != nil { + return err + } + copy(data.remoteMachineName[:], str) + return nil } // DI_FUNCTION is function type for device installer |