New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syscall: StartProcess should accept Desktop property for StartupInfo for Windows #42836
Comments
Seems reasonable to me and easy to implement. One thing I'm wondering is: what are you using this parameter for and why? Usually it's possible to get a token to an interactive user with the desktop, and simply pass that token using the existing mechanism for that. Is there a reason why that doesn't work for you? |
ping @iangallOlive re above Q |
Apologies for not responding very quickly at all! But appreciate the ping. @zx2c4 You're absolutely right, and I think we're already doing that - but as far I can remember (because it's been awhile since we implemented this...I'm only now circling back to see if the concept could be added to Go), if you don't set this property, it doesn't matter where the token is from. I could be wrong, but I feel like this was true. Just to give more context, here's some more info:
I know we went through several iterations trying to figure out this whole concept, some of which I wasn't involved in. Please let me know if there's something I'm missing, that we could be doing to avoid the need to set the |
If you're stealing a token from explorer.exe, you shouldn't need to set desktop, afaik. But actually there's a more robust way of doing this from a service: You can use Once you have the Session ID, you call |
Feature Request
Purpose
This is meant to be a feature request. I'm trying to gauge whether people agree this would be an acceptable/beneficial addition, and if the team would be willing to work on it or if it would be generally accepted by an outside contributor (me) if a PR was submitted.
Problem Statement
To give a quick context:
os/exec
'sCommand
'sRun
func callsos.StartProcess
, which ends up callingsyscall.StartProcess
.For Windows,
syscall.StartProcess
callssyscall.CreateProcess
(orsyscall.CreateProcessAsUser
), which calls theCreateProcessW
Win32 API method.CreateProcessW
accepts aSTARTUP_INFOW
param, which is nicely constructed in thesyscall.StartProcess
func via asyscall.StartupInfo
. One ofSTARTUP_INFOW
's properties is aLPWSTR lpDesktop
. Unfortunately, nothing aroundsyscall.StartProcess
allows for this to be provided or set on the underlyingsyscall.StartupInfo
, even though that struct already has the property defined.I've had to generally rewrite the overall logic of
syscall.StartProcess
in my company's application because we need to be able to set thelpDesktop
property. It would be nice to have it part of Go so we can useos/exec
'sCommand
.Proposed Solution
Of the
syscall.StartProcess
func, In theattr
(*syscall.ProcAttr
) param, there is aSys
(*syscall.SysProcAttr
) property. I think aDesktop string
property should be added there. This will be an optional value and only used in thesyscall.StartupInfo
if it's provided, which should make it fully backwards compatible.So, in
syscall.StartProcess
, something like the following can be done:and then used like this:
and I think that should be it!
The text was updated successfully, but these errors were encountered: