summaryrefslogtreecommitdiffhomepage
path: root/tun/wintun/netshell
diff options
context:
space:
mode:
Diffstat (limited to 'tun/wintun/netshell')
-rw-r--r--tun/wintun/netshell/netshell_windows.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/tun/wintun/netshell/netshell_windows.go b/tun/wintun/netshell/netshell_windows.go
new file mode 100644
index 0000000..cb03252
--- /dev/null
+++ b/tun/wintun/netshell/netshell_windows.go
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
+ */
+
+package netshell
+
+import (
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+var (
+ modnetshell = windows.NewLazySystemDLL("netshell.dll")
+ procHrRenameConnection = modnetshell.NewProc("HrRenameConnection")
+)
+
+func HrRenameConnection(guid *windows.GUID, newName *uint16) (err error) {
+ err = procHrRenameConnection.Find()
+ if err != nil {
+ // Missing from servercore, so we can't presume it's always there.
+ return
+ }
+
+ ret, _, _ := syscall.Syscall(procHrRenameConnection.Addr(), 2, uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(newName)), 0)
+ if ret != 0 {
+ err = syscall.Errno(ret)
+ }
+ return
+}