}
func (tun *NativeTun) Name() (string, error) {
- return tun.wt.GetInterfaceName()
+ return tun.wt.InterfaceName()
}
func (tun *NativeTun) File() *os.File {
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
}
defer devInfoList.Close()
- data, err := devInfoList.GetDeviceInfoListDetail()
+ data, err := devInfoList.DeviceInfoListDetail()
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
} else {
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine handle")
}
- if data.GetRemoteMachineName() != "" {
+ if data.RemoteMachineName() != "" {
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name")
}
}
}
defer devInfoList.Close()
- data, err = devInfoList.GetDeviceInfoListDetail()
+ data, err = devInfoList.DeviceInfoListDetail()
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
} else {
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")
}
}
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())
}
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")
}
}
- 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 {
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")
}
}
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 {
}
}
- 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 {
}
}
- 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())
}
continue
}
- _, err = devInfoList.GetDeviceInstallParams(data)
+ _, err = devInfoList.DeviceInstallParams(data)
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInstallParams: %s", err.Error())
}
params := &DevInstallParams{}
params.SetDriverPath("foobar")
- if params.GetDriverPath() != "foobar" {
+ if params.DriverPath() != "foobar" {
t.Error("DevInstallParams.(Get|Set)DriverPath() differ")
}
}
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 {
remoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16
}
-func (data *DevInfoListDetailData) GetRemoteMachineName() string {
+func (data *DevInfoListDetailData) RemoteMachineName() string {
return windows.UTF16ToString(data.remoteMachineName[:])
}
driverPath [windows.MAX_PATH]uint16
}
-func (params *DevInstallParams) GetDriverPath() string {
+func (params *DevInstallParams) DriverPath() string {
return windows.UTF16ToString(params.driverPath[:])
}
DriverVersion uint64
}
-func (data *DrvInfoData) GetDescription() string {
+func (data *DrvInfoData) Description() string {
return windows.UTF16ToString(data.description[:])
}
return nil
}
-func (data *DrvInfoData) GetMfgName() string {
+func (data *DrvInfoData) MfgName() string {
return windows.UTF16ToString(data.mfgName[:])
}
return nil
}
-func (data *DrvInfoData) GetProviderName() string {
+func (data *DrvInfoData) ProviderName() string {
return windows.UTF16ToString(data.providerName[:])
}
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)])
return ""
}
-func (data *DrvInfoDetailData) GetCompatIDs() []string {
+func (data *DrvInfoDetailData) CompatIDs() []string {
a := make([]string, 0)
if data.compatIDsLength > 0 {
// 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
//TODO: is there a better way than comparing ifnames?
// Get interface name.
- ifname2, err := wintun.GetInterfaceName()
+ ifname2, err := wintun.InterfaceName()
if err != nil {
continue
}
}
// Get driver info details.
- driverDetailData, err := devInfoList.GetDriverInfoDetail(deviceData, driverData)
+ driverDetailData, err := devInfoList.DriverInfoDetail(deviceData, driverData)
if err != nil {
// Something is wrong with this driver. Skip it.
continue
// Check the driver version first, since the check is trivial and will save us iterating over hardware IDs for any driver versioned prior our best match.
if driverData.IsNewer(driverDate, driverVersion) {
// Get driver info details.
- driverDetailData, err := devInfoList.GetDriverInfoDetail(deviceData, driverData)
+ driverDetailData, err := devInfoList.DriverInfoDetail(deviceData, driverData)
if err != nil {
// Something is wrong with this driver. Skip it.
continue
// checkReboot checks device install parameters if a system reboot is required.
//
func checkReboot(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.DevInfoData) (bool, error) {
- devInstallParams, err := deviceInfoSet.GetDeviceInstallParams(deviceInfoData)
+ devInstallParams, err := deviceInfoSet.DeviceInstallParams(deviceInfoData)
if err != nil {
return false, err
}
}
//
-// GetInterfaceName returns network interface name.
+// InterfaceName returns network interface name.
//
-func (wintun *Wintun) GetInterfaceName() (string, error) {
+func (wintun *Wintun) InterfaceName() (string, error) {
key, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.netRegKeyName(), registry.QUERY_VALUE)
if err != nil {
return "", fmt.Errorf("Network-specific registry key open failed: %v", err)