-
Notifications
You must be signed in to change notification settings - Fork 322
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
Docs for making CreateProcess work on a packaged win32 exe could be improved #4651
Comments
One of the big issues I have with this is that the Windows App Runtime provides a way for an application to request a restart for itself. This starts RestartAgent.exe, which is part of the Windows App Runtime package, and isn't mentioned in the AppxManifest file, and exits the process. This RestartAgent.exe then executes the process again. This means that not CreateProcess is used twice, but one of them is for a process that is not mentioned in the package's manifest. What's more, there is no alias registered for this, and the restart agent manifest doesn't contain a msix element. |
Entry point is "Windows.FullTrustApplication" and @DrusTheAxe has posted elsewhere on GitHub about how this mechanism works internally, and what he's said does strongly imply that your EXEs have to be listed in the manifest and have the If
This sounds highly related. |
BTW, I suspect the reason this may be required for Node is this code: But really what we need here is someone with source code access to explain or better update CreateProcess docs with an explanation of what combinations yield what outcomes. |
Just in case you are wondering where I got my information from, it is in UpdateProcThreadAttribute, which is the primary function for setting information in the extended startup information. With regards to Windows 10, I don't think it needs the msix element and an Application entry, but I think it does require some form of telling it to inherit the package identity. So the extended startup information should work just as well. --Edit-- Anyway, I agree with your point that there is information missing. |
Yes this isn't a problem. Only running EXEs inside the app package.
Sure, but changing the code that runs CreateProcess is hard. It sits inside a bunch of language runtimes that people upgrade slowly, and where code changes are reviewed carefully. Given the docs on this are scattered and hard to interpret, it's hard to convince people to change their code when it works fine outside of the MSIX container. So changing the manifests has to be the way to go here. Clearer direction from Microsoft would help here: CreateProcess could/should discuss all these topics, as package identity is clearly an aspect of the Windows API that becomes increasingly important. |
Continuing my mission to document the hidden internals of CreateProcess on Win10 things get much hairier still. It's possible that my report of a bug above is wrong because more investigation reveals that
So it seems like something inside Windows is trying to work out the link between the EXE and the MSIX, and in some cases it gets confused and can't work it out because there are multiple similar packages installed, so it gives up and returns I've also seen behavior not be consistent across upgrades, e.g. change from not having the |
Systematic testing shows the following:
This is all Win10 + NodeJS + apps having an So in the end, the Is it OK if the app alias name is different to the EXE name? No: they have to match. This poses quite the conundrum. If two programs that use MSIX both ship the same helper EXE, then it looks like on Win10 they must pollute the %PATH%, and cannot be installed simultaneously. Hopefully digging reveals some way to dodge this because this otherwise appears to be a critical bug in Win10 - you don't control what other packages are installed or what EXEs they use. And we can't tell users to just upgrade to 11 due to the hardware requirements. |
What are you trying to do?
|
It's the first.
|
Update: it turns out this is more than a documentation problem. Adding the manifest entries for the helper EXE breaks Windows Store submission because they consider an app that contains any CLI exe to be a "headless" app, even if the package also contains a desktop/start menu entry point. And then for some inexplicable reason they require you to apply for special permission to create such apps. Windows happily installs them outside of the store without special permissions, but in store, you have to ask. So the workaround for this Windows bug breaks Store submission. Great. :( We really do need some sort of fix here. This is a sharp edge that surfaces to most developers as "I packaged with MSIX and now stuff randomly doesn't work". |
@codendone See last comment, I think this is not (only) a documentation bug but a more general problem with Windows. |
Describe the bug
I'm not sure this is the right repository, but I've seen @DrusTheAxe giving expert answers to related topics here, so I think bugs filed may reach the right people.
There are some aspects of making CreateProcess work correctly in an MSIX packaged app that aren't intuitive and there's a bug in Windows 10 that isn't documented. I had to work it out by trial and error.
On all versions of Windows if your main EXE attempts to execute an EXE that's included in your package as a helper, then it will mysteriously get ERROR_ACCESS_DENIED from CreateProcess ("Access is denied"). Nothing is logged when this happens 😢
The reason is that all EXEs, not just those started from the start menu or a %PATH% execution alias, must be listed in the AppX Manifest using
<Application>
elements even if the only thing that starts them is your own code. This isn't mentioned in the docs for<Application>
nor the docs forCreateProcess
(in fact the API docs forCreateProcess
don't contain the word manifest anywhere).On Win11 it is sufficient to create an entry for your helper EXEs in
AppxManifest.xml
. Unfortunately we must still work on Win10 where it requires more effort:<msix>
tag.<Application>
element in the AppxManifestIn other words every EXE helper tool shipped in an MSIX packaged app must be added to the %PATH% if your runtime uses
CreateProcess
to invoke it, even if you don't actually invoke using that execution alias.Steps to reproduce the bug
exec
from thechild_process
module to invoke the EXE.Expected behavior
Everything should just work, obviously. Process creation is the sort of thing you don't expect to break just because of choice of packaging format.
Screenshots
No response
NuGet package version
None
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update), Windows 10 version 22H2 (19045, 2022 Update)
IDE
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: