diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-26 07:30:17 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-26 07:43:49 -0600 |
commit | fa27bd22a6c35a702b7b1c24adbb40206331d5a5 (patch) | |
tree | 889bd4fac7ad182f8902eab3963ca975dc2ca935 /elevate | |
parent | firewall: use RtlGetNtVersionNumbers for kernel compat checks (diff) | |
download | wireguard-windows-fa27bd22a6c35a702b7b1c24adbb40206331d5a5.tar.xz wireguard-windows-fa27bd22a6c35a702b7b1c24adbb40206331d5a5.zip |
elevate: mark as terminal services aware
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'elevate')
-rw-r--r-- | elevate/shellexecute.go | 2 | ||||
-rw-r--r-- | elevate/syscall_windows.go | 2 | ||||
-rw-r--r-- | elevate/zsyscall_windows.go | 30 |
3 files changed, 10 insertions, 24 deletions
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 { |