diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-06-12 18:37:49 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-06-13 09:21:50 +0200 |
commit | 666f4433c53d49fbb953061ac7738d724cf61b8a (patch) | |
tree | 7b4b9b1f8989d827bd691867b34a07d9a7f67055 /conf/zsyscall_windows.go | |
parent | mod: bump wireguard-go (diff) | |
download | wireguard-windows-666f4433c53d49fbb953061ac7738d724cf61b8a.tar.xz wireguard-windows-666f4433c53d49fbb953061ac7738d724cf61b8a.zip |
conf: manually migrate from windows.old
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | conf/zsyscall_windows.go | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/conf/zsyscall_windows.go b/conf/zsyscall_windows.go index d8984bef..7ad7bbab 100644 --- a/conf/zsyscall_windows.go +++ b/conf/zsyscall_windows.go @@ -40,11 +40,14 @@ var ( modwininet = windows.NewLazySystemDLL("wininet.dll") modole32 = windows.NewLazySystemDLL("ole32.dll") modshell32 = windows.NewLazySystemDLL("shell32.dll") + modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") modkernel32 = windows.NewLazySystemDLL("kernel32.dll") procInternetGetConnectedState = modwininet.NewProc("InternetGetConnectedState") procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") + procGetFileSecurityW = modadvapi32.NewProc("GetFileSecurityW") + procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner") procFindFirstChangeNotificationW = modkernel32.NewProc("FindFirstChangeNotificationW") procFindNextChangeNotification = modkernel32.NewProc("FindNextChangeNotification") ) @@ -60,9 +63,29 @@ func coTaskMemFree(pointer uintptr) { return } -func shGetKnownFolderPath(id *windows.GUID, flags uint32, token windows.Handle, path **uint16) (err error) { - r1, _, e1 := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0) - if r1 != 0 { +func shGetKnownFolderPath(id *windows.GUID, flags uint32, token windows.Handle, path **uint16) (ret error) { + r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func getFileSecurity(fileName *uint16, securityInformation uint32, securityDescriptor *byte, descriptorLen uint32, requestedLen *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetFileSecurityW.Addr(), 5, uintptr(unsafe.Pointer(fileName)), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor)), uintptr(descriptorLen), uintptr(unsafe.Pointer(requestedLen)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func getSecurityDescriptorOwner(securityDescriptor *byte, sid **windows.SID, ownerDefaulted *bool) (err error) { + r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(securityDescriptor)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(ownerDefaulted))) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { |