aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/registry/zregistry_windows.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-05-09 10:11:15 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-10 16:43:58 +0200
commit7e962a9932667f4a161b20aba5ff1c75ab8e578a (patch)
tree212eb2c6bc55db43c0b982b71195fc3ec61ce659 /tun/wintun/registry/zregistry_windows.go
parentconn: remove scope when sanity checking IP address format (diff)
downloadwireguard-go-7e962a9932667f4a161b20aba5ff1c75ab8e578a.tar.xz
wireguard-go-7e962a9932667f4a161b20aba5ff1c75ab8e578a.zip
wintun: wait for interface registry key on device creation
By using RegNotifyChangeKeyValue(). Also disable dead gateway detection. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun/wintun/registry/zregistry_windows.go')
-rw-r--r--tun/wintun/registry/zregistry_windows.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/tun/wintun/registry/zregistry_windows.go b/tun/wintun/registry/zregistry_windows.go
new file mode 100644
index 0000000..f7ac33b
--- /dev/null
+++ b/tun/wintun/registry/zregistry_windows.go
@@ -0,0 +1,63 @@
+// Code generated by 'go generate'; DO NOT EDIT.
+
+package registry
+
+import (
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.Errno) error {
+ switch e {
+ case 0:
+ return nil
+ case errnoERROR_IO_PENDING:
+ return errERROR_IO_PENDING
+ }
+ // TODO: add more here, after collecting data on the common
+ // error values see on Windows. (perhaps when running
+ // all.bat?)
+ return e
+}
+
+var (
+ modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
+
+ procRegNotifyChangeKeyValue = modadvapi32.NewProc("RegNotifyChangeKeyValue")
+)
+
+func regNotifyChangeKeyValue(key windows.Handle, watchSubtree bool, notifyFilter uint32, event windows.Handle, asynchronous bool) (regerrno error) {
+ var _p0 uint32
+ if watchSubtree {
+ _p0 = 1
+ } else {
+ _p0 = 0
+ }
+ var _p1 uint32
+ if asynchronous {
+ _p1 = 1
+ } else {
+ _p1 = 0
+ }
+ r0, _, _ := syscall.Syscall6(procRegNotifyChangeKeyValue.Addr(), 5, uintptr(key), uintptr(_p0), uintptr(notifyFilter), uintptr(event), uintptr(_p1), 0)
+ if r0 != 0 {
+ regerrno = syscall.Errno(r0)
+ }
+ return
+}