aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-14 00:39:14 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-16 18:17:05 +0100
commit3e294f9c63fd6fea6981c8f4cc265cfea6570f02 (patch)
tree6e64060b1c3dc40f88eefc91b929a47b39301117 /main.go
parentbuild: llvm doesnt like dashes (diff)
downloadwireguard-windows-3e294f9c63fd6fea6981c8f4cc265cfea6570f02.tar.xz
wireguard-windows-3e294f9c63fd6fea6981c8f4cc265cfea6570f02.zip
mod: bump x/sys for IsWow64Process2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 3 insertions, 19 deletions
diff --git a/main.go b/main.go
index 0c12ce93..868be5d0 100644
--- a/main.go
+++ b/main.go
@@ -7,15 +7,14 @@ package main
import (
"debug/pe"
+ "errors"
"fmt"
"log"
"os"
"runtime"
"strconv"
"strings"
- "syscall"
"time"
- "unsafe"
"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/tun"
@@ -64,25 +63,10 @@ func usage() {
os.Exit(1)
}
-//TODO: replace with https://go-review.googlesource.com/c/sys/+/269077 once merged
-func isWow64Process2(handle windows.Handle, processMachine *uint16, nativeMachine *uint16) (err error) {
- p := windows.NewLazySystemDLL("kernel32.dll").NewProc("IsWow64Process2")
- err = p.Find()
- if err != nil {
- return
- }
- ret, _, e := syscall.Syscall(p.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(processMachine)), uintptr(unsafe.Pointer(nativeMachine)))
- if ret == 0 {
- err = e
- return err
- }
- return
-}
-
func checkForWow64() {
b, err := func() (bool, error) {
var processMachine, nativeMachine uint16
- err := isWow64Process2(windows.CurrentProcess(), &processMachine, &nativeMachine)
+ err := windows.IsWow64Process2(windows.CurrentProcess(), &processMachine, &nativeMachine)
if err == nil {
if nativeMachine == pe.IMAGE_FILE_MACHINE_ARM64 && runtime.GOARCH == "arm" {
//TODO: remove this exception when Go supports arm64
@@ -90,7 +74,7 @@ func checkForWow64() {
}
return processMachine != pe.IMAGE_FILE_MACHINE_UNKNOWN, nil
}
- if _, isDllErr := err.(*windows.DLLError); !isDllErr {
+ if !errors.Is(err, windows.ERROR_PROC_NOT_FOUND) {
return false, err
}
var b bool