summaryrefslogtreecommitdiffhomepage
path: root/tun
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-08-20 15:48:08 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-20 16:06:55 +0200
commitef23100a4f86948e0466dce980d8604ad95f13df (patch)
tree0a3554aa60437783846bce9c101a185203d162cc /tun
parenteb786cd7c11335708133624eda678dfad54048d6 (diff)
wintun: set friendly a bit better
This is still wrong, but NETSETUPPKEY_Driver_FriendlyName seems a bit tricky to use.
Diffstat (limited to 'tun')
-rw-r--r--tun/wintun/wintun_windows.go32
1 files changed, 10 insertions, 22 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index 4bf17e6..35ec89e 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -316,6 +316,12 @@ func CreateInterface(description string, requestedGUID *windows.GUID) (wintun *W
}
rebootRequired = checkReboot(devInfoList, deviceData)
+ err = devInfoList.SetDeviceRegistryPropertyString(deviceData, setupapi.SPDRP_DEVICEDESC, deviceTypeName)
+ if err != nil {
+ err = fmt.Errorf("SetDeviceRegistryPropertyString(SPDRP_DEVICEDESC) failed: %v", err)
+ return
+ }
+
// DIF_INSTALLDEVICE returns almost immediately, while the device installation
// continues in the background. It might take a while, before all registry
// keys and values are populated.
@@ -342,24 +348,6 @@ func CreateInterface(description string, requestedGUID *windows.GUID) (wintun *W
return
}
- // Name ourselves.
- deviceRegKey, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.deviceRegKeyName(), registry.SET_VALUE)
- if err != nil {
- err = fmt.Errorf("Device-level registry key open failed: %v", err)
- return
- }
- defer deviceRegKey.Close()
- err = deviceRegKey.SetStringValue("DeviceDesc", deviceTypeName)
- if err != nil {
- err = fmt.Errorf("SetStringValue(DeviceDesc) failed: %v", err)
- return
- }
- err = deviceRegKey.SetStringValue("FriendlyName", deviceTypeName)
- if err != nil {
- err = fmt.Errorf("SetStringValue(FriendlyName) failed: %v", err)
- return
- }
-
// Wait for network registry key to emerge and populate.
netRegKey, err := registryEx.OpenKeyWait(
registry.LOCAL_MACHINE,
@@ -572,23 +560,23 @@ func (wintun *Wintun) SetInterfaceName(ifname string) error {
if err != nil {
return err
}
+
+ // TODO: This only sometimes works.
deviceRegKey, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.deviceRegKeyName(), registry.SET_VALUE)
if err != nil {
return fmt.Errorf("Device-level registry key open failed: %v", err)
}
defer deviceRegKey.Close()
- err = deviceRegKey.SetStringValue("DeviceDesc", deviceTypeName)
- if err != nil {
- return err
- }
err = deviceRegKey.SetStringValue("FriendlyName", deviceTypeName)
if err != nil {
return err
}
+
// We have to tell the various runtime COM services about the new name too. We ignore the
// error because netshell isn't available on servercore.
// TODO: netsh.exe falls back to NciSetConnection in this case. If somebody complains, maybe
// we should do the same.
+ // TODO: This only sometimes works.
netshell.HrRenameConnection(&wintun.cfgInstanceID, windows.StringToUTF16Ptr(ifname))
return nil
}