From d20459dc6916fa3d4cd4bc161864111195ffecd3 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 19 Aug 2019 09:01:53 +0200 Subject: wintun: set adapter description name --- tun/wintun/wintun_windows.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index 55d4ed0..8b85242 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -32,6 +32,7 @@ var deviceClassNetGUID = windows.GUID{Data1: 0x4d36e972, Data2: 0xe325, Data3: 0 var deviceInterfaceNetGUID = windows.GUID{Data1: 0xcac88484, Data2: 0x7515, Data3: 0x4c03, Data4: [8]byte{0x82, 0xe6, 0x71, 0xa8, 0x7a, 0xba, 0xc3, 0x61}} const ( + deviceTypeName = "WireGuard Tunnel" hardwareID = "Wintun" waitForRegistryTimeout = time.Second * 10 ) @@ -341,6 +342,24 @@ func CreateInterface(description string, requestedGUID *windows.GUID) (wintun *W return } + // Name ourselves. + deviceKey, 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 deviceKey.Close() + err = deviceKey.SetStringValue("DeviceDesc", deviceTypeName) + if err != nil { + err = fmt.Errorf("SetStringValue(DeviceDesc) failed: %v", err) + return + } + err = deviceKey.SetStringValue("FriendlyName", deviceTypeName) + if err != nil { + err = fmt.Errorf("SetStringValue(FriendlyName) failed: %v", err) + return + } + // Wait for network registry key to emerge and populate. key, err = registryEx.OpenKeyWait( registry.LOCAL_MACHINE, @@ -580,6 +599,11 @@ func (wintun *Wintun) tcpipAdapterRegKeyName() string { return fmt.Sprintf("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Adapters\\%v", wintun.cfgInstanceID) } +// deviceRegKeyName returns the device-level registry key name +func (wintun *Wintun) deviceRegKeyName() string { + return fmt.Sprintf("SYSTEM\\CurrentControlSet\\Enum\\%v", wintun.devInstanceID) +} + // tcpipInterfaceRegKeyName returns the interface-specific TCP/IP network registry key name. func (wintun *Wintun) tcpipInterfaceRegKeyName() (path string, err error) { key, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.tcpipAdapterRegKeyName(), registry.QUERY_VALUE) -- cgit v1.2.3-59-g8ed1b