diff options
author | Simon Rozman <simon@rozman.si> | 2019-05-22 19:31:52 +0200 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-05-22 19:31:52 +0200 |
commit | dc9bbec9dbca1daff8265b6e6da6b36185e74660 (patch) | |
tree | 937159ea8cdc51fd4f0486630ca2a24ed47fabff /tun/wintun/setupapi | |
parent | a6dbe4f4754de333a7ab4df6549d681edbb297fd (diff) |
setupapi: trim "Get" from getters
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun/wintun/setupapi')
-rw-r--r-- | tun/wintun/setupapi/setupapi_windows.go | 28 | ||||
-rw-r--r-- | tun/wintun/setupapi/setupapi_windows_test.go | 40 | ||||
-rw-r--r-- | tun/wintun/setupapi/types_windows.go | 24 |
3 files changed, 46 insertions, 46 deletions
diff --git a/tun/wintun/setupapi/setupapi_windows.go b/tun/wintun/setupapi/setupapi_windows.go index 621d12b..2148a67 100644 --- a/tun/wintun/setupapi/setupapi_windows.go +++ b/tun/wintun/setupapi/setupapi_windows.go @@ -40,8 +40,8 @@ func SetupDiGetDeviceInfoListDetail(deviceInfoSet DevInfo) (deviceInfoSetDetailD return data, setupDiGetDeviceInfoListDetail(deviceInfoSet, data) } -// GetDeviceInfoListDetail method retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name. -func (deviceInfoSet DevInfo) GetDeviceInfoListDetail() (*DevInfoListDetailData, error) { +// DeviceInfoListDetail method retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name. +func (deviceInfoSet DevInfo) DeviceInfoListDetail() (*DevInfoListDetailData, error) { return SetupDiGetDeviceInfoListDetail(deviceInfoSet) } @@ -135,8 +135,8 @@ func SetupDiGetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData return data, setupDiGetSelectedDriver(deviceInfoSet, deviceInfoData, data) } -// GetSelectedDriver method retrieves the selected driver for a device information set or a particular device information element. -func (deviceInfoSet DevInfo) GetSelectedDriver(deviceInfoData *DevInfoData) (*DrvInfoData, error) { +// SelectedDriver method retrieves the selected driver for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) SelectedDriver(deviceInfoData *DevInfoData) (*DrvInfoData, error) { return SetupDiGetSelectedDriver(deviceInfoSet, deviceInfoData) } @@ -181,8 +181,8 @@ func SetupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoDa return nil, err } -// GetDriverInfoDetail method retrieves driver information detail for a device information set or a particular device information element in the device information set. -func (deviceInfoSet DevInfo) GetDriverInfoDetail(deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (*DrvInfoDetailData, error) { +// DriverInfoDetail method retrieves driver information detail for a device information set or a particular device information element in the device information set. +func (deviceInfoSet DevInfo) DriverInfoDetail(deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (*DrvInfoDetailData, error) { return SetupDiGetDriverInfoDetail(deviceInfoSet, deviceInfoData, driverInfoData) } @@ -323,8 +323,8 @@ func wcslen(str []uint16) int { return len(str) } -// GetDeviceRegistryProperty method retrieves a specified Plug and Play device property. -func (deviceInfoSet DevInfo) GetDeviceRegistryProperty(deviceInfoData *DevInfoData, property SPDRP) (interface{}, error) { +// DeviceRegistryProperty method retrieves a specified Plug and Play device property. +func (deviceInfoSet DevInfo) DeviceRegistryProperty(deviceInfoData *DevInfoData, property SPDRP) (interface{}, error) { return SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property) } @@ -360,16 +360,16 @@ func SetupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInf return params, setupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, params) } -// GetDeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element. -func (deviceInfoSet DevInfo) GetDeviceInstallParams(deviceInfoData *DevInfoData) (*DevInstallParams, error) { +// DeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) DeviceInstallParams(deviceInfoData *DevInfoData) (*DevInstallParams, error) { return SetupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData) } // SetupDiGetClassInstallParams function retrieves class installation parameters for a device information set or a particular device information element. //sys SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) (err error) = setupapi.SetupDiGetClassInstallParamsW -// GetClassInstallParams method retrieves class installation parameters for a device information set or a particular device information element. -func (deviceInfoSet DevInfo) GetClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) error { +// ClassInstallParams method retrieves class installation parameters for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) ClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) error { return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize) } @@ -460,8 +460,8 @@ func SetupDiGetSelectedDevice(deviceInfoSet DevInfo) (*DevInfoData, error) { return data, setupDiGetSelectedDevice(deviceInfoSet, data) } -// GetSelectedDevice method retrieves the selected device information element in a device information set. -func (deviceInfoSet DevInfo) GetSelectedDevice() (*DevInfoData, error) { +// SelectedDevice method retrieves the selected device information element in a device information set. +func (deviceInfoSet DevInfo) SelectedDevice() (*DevInfoData, error) { return SetupDiGetSelectedDevice(deviceInfoSet) } diff --git a/tun/wintun/setupapi/setupapi_windows_test.go b/tun/wintun/setupapi/setupapi_windows_test.go index d5443ff..ede1078 100644 --- a/tun/wintun/setupapi/setupapi_windows_test.go +++ b/tun/wintun/setupapi/setupapi_windows_test.go @@ -52,7 +52,7 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) { } defer devInfoList.Close() - data, err := devInfoList.GetDeviceInfoListDetail() + data, err := devInfoList.DeviceInfoListDetail() if err != nil { t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error()) } else { @@ -64,7 +64,7 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) { t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine handle") } - if data.GetRemoteMachineName() != "" { + if data.RemoteMachineName() != "" { t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name") } } @@ -75,7 +75,7 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) { } defer devInfoList.Close() - data, err = devInfoList.GetDeviceInfoListDetail() + data, err = devInfoList.DeviceInfoListDetail() if err != nil { t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error()) } else { @@ -87,14 +87,14 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) { t.Error("SetupDiGetDeviceInfoListDetail returned NULL remote machine handle") } - if data.GetRemoteMachineName() != computerName { + if data.RemoteMachineName() != computerName { t.Error("SetupDiGetDeviceInfoListDetail returned different remote machine name") } } data = &DevInfoListDetailData{} data.SetRemoteMachineName("foobar") - if data.GetRemoteMachineName() != "foobar" { + if data.RemoteMachineName() != "foobar" { t.Error("DevInfoListDetailData.(Get|Set)RemoteMachineName() differ") } } @@ -210,7 +210,7 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) { selectedDriverData = driverData } - driverDetailData, err := devInfoList.GetDriverInfoDetail(deviceData, driverData) + driverDetailData, err := devInfoList.DriverInfoDetail(deviceData, driverData) if err != nil { t.Errorf("Error calling SetupDiGetDriverInfoDetail: %s", err.Error()) } @@ -218,10 +218,10 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) { if driverDetailData.IsCompatible("foobar-aab6e3a4-144e-4786-88d3-6cec361e1edd") { t.Error("Invalid HWID compatibitlity reported") } - if !driverDetailData.IsCompatible(strings.ToUpper(driverDetailData.GetHardwareID())) { + if !driverDetailData.IsCompatible(strings.ToUpper(driverDetailData.HardwareID())) { t.Error("HWID compatibitlity missed") } - a := driverDetailData.GetCompatIDs() + a := driverDetailData.CompatIDs() for k := range a { if !driverDetailData.IsCompatible(strings.ToUpper(a[k])) { t.Error("HWID compatibitlity missed") @@ -229,7 +229,7 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) { } } - selectedDriverData2, err := devInfoList.GetSelectedDriver(deviceData) + selectedDriverData2, err := devInfoList.SelectedDriver(deviceData) if err != nil { t.Errorf("Error calling SetupDiGetSelectedDriver: %s", err.Error()) } else if *selectedDriverData != *selectedDriverData2 { @@ -239,15 +239,15 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) { data := &DrvInfoData{} data.SetDescription("foobar") - if data.GetDescription() != "foobar" { + if data.Description() != "foobar" { t.Error("DrvInfoData.(Get|Set)Description() differ") } data.SetMfgName("foobar") - if data.GetMfgName() != "foobar" { + if data.MfgName() != "foobar" { t.Error("DrvInfoData.(Get|Set)MfgName() differ") } data.SetProviderName("foobar") - if data.GetProviderName() != "foobar" { + if data.ProviderName() != "foobar" { t.Error("DrvInfoData.(Get|Set)ProviderName() differ") } } @@ -311,14 +311,14 @@ func TestSetupDiGetDeviceRegistryProperty(t *testing.T) { continue } - val, err := devInfoList.GetDeviceRegistryProperty(data, SPDRP_CLASS) + val, err := devInfoList.DeviceRegistryProperty(data, SPDRP_CLASS) if err != nil { t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CLASS): %s", err.Error()) } else if class, ok := val.(string); !ok || strings.ToLower(class) != "net" { t.Errorf("SetupDiGetDeviceRegistryProperty(SPDRP_CLASS) should return \"Net\"") } - val, err = devInfoList.GetDeviceRegistryProperty(data, SPDRP_CLASSGUID) + val, err = devInfoList.DeviceRegistryProperty(data, SPDRP_CLASSGUID) if err != nil { t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CLASSGUID): %s", err.Error()) } else if valStr, ok := val.(string); !ok { @@ -332,7 +332,7 @@ func TestSetupDiGetDeviceRegistryProperty(t *testing.T) { } } - val, err = devInfoList.GetDeviceRegistryProperty(data, SPDRP_COMPATIBLEIDS) + val, err = devInfoList.DeviceRegistryProperty(data, SPDRP_COMPATIBLEIDS) if err != nil { // Some devices have no SPDRP_COMPATIBLEIDS. if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_INVALID_DATA { @@ -340,12 +340,12 @@ func TestSetupDiGetDeviceRegistryProperty(t *testing.T) { } } - val, err = devInfoList.GetDeviceRegistryProperty(data, SPDRP_CONFIGFLAGS) + val, err = devInfoList.DeviceRegistryProperty(data, SPDRP_CONFIGFLAGS) if err != nil { t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CONFIGFLAGS): %s", err.Error()) } - val, err = devInfoList.GetDeviceRegistryProperty(data, SPDRP_DEVICE_POWER_DATA) + val, err = devInfoList.DeviceRegistryProperty(data, SPDRP_DEVICE_POWER_DATA) if err != nil { t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_DEVICE_POWER_DATA): %s", err.Error()) } @@ -368,7 +368,7 @@ func TestSetupDiGetDeviceInstallParams(t *testing.T) { continue } - _, err = devInfoList.GetDeviceInstallParams(data) + _, err = devInfoList.DeviceInstallParams(data) if err != nil { t.Errorf("Error calling SetupDiGetDeviceInstallParams: %s", err.Error()) } @@ -376,7 +376,7 @@ func TestSetupDiGetDeviceInstallParams(t *testing.T) { params := &DevInstallParams{} params.SetDriverPath("foobar") - if params.GetDriverPath() != "foobar" { + if params.DriverPath() != "foobar" { t.Error("DevInstallParams.(Get|Set)DriverPath() differ") } } @@ -452,7 +452,7 @@ func TestSetupDiGetSelectedDevice(t *testing.T) { t.Errorf("Error calling SetupDiSetSelectedDevice: %s", err.Error()) } - data2, err := devInfoList.GetSelectedDevice() + data2, err := devInfoList.SelectedDevice() if err != nil { t.Errorf("Error calling SetupDiGetSelectedDevice: %s", err.Error()) } else if *data != *data2 { diff --git a/tun/wintun/setupapi/types_windows.go b/tun/wintun/setupapi/types_windows.go index 863bd7b..287ea52 100644 --- a/tun/wintun/setupapi/types_windows.go +++ b/tun/wintun/setupapi/types_windows.go @@ -66,7 +66,7 @@ type DevInfoListDetailData struct { remoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16 } -func (data *DevInfoListDetailData) GetRemoteMachineName() string { +func (data *DevInfoListDetailData) RemoteMachineName() string { return windows.UTF16ToString(data.remoteMachineName[:]) } @@ -138,7 +138,7 @@ type DevInstallParams struct { driverPath [windows.MAX_PATH]uint16 } -func (params *DevInstallParams) GetDriverPath() string { +func (params *DevInstallParams) DriverPath() string { return windows.UTF16ToString(params.driverPath[:]) } @@ -304,7 +304,7 @@ type DrvInfoData struct { DriverVersion uint64 } -func (data *DrvInfoData) GetDescription() string { +func (data *DrvInfoData) Description() string { return windows.UTF16ToString(data.description[:]) } @@ -317,7 +317,7 @@ func (data *DrvInfoData) SetDescription(description string) error { return nil } -func (data *DrvInfoData) GetMfgName() string { +func (data *DrvInfoData) MfgName() string { return windows.UTF16ToString(data.mfgName[:]) } @@ -330,7 +330,7 @@ func (data *DrvInfoData) SetMfgName(mfgName string) error { return nil } -func (data *DrvInfoData) GetProviderName() string { +func (data *DrvInfoData) ProviderName() string { return windows.UTF16ToString(data.providerName[:]) } @@ -382,19 +382,19 @@ type DrvInfoDetailData struct { hardwareID [ANYSIZE_ARRAY]uint16 } -func (data *DrvInfoDetailData) GetSectionName() string { +func (data *DrvInfoDetailData) SectionName() string { return windows.UTF16ToString(data.sectionName[:]) } -func (data *DrvInfoDetailData) GetInfFileName() string { +func (data *DrvInfoDetailData) InfFileName() string { return windows.UTF16ToString(data.infFileName[:]) } -func (data *DrvInfoDetailData) GetDrvDescription() string { +func (data *DrvInfoDetailData) DrvDescription() string { return windows.UTF16ToString(data.drvDescription[:]) } -func (data *DrvInfoDetailData) GetHardwareID() string { +func (data *DrvInfoDetailData) HardwareID() string { if data.compatIDsOffset > 1 { bufW := data.getBuf() return windows.UTF16ToString(bufW[:wcslen(bufW)]) @@ -403,7 +403,7 @@ func (data *DrvInfoDetailData) GetHardwareID() string { return "" } -func (data *DrvInfoDetailData) GetCompatIDs() []string { +func (data *DrvInfoDetailData) CompatIDs() []string { a := make([]string, 0) if data.compatIDsLength > 0 { @@ -434,10 +434,10 @@ func (data *DrvInfoDetailData) getBuf() []uint16 { // IsCompatible method tests if given hardware ID matches the driver or is listed on the compatible ID list. func (data *DrvInfoDetailData) IsCompatible(hwid string) bool { hwidLC := strings.ToLower(hwid) - if strings.ToLower(data.GetHardwareID()) == hwidLC { + if strings.ToLower(data.HardwareID()) == hwidLC { return true } - a := data.GetCompatIDs() + a := data.CompatIDs() for i := range a { if strings.ToLower(a[i]) == hwidLC { return true |