mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 09:15:14 +01:00
setupapi: trim "Get" from getters
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
a6dbe4f475
commit
dc9bbec9db
@ -185,7 +185,7 @@ func (tun *NativeTun) getTUN() (read *os.File, write *os.File, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Name() (string, error) {
|
func (tun *NativeTun) Name() (string, error) {
|
||||||
return tun.wt.GetInterfaceName()
|
return tun.wt.InterfaceName()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) File() *os.File {
|
func (tun *NativeTun) File() *os.File {
|
||||||
|
@ -40,8 +40,8 @@ func SetupDiGetDeviceInfoListDetail(deviceInfoSet DevInfo) (deviceInfoSetDetailD
|
|||||||
return data, setupDiGetDeviceInfoListDetail(deviceInfoSet, data)
|
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.
|
// DeviceInfoListDetail 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) {
|
func (deviceInfoSet DevInfo) DeviceInfoListDetail() (*DevInfoListDetailData, error) {
|
||||||
return SetupDiGetDeviceInfoListDetail(deviceInfoSet)
|
return SetupDiGetDeviceInfoListDetail(deviceInfoSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ func SetupDiGetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData
|
|||||||
return data, setupDiGetSelectedDriver(deviceInfoSet, deviceInfoData, data)
|
return data, setupDiGetSelectedDriver(deviceInfoSet, deviceInfoData, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSelectedDriver method retrieves the selected driver for a device information set or a particular device information element.
|
// SelectedDriver method retrieves the selected driver for a device information set or a particular device information element.
|
||||||
func (deviceInfoSet DevInfo) GetSelectedDriver(deviceInfoData *DevInfoData) (*DrvInfoData, error) {
|
func (deviceInfoSet DevInfo) SelectedDriver(deviceInfoData *DevInfoData) (*DrvInfoData, error) {
|
||||||
return SetupDiGetSelectedDriver(deviceInfoSet, deviceInfoData)
|
return SetupDiGetSelectedDriver(deviceInfoSet, deviceInfoData)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +181,8 @@ func SetupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoDa
|
|||||||
return nil, err
|
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.
|
// 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) GetDriverInfoDetail(deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (*DrvInfoDetailData, error) {
|
func (deviceInfoSet DevInfo) DriverInfoDetail(deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (*DrvInfoDetailData, error) {
|
||||||
return SetupDiGetDriverInfoDetail(deviceInfoSet, deviceInfoData, driverInfoData)
|
return SetupDiGetDriverInfoDetail(deviceInfoSet, deviceInfoData, driverInfoData)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,8 +323,8 @@ func wcslen(str []uint16) int {
|
|||||||
return len(str)
|
return len(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceRegistryProperty method retrieves a specified Plug and Play device property.
|
// DeviceRegistryProperty method retrieves a specified Plug and Play device property.
|
||||||
func (deviceInfoSet DevInfo) GetDeviceRegistryProperty(deviceInfoData *DevInfoData, property SPDRP) (interface{}, error) {
|
func (deviceInfoSet DevInfo) DeviceRegistryProperty(deviceInfoData *DevInfoData, property SPDRP) (interface{}, error) {
|
||||||
return SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property)
|
return SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,16 +360,16 @@ func SetupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInf
|
|||||||
return params, setupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, params)
|
return params, setupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element.
|
// DeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element.
|
||||||
func (deviceInfoSet DevInfo) GetDeviceInstallParams(deviceInfoData *DevInfoData) (*DevInstallParams, error) {
|
func (deviceInfoSet DevInfo) DeviceInstallParams(deviceInfoData *DevInfoData) (*DevInstallParams, error) {
|
||||||
return SetupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData)
|
return SetupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupDiGetClassInstallParams function retrieves class installation parameters for a device information set or a particular device information element.
|
// 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
|
//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.
|
// ClassInstallParams 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 {
|
func (deviceInfoSet DevInfo) ClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) error {
|
||||||
return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize)
|
return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,8 +460,8 @@ func SetupDiGetSelectedDevice(deviceInfoSet DevInfo) (*DevInfoData, error) {
|
|||||||
return data, setupDiGetSelectedDevice(deviceInfoSet, data)
|
return data, setupDiGetSelectedDevice(deviceInfoSet, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSelectedDevice method retrieves the selected device information element in a device information set.
|
// SelectedDevice method retrieves the selected device information element in a device information set.
|
||||||
func (deviceInfoSet DevInfo) GetSelectedDevice() (*DevInfoData, error) {
|
func (deviceInfoSet DevInfo) SelectedDevice() (*DevInfoData, error) {
|
||||||
return SetupDiGetSelectedDevice(deviceInfoSet)
|
return SetupDiGetSelectedDevice(deviceInfoSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer devInfoList.Close()
|
defer devInfoList.Close()
|
||||||
|
|
||||||
data, err := devInfoList.GetDeviceInfoListDetail()
|
data, err := devInfoList.DeviceInfoListDetail()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
|
||||||
} else {
|
} else {
|
||||||
@ -64,7 +64,7 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) {
|
|||||||
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine handle")
|
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine handle")
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.GetRemoteMachineName() != "" {
|
if data.RemoteMachineName() != "" {
|
||||||
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name")
|
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer devInfoList.Close()
|
defer devInfoList.Close()
|
||||||
|
|
||||||
data, err = devInfoList.GetDeviceInfoListDetail()
|
data, err = devInfoList.DeviceInfoListDetail()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
|
||||||
} else {
|
} else {
|
||||||
@ -87,14 +87,14 @@ func TestSetupDiGetDeviceInfoListDetail(t *testing.T) {
|
|||||||
t.Error("SetupDiGetDeviceInfoListDetail returned NULL remote machine handle")
|
t.Error("SetupDiGetDeviceInfoListDetail returned NULL remote machine handle")
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.GetRemoteMachineName() != computerName {
|
if data.RemoteMachineName() != computerName {
|
||||||
t.Error("SetupDiGetDeviceInfoListDetail returned different remote machine name")
|
t.Error("SetupDiGetDeviceInfoListDetail returned different remote machine name")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = &DevInfoListDetailData{}
|
data = &DevInfoListDetailData{}
|
||||||
data.SetRemoteMachineName("foobar")
|
data.SetRemoteMachineName("foobar")
|
||||||
if data.GetRemoteMachineName() != "foobar" {
|
if data.RemoteMachineName() != "foobar" {
|
||||||
t.Error("DevInfoListDetailData.(Get|Set)RemoteMachineName() differ")
|
t.Error("DevInfoListDetailData.(Get|Set)RemoteMachineName() differ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) {
|
|||||||
selectedDriverData = driverData
|
selectedDriverData = driverData
|
||||||
}
|
}
|
||||||
|
|
||||||
driverDetailData, err := devInfoList.GetDriverInfoDetail(deviceData, driverData)
|
driverDetailData, err := devInfoList.DriverInfoDetail(deviceData, driverData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDriverInfoDetail: %s", err.Error())
|
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") {
|
if driverDetailData.IsCompatible("foobar-aab6e3a4-144e-4786-88d3-6cec361e1edd") {
|
||||||
t.Error("Invalid HWID compatibitlity reported")
|
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")
|
t.Error("HWID compatibitlity missed")
|
||||||
}
|
}
|
||||||
a := driverDetailData.GetCompatIDs()
|
a := driverDetailData.CompatIDs()
|
||||||
for k := range a {
|
for k := range a {
|
||||||
if !driverDetailData.IsCompatible(strings.ToUpper(a[k])) {
|
if !driverDetailData.IsCompatible(strings.ToUpper(a[k])) {
|
||||||
t.Error("HWID compatibitlity missed")
|
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 {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetSelectedDriver: %s", err.Error())
|
t.Errorf("Error calling SetupDiGetSelectedDriver: %s", err.Error())
|
||||||
} else if *selectedDriverData != *selectedDriverData2 {
|
} else if *selectedDriverData != *selectedDriverData2 {
|
||||||
@ -239,15 +239,15 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) {
|
|||||||
|
|
||||||
data := &DrvInfoData{}
|
data := &DrvInfoData{}
|
||||||
data.SetDescription("foobar")
|
data.SetDescription("foobar")
|
||||||
if data.GetDescription() != "foobar" {
|
if data.Description() != "foobar" {
|
||||||
t.Error("DrvInfoData.(Get|Set)Description() differ")
|
t.Error("DrvInfoData.(Get|Set)Description() differ")
|
||||||
}
|
}
|
||||||
data.SetMfgName("foobar")
|
data.SetMfgName("foobar")
|
||||||
if data.GetMfgName() != "foobar" {
|
if data.MfgName() != "foobar" {
|
||||||
t.Error("DrvInfoData.(Get|Set)MfgName() differ")
|
t.Error("DrvInfoData.(Get|Set)MfgName() differ")
|
||||||
}
|
}
|
||||||
data.SetProviderName("foobar")
|
data.SetProviderName("foobar")
|
||||||
if data.GetProviderName() != "foobar" {
|
if data.ProviderName() != "foobar" {
|
||||||
t.Error("DrvInfoData.(Get|Set)ProviderName() differ")
|
t.Error("DrvInfoData.(Get|Set)ProviderName() differ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,14 +311,14 @@ func TestSetupDiGetDeviceRegistryProperty(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val, err := devInfoList.GetDeviceRegistryProperty(data, SPDRP_CLASS)
|
val, err := devInfoList.DeviceRegistryProperty(data, SPDRP_CLASS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CLASS): %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CLASS): %s", err.Error())
|
||||||
} else if class, ok := val.(string); !ok || strings.ToLower(class) != "net" {
|
} else if class, ok := val.(string); !ok || strings.ToLower(class) != "net" {
|
||||||
t.Errorf("SetupDiGetDeviceRegistryProperty(SPDRP_CLASS) should return \"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 {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CLASSGUID): %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CLASSGUID): %s", err.Error())
|
||||||
} else if valStr, ok := val.(string); !ok {
|
} 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 {
|
if err != nil {
|
||||||
// Some devices have no SPDRP_COMPATIBLEIDS.
|
// Some devices have no SPDRP_COMPATIBLEIDS.
|
||||||
if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_INVALID_DATA {
|
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 {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_CONFIGFLAGS): %s", err.Error())
|
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 {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_DEVICE_POWER_DATA): %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_DEVICE_POWER_DATA): %s", err.Error())
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ func TestSetupDiGetDeviceInstallParams(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = devInfoList.GetDeviceInstallParams(data)
|
_, err = devInfoList.DeviceInstallParams(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetDeviceInstallParams: %s", err.Error())
|
t.Errorf("Error calling SetupDiGetDeviceInstallParams: %s", err.Error())
|
||||||
}
|
}
|
||||||
@ -376,7 +376,7 @@ func TestSetupDiGetDeviceInstallParams(t *testing.T) {
|
|||||||
|
|
||||||
params := &DevInstallParams{}
|
params := &DevInstallParams{}
|
||||||
params.SetDriverPath("foobar")
|
params.SetDriverPath("foobar")
|
||||||
if params.GetDriverPath() != "foobar" {
|
if params.DriverPath() != "foobar" {
|
||||||
t.Error("DevInstallParams.(Get|Set)DriverPath() differ")
|
t.Error("DevInstallParams.(Get|Set)DriverPath() differ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,7 +452,7 @@ func TestSetupDiGetSelectedDevice(t *testing.T) {
|
|||||||
t.Errorf("Error calling SetupDiSetSelectedDevice: %s", err.Error())
|
t.Errorf("Error calling SetupDiSetSelectedDevice: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
data2, err := devInfoList.GetSelectedDevice()
|
data2, err := devInfoList.SelectedDevice()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error calling SetupDiGetSelectedDevice: %s", err.Error())
|
t.Errorf("Error calling SetupDiGetSelectedDevice: %s", err.Error())
|
||||||
} else if *data != *data2 {
|
} else if *data != *data2 {
|
||||||
|
@ -66,7 +66,7 @@ type DevInfoListDetailData struct {
|
|||||||
remoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16
|
remoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DevInfoListDetailData) GetRemoteMachineName() string {
|
func (data *DevInfoListDetailData) RemoteMachineName() string {
|
||||||
return windows.UTF16ToString(data.remoteMachineName[:])
|
return windows.UTF16ToString(data.remoteMachineName[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ type DevInstallParams struct {
|
|||||||
driverPath [windows.MAX_PATH]uint16
|
driverPath [windows.MAX_PATH]uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (params *DevInstallParams) GetDriverPath() string {
|
func (params *DevInstallParams) DriverPath() string {
|
||||||
return windows.UTF16ToString(params.driverPath[:])
|
return windows.UTF16ToString(params.driverPath[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ type DrvInfoData struct {
|
|||||||
DriverVersion uint64
|
DriverVersion uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoData) GetDescription() string {
|
func (data *DrvInfoData) Description() string {
|
||||||
return windows.UTF16ToString(data.description[:])
|
return windows.UTF16ToString(data.description[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ func (data *DrvInfoData) SetDescription(description string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoData) GetMfgName() string {
|
func (data *DrvInfoData) MfgName() string {
|
||||||
return windows.UTF16ToString(data.mfgName[:])
|
return windows.UTF16ToString(data.mfgName[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ func (data *DrvInfoData) SetMfgName(mfgName string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoData) GetProviderName() string {
|
func (data *DrvInfoData) ProviderName() string {
|
||||||
return windows.UTF16ToString(data.providerName[:])
|
return windows.UTF16ToString(data.providerName[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,19 +382,19 @@ type DrvInfoDetailData struct {
|
|||||||
hardwareID [ANYSIZE_ARRAY]uint16
|
hardwareID [ANYSIZE_ARRAY]uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoDetailData) GetSectionName() string {
|
func (data *DrvInfoDetailData) SectionName() string {
|
||||||
return windows.UTF16ToString(data.sectionName[:])
|
return windows.UTF16ToString(data.sectionName[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoDetailData) GetInfFileName() string {
|
func (data *DrvInfoDetailData) InfFileName() string {
|
||||||
return windows.UTF16ToString(data.infFileName[:])
|
return windows.UTF16ToString(data.infFileName[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoDetailData) GetDrvDescription() string {
|
func (data *DrvInfoDetailData) DrvDescription() string {
|
||||||
return windows.UTF16ToString(data.drvDescription[:])
|
return windows.UTF16ToString(data.drvDescription[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoDetailData) GetHardwareID() string {
|
func (data *DrvInfoDetailData) HardwareID() string {
|
||||||
if data.compatIDsOffset > 1 {
|
if data.compatIDsOffset > 1 {
|
||||||
bufW := data.getBuf()
|
bufW := data.getBuf()
|
||||||
return windows.UTF16ToString(bufW[:wcslen(bufW)])
|
return windows.UTF16ToString(bufW[:wcslen(bufW)])
|
||||||
@ -403,7 +403,7 @@ func (data *DrvInfoDetailData) GetHardwareID() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *DrvInfoDetailData) GetCompatIDs() []string {
|
func (data *DrvInfoDetailData) CompatIDs() []string {
|
||||||
a := make([]string, 0)
|
a := make([]string, 0)
|
||||||
|
|
||||||
if data.compatIDsLength > 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.
|
// 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 {
|
func (data *DrvInfoDetailData) IsCompatible(hwid string) bool {
|
||||||
hwidLC := strings.ToLower(hwid)
|
hwidLC := strings.ToLower(hwid)
|
||||||
if strings.ToLower(data.GetHardwareID()) == hwidLC {
|
if strings.ToLower(data.HardwareID()) == hwidLC {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
a := data.GetCompatIDs()
|
a := data.CompatIDs()
|
||||||
for i := range a {
|
for i := range a {
|
||||||
if strings.ToLower(a[i]) == hwidLC {
|
if strings.ToLower(a[i]) == hwidLC {
|
||||||
return true
|
return true
|
||||||
|
@ -125,7 +125,7 @@ func GetInterface(ifname string, hwndParent uintptr) (*Wintun, error) {
|
|||||||
|
|
||||||
//TODO: is there a better way than comparing ifnames?
|
//TODO: is there a better way than comparing ifnames?
|
||||||
// Get interface name.
|
// Get interface name.
|
||||||
ifname2, err := wintun.GetInterfaceName()
|
ifname2, err := wintun.InterfaceName()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ func GetInterface(ifname string, hwndParent uintptr) (*Wintun, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get driver info details.
|
// Get driver info details.
|
||||||
driverDetailData, err := devInfoList.GetDriverInfoDetail(deviceData, driverData)
|
driverDetailData, err := devInfoList.DriverInfoDetail(deviceData, driverData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Something is wrong with this driver. Skip it.
|
// Something is wrong with this driver. Skip it.
|
||||||
continue
|
continue
|
||||||
@ -241,7 +241,7 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err
|
|||||||
// 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.
|
// 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) {
|
if driverData.IsNewer(driverDate, driverVersion) {
|
||||||
// Get driver info details.
|
// Get driver info details.
|
||||||
driverDetailData, err := devInfoList.GetDriverInfoDetail(deviceData, driverData)
|
driverDetailData, err := devInfoList.DriverInfoDetail(deviceData, driverData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Something is wrong with this driver. Skip it.
|
// Something is wrong with this driver. Skip it.
|
||||||
continue
|
continue
|
||||||
@ -474,7 +474,7 @@ func (wintun *Wintun) DeleteInterface(hwndParent uintptr) (bool, bool, error) {
|
|||||||
// checkReboot checks device install parameters if a system reboot is required.
|
// checkReboot checks device install parameters if a system reboot is required.
|
||||||
//
|
//
|
||||||
func checkReboot(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.DevInfoData) (bool, error) {
|
func checkReboot(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.DevInfoData) (bool, error) {
|
||||||
devInstallParams, err := deviceInfoSet.GetDeviceInstallParams(deviceInfoData)
|
devInstallParams, err := deviceInfoSet.DeviceInstallParams(deviceInfoData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -487,9 +487,9 @@ func checkReboot(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.DevInf
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// 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)
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.netRegKeyName(), registry.QUERY_VALUE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Network-specific registry key open failed: %v", err)
|
return "", fmt.Errorf("Network-specific registry key open failed: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user