Console-Docs icon indicating copy to clipboard operation
Console-Docs copied to clipboard

Explain the CreateProcess flags and how they actually work

Open miniksa opened this issue 5 years ago • 2 comments

Despite hearing from no one for years about these flags, somehow in the last 6 working days, I've had 5 separate incidents of people coming out of nowhere having trouble with launching processes because of the poor documentation on these flags.

This represents clearing up how they actually work from the console side and will cross reference the code in kernelbase process initialization and console host process startup with the flag definitions in CreateProcessA/W

miniksa avatar Dec 05 '19 18:12 miniksa

  • contents of MSFT:19755089

From the filer: "Search the Web for "CREATE_NO_WINDOW vs. DETACHED_PROCESS". Find users confused about the distinction about these flags and even the "popular expert answers" on stackoverflow.com being completely incorrect.

The reason is the documentation is wrong and vague about it. Based on my exploration of the current Windows source code, I find that this flag means essentially: "just like with the CREATE_NEW_CONSOLE flag, instead of having the new process inherit its parent's console, create a new console for the new process; however, have that console have no window. In particular, the standard in/out/err handles for the child process will be valid handles corresponding to the console device, but any attempts to output or input on them will essentially have no effect as the console has no window". This actual meaning contradicts the false statements made in the current documentation.

A source code owner needs to confirm my findings before publishing them as the official documentation."

miniksa avatar Nov 23 '21 23:11 miniksa

To represent the scope of this item, I've added the flags from the CreateProcess documentation to track validation of their current documentation or potential updates.

Flags documented per console experience and source code:

  • [ ] CREATE_BREAKAWAY_FROM_JOB
  • [ ] CREATE_DEFAULT_ERROR_MODE
  • [ ] CREATE_NEW_CONSOLE
  • [ ] CREATE_NEW_PROCESS_GROUP
  • [ ] CREATE_NO_WINDOW https://github.com/MicrosoftDocs/win32/pull/1219
  • [ ] CREATE_PROTECTED_PROCESS
  • [ ] CREATE_PRESERVE_CODE_AUTHZ_LEVEL
  • [ ] CREATE_SECURE_PROCESS
  • [ ] CREATE_SEPARATE_WOW_VDM
  • [ ] CREATE_SHARED_WOW_VDM
  • [ ] CREATE_SUSPENDED
  • [ ] CREATE_UNICODE_ENVIRONMENT
  • [ ] DEBUG_ONLY_THIS_PROCESS
  • [ ] DEBUG_PROCESS
  • [ ] DETACHED_PROCESS
  • [ ] EXTENDED_STARTUPINFO_PRESENT
  • [ ] INHERIT_PARENT_AFFINITY

pizzaz93 avatar May 03 '22 23:05 pizzaz93