From 7a33df13357bf2b760e8df5bd6ec43d2e13f8ab0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 26 Aug 2019 07:30:17 -0600 Subject: elevate: mark as terminal services aware --- elevate/shellexecute.go | 2 +- elevate/syscall_windows.go | 2 +- elevate/zsyscall_windows.go | 30 ++++++++---------------------- 3 files changed, 10 insertions(+), 24 deletions(-) (limited to 'elevate') 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 { -- cgit v1.2.3-59-g8ed1b