Jason A. Donenfeld has uploaded this change for review.
windows: add CreateProcessAsUser
The syscall package already has this, but this one does not, so add this
simple companion to CreateProcess.
Change-Id: I8533f91245630dcf39705ae56a22c1217871f968
---
M windows/syscall_windows.go
M windows/zsyscall_windows.go
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go
index bb6aaf8..7d7d351 100644
--- a/windows/syscall_windows.go
+++ b/windows/syscall_windows.go
@@ -220,6 +220,7 @@
//sys CancelIo(s Handle) (err error)
//sys CancelIoEx(s Handle, o *Overlapped) (err error)
//sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
+//sys CreateProcessAsUser(token Token, appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessAsUserW
//sys initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) = InitializeProcThreadAttributeList
//sys deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) = DeleteProcThreadAttributeList
//sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute
diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go
index 559bc84..86989b5 100644
--- a/windows/zsyscall_windows.go
+++ b/windows/zsyscall_windows.go
@@ -185,6 +185,7 @@
procCreateMutexW = modkernel32.NewProc("CreateMutexW")
procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
procCreatePipe = modkernel32.NewProc("CreatePipe")
+ procCreateProcessAsUserW = modkernel32.NewProc("CreateProcessAsUserW")
procCreateProcessW = modkernel32.NewProc("CreateProcessW")
procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
@@ -1577,6 +1578,18 @@
return
}
+func CreateProcessAsUser(token Token, appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
+ var _p0 uint32
+ if inheritHandles {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall12(procCreateProcessAsUserW.Addr(), 11, uintptr(token), uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
var _p0 uint32
if inheritHandles {
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Alex Brainman, Brad Fitzpatrick.
Patch set 1:Run-TryBot +1Trust +1
Attention is currently required from: Jason A. Donenfeld, Alex Brainman.
Patch set 1:Code-Review +2Trust +1
1 comment:
Patchset:
random tab character midline in the first file. otherwise LGTM.
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Jason A. Donenfeld, Alex Brainman.
Jason A. Donenfeld uploaded patch set #2 to this change.
windows: add CreateProcessAsUser
The syscall package already has this, but this one does not, so add this
simple companion to CreateProcess.
Change-Id: I8533f91245630dcf39705ae56a22c1217871f968
---
M windows/syscall_windows.go
M windows/zsyscall_windows.go
2 files changed, 14 insertions(+), 0 deletions(-)
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Alex Brainman.
Patch set 2:Run-TryBot +1Trust +1
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.
Jason A. Donenfeld submitted this change.
windows: add CreateProcessAsUser
The syscall package already has this, but this one does not, so add this
simple companion to CreateProcess.
Change-Id: I8533f91245630dcf39705ae56a22c1217871f968
Reviewed-on: https://go-review.googlesource.com/c/sys/+/322489
Trust: Jason A. Donenfeld <Ja...@zx2c4.com>
Trust: Brad Fitzpatrick <brad...@golang.org>
Run-TryBot: Jason A. Donenfeld <Ja...@zx2c4.com>
TryBot-Result: Go Bot <go...@golang.org>
Reviewed-by: Brad Fitzpatrick <brad...@golang.org>
---
M windows/syscall_windows.go
M windows/zsyscall_windows.go
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go
index bb6aaf8..183173a 100644
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Jason A. Donenfeld.
1 comment:
File windows/syscall_windows.go:
Patch Set #3, Line 223: CreateProcessAsUserW
version in $GOROOT uses CreateProcessAsUserW from advapi32.dll
s/CreateProcessAsUserW/advapi32.CreateProcessAsUserW/
Same here
says it lives in advapi32.dll.
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
File windows/syscall_windows.go:
Patch Set #3, Line 223: CreateProcessAsUserW
version in $GOROOT uses CreateProcessAsUserW from advapi32.dll […]
Good catch. Interesting that this code still works; looks like there's an alias. I'll send a followup CL.
To view, visit change 322489. To unsubscribe, or for help writing mail filters, visit settings.