Codebase list golang-golang-x-sys / 35b2ab0
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
2 changed file(s) with 14 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
219219 //sys CancelIo(s Handle) (err error)
220220 //sys CancelIoEx(s Handle, o *Overlapped) (err error)
221221 //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
222223 //sys initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) = InitializeProcThreadAttributeList
223224 //sys deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) = DeleteProcThreadAttributeList
224225 //sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute
184184 procCreateMutexW = modkernel32.NewProc("CreateMutexW")
185185 procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
186186 procCreatePipe = modkernel32.NewProc("CreatePipe")
187 procCreateProcessAsUserW = modkernel32.NewProc("CreateProcessAsUserW")
187188 procCreateProcessW = modkernel32.NewProc("CreateProcessW")
188189 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
189190 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
15761577 return
15771578 }
15781579
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
15791592 func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
15801593 var _p0 uint32
15811594 if inheritHandles {