aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/wintun_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-07-18 10:25:12 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-07-18 10:25:20 +0200
commit298d759f3efba6b90ea70838d190959b39c5be57 (patch)
tree8e01a764682a50c258ece5d54a26363e7b96ee67 /tun/wintun/wintun_windows.go
parenttun: openbsd: don't change MTU when it's already the expected size (diff)
downloadwireguard-go-298d759f3efba6b90ea70838d190959b39c5be57.tar.xz
wireguard-go-298d759f3efba6b90ea70838d190959b39c5be57.zip
wintun: calculate path of NDIS device object symbolic link
Diffstat (limited to '')
-rw-r--r--tun/wintun/wintun_windows.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index b8aabf3..160d51f 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -311,6 +311,9 @@ func CreateInterface(description string, requestedGUID *windows.GUID) (wintun *W
waitForRegistryTimeout)
if err == nil {
_, err = registryEx.GetStringValueWait(key, "Name", waitForRegistryTimeout)
+ if err == nil {
+ _, err = registryEx.GetStringValueWait(key, "PnPInstanceId", waitForRegistryTimeout)
+ }
key.Close()
}
}
@@ -614,6 +617,23 @@ func (wintun *Wintun) DataFileName() string {
return fmt.Sprintf("\\\\.\\Global\\WINTUN%d", wintun.luidIndex)
}
+// NdisFileName returns the Wintun NDIS device object name.
+func (wintun *Wintun) NdisFileName() (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)
+ }
+ defer key.Close()
+
+ // Get the interface name.
+ pnpInstanceID, err := registryEx.GetStringValue(key, "PnPInstanceId")
+ if err != nil {
+ return "", fmt.Errorf("PnpInstanceId registry key read failed: %v", err)
+ }
+ mangledPnpNode := strings.ReplaceAll(fmt.Sprintf("%s\\{cac88484-7515-4c03-82e6-71a87abac361}", pnpInstanceID), "\\", "#")
+ return fmt.Sprintf("\\\\.\\Global\\%s", mangledPnpNode), nil
+}
+
// GUID returns the GUID of the interface.
func (wintun *Wintun) GUID() windows.GUID {
return wintun.cfgInstanceID