aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/resource/zsyscall_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-03-03 15:05:19 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-03-08 21:04:09 -0700
commit4885e7c9549e8d6812eb7aa069e863a349f50e84 (patch)
tree65871ccc7e13c6de5b0385cc703753dc56a29ff0 /tun/wintun/resource/zsyscall_windows.go
parentmemmod: do not use IsBadReadPtr (diff)
downloadwireguard-go-4885e7c9549e8d6812eb7aa069e863a349f50e84.tar.xz
wireguard-go-4885e7c9549e8d6812eb7aa069e863a349f50e84.zip
memmod: use resource functions from x/sys
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun/wintun/resource/zsyscall_windows.go')
-rw-r--r--tun/wintun/resource/zsyscall_windows.go112
1 files changed, 0 insertions, 112 deletions
diff --git a/tun/wintun/resource/zsyscall_windows.go b/tun/wintun/resource/zsyscall_windows.go
deleted file mode 100644
index e4c4bf1..0000000
--- a/tun/wintun/resource/zsyscall_windows.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Code generated by 'go generate'; DO NOT EDIT.
-
-package resource
-
-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 (
- modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
- modversion = windows.NewLazySystemDLL("version.dll")
-
- procFindResourceW = modkernel32.NewProc("FindResourceW")
- procSizeofResource = modkernel32.NewProc("SizeofResource")
- procLoadResource = modkernel32.NewProc("LoadResource")
- procLockResource = modkernel32.NewProc("LockResource")
- procVerQueryValueW = modversion.NewProc("VerQueryValueW")
-)
-
-func findResource(module windows.Handle, name *uint16, resType *uint16) (resInfo windows.Handle, err error) {
- r0, _, e1 := syscall.Syscall(procFindResourceW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(resType)))
- resInfo = windows.Handle(r0)
- if resInfo == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func sizeofResource(module windows.Handle, resInfo windows.Handle) (size uint32, err error) {
- r0, _, e1 := syscall.Syscall(procSizeofResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
- size = uint32(r0)
- if size == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func loadResource(module windows.Handle, resInfo windows.Handle) (resData windows.Handle, err error) {
- r0, _, e1 := syscall.Syscall(procLoadResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
- resData = windows.Handle(r0)
- if resData == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func lockResource(resData windows.Handle) (addr uintptr, err error) {
- r0, _, e1 := syscall.Syscall(procLockResource.Addr(), 1, uintptr(resData), 0, 0)
- addr = uintptr(r0)
- if addr == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func verQueryValue(block *byte, section *uint16, value **byte, size *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procVerQueryValueW.Addr(), 4, uintptr(unsafe.Pointer(block)), uintptr(unsafe.Pointer(section)), uintptr(unsafe.Pointer(value)), uintptr(unsafe.Pointer(size)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}