diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-29 22:29:22 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-02 21:44:58 +0100 |
commit | e11de8481c4c349456125e5ad6782d82d423a5b9 (patch) | |
tree | d68075b842708eaef491eaed5cd240245923af7d /tunnel/winipcfg/zwinipcfg_windows.go | |
parent | mod: bump to fix 32-bit alignment (diff) | |
download | wireguard-windows-e11de8481c4c349456125e5ad6782d82d423a5b9.tar.xz wireguard-windows-e11de8481c4c349456125e5ad6782d82d423a5b9.zip |
winipcfg: move to undocumented DNS function
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | tunnel/winipcfg/zwinipcfg_windows.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tunnel/winipcfg/zwinipcfg_windows.go b/tunnel/winipcfg/zwinipcfg_windows.go index cf661548..c4bf3b00 100644 --- a/tunnel/winipcfg/zwinipcfg_windows.go +++ b/tunnel/winipcfg/zwinipcfg_windows.go @@ -66,6 +66,7 @@ var ( procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange") procNotifyRouteChange2 = modiphlpapi.NewProc("NotifyRouteChange2") procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange") + procSetInterfaceDnsSettings = modiphlpapi.NewProc("SetInterfaceDnsSettings") procSetIpForwardEntry2 = modiphlpapi.NewProc("SetIpForwardEntry2") procSetIpInterfaceEntry = modiphlpapi.NewProc("SetIpInterfaceEntry") procSetUnicastIpAddressEntry = modiphlpapi.NewProc("SetUnicastIpAddressEntry") @@ -279,6 +280,42 @@ func notifyUnicastIPAddressChange(family AddressFamily, callback uintptr, caller return } +func setInterfaceDnsSettingsByDwords(guid1 uintptr, guid2 uintptr, guid3 uintptr, guid4 uintptr, settings *dnsInterfaceSettings) (ret error) { + ret = procSetInterfaceDnsSettings.Find() + if ret != nil { + return + } + r0, _, _ := syscall.Syscall6(procSetInterfaceDnsSettings.Addr(), 5, uintptr(guid1), uintptr(guid2), uintptr(guid3), uintptr(guid4), uintptr(unsafe.Pointer(settings)), 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func setInterfaceDnsSettingsByPtr(guid *windows.GUID, settings *dnsInterfaceSettings) (ret error) { + ret = procSetInterfaceDnsSettings.Find() + if ret != nil { + return + } + r0, _, _ := syscall.Syscall(procSetInterfaceDnsSettings.Addr(), 2, uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(settings)), 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func setInterfaceDnsSettingsByQwords(guid1 uintptr, guid2 uintptr, settings *dnsInterfaceSettings) (ret error) { + ret = procSetInterfaceDnsSettings.Find() + if ret != nil { + return + } + r0, _, _ := syscall.Syscall(procSetInterfaceDnsSettings.Addr(), 3, uintptr(guid1), uintptr(guid2), uintptr(unsafe.Pointer(settings))) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + func setIPForwardEntry2(route *MibIPforwardRow2) (ret error) { r0, _, _ := syscall.Syscall(procSetIpForwardEntry2.Addr(), 1, uintptr(unsafe.Pointer(route)), 0, 0) if r0 != 0 { |