aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-08-26 07:30:17 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-26 07:43:49 -0600
commit7a33df13357bf2b760e8df5bd6ec43d2e13f8ab0 (patch)
tree889bd4fac7ad182f8902eab3963ca975dc2ca935
parentfirewall: use RtlGetNtVersionNumbers for kernel compat checks (diff)
downloadwireguard-windows-7a33df13357bf2b760e8df5bd6ec43d2e13f8ab0.tar.xz
wireguard-windows-7a33df13357bf2b760e8df5bd6ec43d2e13f8ab0.zip
elevate: mark as terminal services aware
-rw-r--r--Makefile2
-rw-r--r--elevate/shellexecute.go2
-rw-r--r--elevate/syscall_windows.go2
-rw-r--r--elevate/zsyscall_windows.go30
4 files changed, 11 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 2e170a72..d6fe422b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
GOFLAGS := -ldflags="-H windowsgui -s -w" -v -tags walk_use_cgo -trimpath
export CGO_ENABLED := 1
export CGO_CFLAGS := -O3 -Wall -Wno-unused-function -Wno-switch -std=gnu11 -DWINVER=0x0601
-export CGO_LDFLAGS := -Wl,--major-os-version=6 -Wl,--minor-os-version=1 -Wl,--major-subsystem-version=6 -Wl,--minor-subsystem-version=1
+export CGO_LDFLAGS := -Wl,--major-os-version=6 -Wl,--minor-os-version=1 -Wl,--major-subsystem-version=6 -Wl,--minor-subsystem-version=1 -Wl,--tsaware
export GOOS := windows
export GOPROXY := direct
diff --git a/elevate/shellexecute.go b/elevate/shellexecute.go
index 149a4c57..c4cd04da 100644
--- a/elevate/shellexecute.go
+++ b/elevate/shellexecute.go
@@ -94,7 +94,7 @@ func ShellExecute(program string, arguments string, directory string, show int32
return
}
var windowsDirectory [windows.MAX_PATH]uint16
- if _, err = getWindowsDirectory(&windowsDirectory[0], windows.MAX_PATH); err != nil {
+ if _, err = getSystemWindowsDirectory(&windowsDirectory[0], windows.MAX_PATH); err != nil {
return
}
originalPath := dataTableEntry.FullDllName.Buffer
diff --git a/elevate/syscall_windows.go b/elevate/syscall_windows.go
index d50e9c87..2ee3587a 100644
--- a/elevate/syscall_windows.go
+++ b/elevate/syscall_windows.go
@@ -78,7 +78,7 @@ const (
cCOINIT_APARTMENTTHREADED = 2
)
-//sys getWindowsDirectory(windowsDirectory *uint16, inLen uint32) (outLen uint32, err error) [failretval==0] = kernel32.GetWindowsDirectoryW
+//sys getSystemWindowsDirectory(windowsDirectory *uint16, inLen uint32) (outLen uint32, err error) [failretval==0] = kernel32.GetSystemWindowsDirectoryW
//sys rtlInitUnicodeString(destinationString *cUNICODE_STRING, sourceString *uint16) = ntdll.RtlInitUnicodeString
//sys rtlGetCurrentPeb() (peb *cPEB) = ntdll.RtlGetCurrentPeb
diff --git a/elevate/zsyscall_windows.go b/elevate/zsyscall_windows.go
index a3c5400d..6ce8f0db 100644
--- a/elevate/zsyscall_windows.go
+++ b/elevate/zsyscall_windows.go
@@ -41,30 +41,16 @@ var (
modntdll = windows.NewLazySystemDLL("ntdll.dll")
modole32 = windows.NewLazySystemDLL("ole32.dll")
- procGetModuleHandleW = modkernel32.NewProc("GetModuleHandleW")
- procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
- procRtlInitUnicodeString = modntdll.NewProc("RtlInitUnicodeString")
- procRtlGetCurrentPeb = modntdll.NewProc("RtlGetCurrentPeb")
- procCoInitializeEx = modole32.NewProc("CoInitializeEx")
- procCoUninitialize = modole32.NewProc("CoUninitialize")
- procCoGetObject = modole32.NewProc("CoGetObject")
+ procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
+ procRtlInitUnicodeString = modntdll.NewProc("RtlInitUnicodeString")
+ procRtlGetCurrentPeb = modntdll.NewProc("RtlGetCurrentPeb")
+ procCoInitializeEx = modole32.NewProc("CoInitializeEx")
+ procCoUninitialize = modole32.NewProc("CoUninitialize")
+ procCoGetObject = modole32.NewProc("CoGetObject")
)
-func getModuleHandle(moduleName *uint16) (moduleHandle uintptr, err error) {
- r0, _, e1 := syscall.Syscall(procGetModuleHandleW.Addr(), 1, uintptr(unsafe.Pointer(moduleName)), 0, 0)
- moduleHandle = uintptr(r0)
- if moduleHandle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getWindowsDirectory(windowsDirectory *uint16, inLen uint32) (outLen uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(windowsDirectory)), uintptr(inLen), 0)
+func getSystemWindowsDirectory(windowsDirectory *uint16, inLen uint32) (outLen uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(windowsDirectory)), uintptr(inLen), 0)
outLen = uint32(r0)
if outLen == 0 {
if e1 != 0 {