summaryrefslogtreecommitdiffhomepage
path: root/tun/wintun
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-03-04 13:25:18 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-04 16:37:11 +0100
commit9041d38e2d99aa02c8c318c10b5e57a005c65a7d (patch)
treeed3fc77bbb57b13891b0c1d98412d64b6b09bcbe /tun/wintun
parentcddfd9a0d8d8c2dcdd778aa46ed32228d8f6cb93 (diff)
Simplify reading NetCfgInstanceId from registry
As querying non-existing registry value and reading non-existing registry string value both return ERROR_FILE_NOT_FOUND, we can use later only. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun/wintun')
-rw-r--r--tun/wintun/wintun_windows.go10
1 files changed, 2 insertions, 8 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index 875ca35..bb44963 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -386,8 +386,8 @@ func getInterfaceId(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.Dev
defer key.Close()
for {
- // Query the NetCfgInstanceId value. Using get_reg_string() right on might clutter the output with error messages while the registry is still being populated.
- _, _, err = key.GetValue("NetCfgInstanceId", nil)
+ // Read the NetCfgInstanceId value.
+ value, err := getRegStringValue(key, "NetCfgInstanceId")
if err != nil {
if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_FILE_NOT_FOUND {
numAttempts--
@@ -399,12 +399,6 @@ func getInterfaceId(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.Dev
}
}
- return nil, errors.New("RegQueryValueEx(\"NetCfgInstanceId\") failed: " + err.Error())
- }
-
- // Read the NetCfgInstanceId value now.
- value, err := getRegStringValue(key, "NetCfgInstanceId")
- if err != nil {
return nil, errors.New("RegQueryStringValue(\"NetCfgInstanceId\") failed: " + err.Error())
}