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 <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Jason A. Donenfeld
2 years ago
219 | 219 |
//sys CancelIo(s Handle) (err error)
|
220 | 220 |
//sys CancelIoEx(s Handle, o *Overlapped) (err error)
|
221 | 221 |
//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
|
|
222 |
//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
|
222 | 223 |
//sys initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) = InitializeProcThreadAttributeList
|
223 | 224 |
//sys deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) = DeleteProcThreadAttributeList
|
224 | 225 |
//sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute
|
184 | 184 |
procCreateMutexW = modkernel32.NewProc("CreateMutexW")
|
185 | 185 |
procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
|
186 | 186 |
procCreatePipe = modkernel32.NewProc("CreatePipe")
|
|
187 |
procCreateProcessAsUserW = modkernel32.NewProc("CreateProcessAsUserW")
|
187 | 188 |
procCreateProcessW = modkernel32.NewProc("CreateProcessW")
|
188 | 189 |
procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
|
189 | 190 |
procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
|
|
1576 | 1577 |
return
|
1577 | 1578 |
}
|
1578 | 1579 |
|
|
1580 |
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) {
|
|
1581 |
var _p0 uint32
|
|
1582 |
if inheritHandles {
|
|
1583 |
_p0 = 1
|
|
1584 |
}
|
|
1585 |
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)
|
|
1586 |
if r1 == 0 {
|
|
1587 |
err = errnoErr(e1)
|
|
1588 |
}
|
|
1589 |
return
|
|
1590 |
}
|
|
1591 |
|
1579 | 1592 |
func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
|
1580 | 1593 |
var _p0 uint32
|
1581 | 1594 |
if inheritHandles {
|