Are child processes "break away" or not by default?

%3CLINGO-SUB%20id%3D%22lingo-sub-1671578%22%20slang%3D%22en-US%22%3EAre%20child%20processes%20%22break%20away%22%20or%20not%20by%20default%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1671578%22%20slang%3D%22en-US%22%3E%3CP%20data-unlink%3D%22true%22%3EHello%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20experiencing%20some%20difference%20in%20behavior%20between%20Windows%2010%202004%20and%20earlier%20versions.%3CBR%20%2F%3EHere's%20my%20scenario%3A%3CBR%20%2F%3EI'm%20creating%20an%20MSIX%20package%20for%20my%20application.%20I%20want%20my%20main%20executable%20and%20all%20of%20its%20child%20processes%20to%20run%20inside%20the%20MSIX%20container.%20According%20to%20the%20docs%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fmsix-container%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%2C%26nbsp%3B%26nbsp%3Bthis%20supposed%20to%20be%20the%20default%20behavior.%20However%2C%20in%20my%20testing%20on%20Windows%2010%201909%20I%20found%20this%20to%20be%20NOT%20the%20case.%20So%20I%20created%20a%20little%20executable%20that%20simply%20calls%20CreateProcess%20with%20the%26nbsp%3BPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%20flag.%20This%20executable%20is%20pointed%20by%20my%20start%20menu%20shortcut.%20This%20fixed%20my%20problem%20on%20Win10%201909.%20My%20child%20processes%20happily%20run%20inside%20the%20container.%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20an%20aside%2C%20the%20MSIX%20documentation%20above%20and%20the%20Win32%20documentation%20appears%20to%20be%20in%20conflict%3A%3CBR%20%2F%3EThe%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fapi%2Fprocessthreadsapi%2Fnf-processthreadsapi-updateprocthreadattribute%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ewin32%20documentation%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Estates%3A%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23999999%22%3E%3CSTRONG%3EPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_ENABLE_PROCESS_TREE%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E0x01%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23999999%22%3EThe%20process%20being%20created%20will%20create%20any%20child%20processes%20outside%20of%20the%20desktop%20app%20runtime%20environment.%20This%20behavior%20is%20the%20default%20for%20processes%20for%20which%20no%20policy%20has%20been%20set.%3C%2FFONT%3E%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E%3CBR%20%2F%3ESo%20if%20break-away%20is%20the%20default%20then%20child%20processes%20will%20NOT%20run%20inside%20a%20container.%3CBR%20%2F%3E%3CBR%20%2F%3EBack%20the%20the%20real%20problem%3A%20on%20Windows%2010%202004%20my%20little%20launcher%20app%20does%20not%20work%20at%20all.%20Calling%20CreateProcess%20with%26nbsp%3BPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%20has%20the%20exact%20opposite%20affect%20than%20what's%20documented.%20The%20child%20process%20%22breaks%20away%22%20and%20does%20not%20see%20the%20files%20inside%20the%20container.%20If%20I%20use%20%22null%22%20attribute%20list%2C%20then%20I%20get%20the%20behavior%20I%20want.%3CBR%20%2F%3E%3CBR%20%2F%3ECan%20anybody%20confirm%20this%20confusing%20variety%20of%20documentation%20and%20behaviors%3F%3CBR%20%2F%3E%3CBR%20%2F%3EHere's%20the%20code%20for%20my%20launcher%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-cpp%22%3E%3CCODE%3E%23include%20%3CIOSTREAM%3E%0A%23include%20%3CCASSERT%3E%0A%23include%20%3CVECTOR%3E%0A%23include%20%3CSTRING%3E%0A%23include%20%3CREGEX%3E%0A%0A%23define%20NTDDI_VERSION%20NTDDI_WIN10_RS2%0A%23include%20%3CWINDOWS.H%3E%0A%23define%20ASSERT%20assert%0A%0ALPPROC_THREAD_ATTRIBUTE_LIST%20MakeAttributeList()%0A%7B%0A%20%20%20%20LPPROC_THREAD_ATTRIBUTE_LIST%20attrbuteList%3B%0A%20%20%20%20SIZE_T%20AttributeListSize%7B%7D%3B%0A%20%20%20%20InitializeProcThreadAttributeList(nullptr%2C%201%2C%200%2C%20%26amp%3BAttributeListSize)%3B%0A%20%20%20%20attrbuteList%20%3D%20(LPPROC_THREAD_ATTRIBUTE_LIST)HeapAlloc(%0A%20%20%20%20%20%20%20%20GetProcessHeap()%2C%0A%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20AttributeListSize%0A%20%20%20%20)%3B%0A%0A%20%20%20%20DWORD%20error%20%3D%200%3B%0A%20%20%20%20if%20(!InitializeProcThreadAttributeList(%0A%20%20%20%20%20%20%20%20attrbuteList%2C%0A%20%20%20%20%20%20%20%201%2C%0A%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%26amp%3BAttributeListSize))%0A%20%20%20%20%20%20%20%20throw%20GetLastError()%3B%0A%0A%20%20%20%20DWORD%20attribute%20%3D%20PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%3B%0A%20%20%20%20if%20(!UpdateProcThreadAttribute(%0A%20%20%20%20%20%20%20%20attrbuteList%2C%0A%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20PROC_THREAD_ATTRIBUTE_DESKTOP_APP_POLICY%2C%0A%20%20%20%20%20%20%20%20%26amp%3Battribute%2C%0A%20%20%20%20%20%20%20%20sizeof(attribute)%2C%0A%20%20%20%20%20%20%20%20nullptr%2C%0A%20%20%20%20%20%20%20%20nullptr))%0A%20%20%20%20%20%20%20%20throw%20GetLastError()%3B%0A%0A%20%20%20%20return%20attrbuteList%3B%0A%7D%0A%0Aint%20wWinMain(%0A%20%20%20%20HINSTANCE%20hInstance%2C%0A%20%20%20%20HINSTANCE%20hPrevInstance%2C%0A%20%20%20%20LPWSTR%20%20%20%20%20lpCmdLine%2C%0A%20%20%20%20int%20%20%20%20%20%20%20nShowCmd)%0A%7B%0A%20%20%20%20try%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20const%20int%20len%20%3D%204096%3B%0A%20%20%20%20%20%20%20%20wchar_t%20buf%5Blen%5D%3B%0A%20%20%20%20%20%20%20%20if%20(len%20%3D%3D%20GetModuleFileName(0%2C%20buf%2C%20len))%0A%20%20%20%20%20%20%20%20%20%20%20%20throw%20GetLastError()%3B%0A%0A%20%20%20%20%20%20%20%20auto%20fname%20%3D%20std%3A%3Aregex_replace(buf%2C%20std%3A%3Awregex(L%22msixlauncher%5C%5C.exe%22)%2C%20L%22dwgviewr.exe%22)%3B%0A%20%20%20%20%20%20%20%20STARTUPINFOEXW%20startup_info%20%3D%20%7B%7D%3B%0A%20%20%20%20%20%20%20%20PROCESS_INFORMATION%20process_info%20%3D%20%7B%7D%3B%0A%20%20%20%20%20%20%20%20startup_info.StartupInfo.cb%20%3D%20sizeof(startup_info)%3B%0A%20%20%20%20%20%20%20%20startup_info.lpAttributeList%20%3D%20MakeAttributeList()%3B%0A%0A%20%20%20%20%20%20%20%20if%20(!%3A%3ACreateProcess(%0A%20%20%20%20%20%20%20%20%20%20%20%20fname.c_str()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20nullptr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20nullptr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20nullptr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20false%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20EXTENDED_STARTUPINFO_PRESENT%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20nullptr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20nullptr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20(STARTUPINFO*)%26amp%3Bstartup_info%2C%20%2F%2F%20startup%20info%0A%20%20%20%20%20%20%20%20%20%20%20%20%26amp%3Bprocess_info%20%20%2F%2F%20process%20info%0A%20%20%20%20%20%20%20%20))%0A%20%20%20%20%20%20%20%20%20%20%20%20throw%20GetLastError()%3B%0A%0A%20%20%20%20%20%20%20%20WaitForSingleObject(process_info.hProcess%2C%20INFINITE)%3B%0A%0A%20%20%20%20%20%20%20%20%3A%3ACloseHandle(process_info.hProcess)%3B%0A%20%20%20%20%20%20%20%20%3A%3ACloseHandle(process_info.hThread)%3B%0A%20%20%20%20%7D%0A%20%20%20%20catch%20(DWORD%20err)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20return%20err%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%200%3B%0A%7D%3C%2FWINDOWS.H%3E%3C%2FREGEX%3E%3C%2FSTRING%3E%3C%2FVECTOR%3E%3C%2FCASSERT%3E%3C%2FIOSTREAM%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%20data-unlink%3D%22true%22%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1673147%22%20slang%3D%22en-US%22%3ERe%3A%20Are%20child%20processes%20%22break%20away%22%20or%20not%20by%20default%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1673147%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F769820%22%20target%3D%22_blank%22%3E%40szilvaa%3C%2FA%3E%26nbsp%3BI%20believe%20that%20this%20is%20a%20change%20in%20the%202004%20Runtime.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPrior%20to%202004%20OS%2C%20my%20experience%20was%20that%20by%20default%20child%20processes%20would%20run%20outside%20of%20the%20container%2C%20but%20now%20on%202004%20breakaway%20is%20disabled.%26nbsp%3B%20My%20recollection%20is%20that%20if%20I%20controlled%20the%20process%20launch%2C%20the%20controls%20you%20show%20could%20be%20used%20to%20control%20breakaway%20previously%2C%20but%20now%20on%202004%20those%20controls%20are%20ignored.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1674078%22%20slang%3D%22en-US%22%3ERe%3A%20Are%20child%20processes%20%22break%20away%22%20or%20not%20by%20default%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1674078%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146612%22%20target%3D%22_blank%22%3E%40TIMOTHY%20MANGAN%3C%2FA%3E%26nbsp%3BThanks!%3CBR%20%2F%3EYeah%2C%20in%20the%20meantime%20I%20figured%20out%20that%20child%20process%20breaks%20away%20if%20the%20exe%20image%20is%20under%20AppData%20(i.e.%20LocalCache).%20The%20child%20process%20does%20NOT%20break%20away%20if%20the%20exe%20image%20is%20in%20VFS.%20This%20makes%20some%20sense.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3ESo%2C%20my%20%22only%22%20remaining%20problem%20is%20that%26nbsp%3BPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%20does%20not%20appear%20to%20work%20at%20all%20with%202004.%20The%20process%20launched%20with%20this%20flag%20does%20not%20%22see%22%20the%20containerized%20files%20and%20registry%20keys.%20I%20need%20this%20flag%20to%20work%20so%20that%20child%20processes%20whose%20exe%20image%20is%20in%20AppData%26nbsp%3B%20will%20remain%20in%20the%20container.%20At%20this%20point%2C%20I%20don't%20have%20any%20way%20to%20force%20this.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1674474%22%20slang%3D%22en-US%22%3ERe%3A%20Are%20child%20processes%20%22break%20away%22%20or%20not%20by%20default%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1674474%22%20slang%3D%22en-US%22%3E%3CP%3EFor%20good%20measure%2C%20I%20also%20tried%20to%20combine%26nbsp%3BPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%20%7C%20PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_OVERRIDE%20but%20it%20doesn't%20help.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThe%20documentation%20for%20PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%20is%20%22interesting%22.%20It%20doesn't%20say%20anything%20about%20the%20%22process%20being%20created%22.%20It%20only%20talks%20about%20child%20processes%20of%20the%20process%20being%20created.%20The%20documentation%20for%26nbsp%3BPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_OVERRIDE%20is%20does%20talk%20about%20the%20process%20being%20created%20so%20the%20combination%20should%20definitely%20work.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20appears%20to%20be%20a%20bug.%20Do%20you%20know%20how%20I%20can%20report%20these%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1674923%22%20slang%3D%22en-US%22%3ERe%3A%20Are%20child%20processes%20%22break%20away%22%20or%20not%20by%20default%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1674923%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F769820%22%20target%3D%22_blank%22%3E%40szilvaa%3C%2FA%3E%26nbsp%3BThere%20is%20a%20chance%20that%20one%20of%20the%20Microsoft%20Engineers%20will%20respond%20here%2C%20but%20running%20a%20test%20and%20then%20entering%20it%20using%20the%20Feedback%20Hub%20on%20your%20device%20would%20be%20the%20way%20to%20report%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20suspect%20that%20you%20will%20find%20that%20this%20is%20%22by%20design%22%20now.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAn%20interesting%20thing%20to%20look%20at%20is%20to%20use%20Process%20Explorer%20(started%20with%20RunAsAdmin)%20and%20look%20at%20the%20%22Jobs%22%20tab.%26nbsp%3B%20The%20Container%20is%20where%20Microsoft%20sets%20the%20Breakaway%20by%20setting%20it%20in%20the%20Job%20of%20the%20first%20process%20inside%20the%20container.%26nbsp%3B%20This%20is%20what%20changed%20in%202004.%26nbsp%3B%20Any%20breakaway%20controls%20placed%20on%20the%20job%20appear%20in%20the%20lower%20pane.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1704644%22%20slang%3D%22en-US%22%3ERe%3A%20Are%20child%20processes%20%22break%20away%22%20or%20not%20by%20default%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1704644%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146612%22%20target%3D%22_blank%22%3E%40TIMOTHY%20MANGAN%3C%2FA%3E%26nbsp%3BThanks%20for%20your%20responses!%20The%20Jobs%20tab%20in%20process%20explorer%20is%20nice%20debugging%20aid!%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20some%20more%20news%3A%3CBR%20%2F%3E%3CSPAN%3EI%20was%20able%20to%20confirm%20that%20%22Windows%20October%202020%20Update%22%20(aka%26nbsp%3B%3C%2FSPAN%3E%3CFONT%20color%3D%22%23FF0000%22%3E10.0.19042.541%3C%2FFONT%3E%3CSPAN%3E%26nbsp%3B)%20fixes%20the%20change%20in%20behavior%20(I%20think%20we%20can%20call%20it%20%22regression%22%20now)%26nbsp%3Bin%20Windows%2010%202004%20(aka%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E10.0.19041.508%3C%2FFONT%3E)%20affecting%20PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE%3CSTRONG%3E.%20%3C%2FSTRONG%3EThis%20flag%20works%20again%20as%20documented.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20guess%20MSIX%20isn't%20as%20mature%20as%20I%20expected%20it%20if%20major%20parts%20of%20the%20behavior%20can%20still%20regress%20like%20this.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

I'm experiencing some difference in behavior between Windows 10 2004 and earlier versions.
Here's my scenario:
I'm creating an MSIX package for my application. I want my main executable and all of its child processes to run inside the MSIX container. According to the docs here,  this supposed to be the default behavior. However, in my testing on Windows 10 1909 I found this to be NOT the case. So I created a little executable that simply calls CreateProcess with the PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE flag. This executable is pointed by my start menu shortcut. This fixed my problem on Win10 1909. My child processes happily run inside the container.

As an aside, the MSIX documentation above and the Win32 documentation appears to be in conflict:
The win32 documentation states:

PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_ENABLE_PROCESS_TREE 0x01

The process being created will create any child processes outside of the desktop app runtime environment. This behavior is the default for processes for which no policy has been set.


So if break-away is the default then child processes will NOT run inside a container.

Back the the real problem: on Windows 10 2004 my little launcher app does not work at all. Calling CreateProcess with PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE has the exact opposite affect than what's documented. The child process "breaks away" and does not see the files inside the container. If I use "null" attribute list, then I get the behavior I want.

Can anybody confirm this confusing variety of documentation and behaviors?

Here's the code for my launcher:

#include <iostream>
#include <cassert>
#include <vector>
#include <string>
#include <regex>

#define NTDDI_VERSION NTDDI_WIN10_RS2
#include <Windows.h>
#define ASSERT assert

LPPROC_THREAD_ATTRIBUTE_LIST MakeAttributeList()
{
    LPPROC_THREAD_ATTRIBUTE_LIST attrbuteList;
    SIZE_T AttributeListSize{};
    InitializeProcThreadAttributeList(nullptr, 1, 0, &AttributeListSize);
    attrbuteList = (LPPROC_THREAD_ATTRIBUTE_LIST)HeapAlloc(
        GetProcessHeap(),
        0,
        AttributeListSize
    );

    DWORD error = 0;
    if (!InitializeProcThreadAttributeList(
        attrbuteList,
        1,
        0,
        &AttributeListSize))
        throw GetLastError();

    DWORD attribute = PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE;
    if (!UpdateProcThreadAttribute(
        attrbuteList,
        0,
        PROC_THREAD_ATTRIBUTE_DESKTOP_APP_POLICY,
        &attribute,
        sizeof(attribute),
        nullptr,
        nullptr))
        throw GetLastError();

    return attrbuteList;
}

int wWinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPWSTR     lpCmdLine,
    int       nShowCmd)
{
    try
    {
        const int len = 4096;
        wchar_t buf[len];
        if (len == GetModuleFileName(0, buf, len))
            throw GetLastError();

        auto fname = std::regex_replace(buf, std::wregex(L"msixlauncher\\.exe"), L"dwgviewr.exe");
        STARTUPINFOEXW startup_info = {};
        PROCESS_INFORMATION process_info = {};
        startup_info.StartupInfo.cb = sizeof(startup_info);
        startup_info.lpAttributeList = MakeAttributeList();

        if (!::CreateProcess(
            fname.c_str(),
            nullptr,
            nullptr,
            nullptr,
            false,
            EXTENDED_STARTUPINFO_PRESENT,
            nullptr,
            nullptr,
            (STARTUPINFO*)&startup_info, // startup info
            &process_info  // process info
        ))
            throw GetLastError();

        WaitForSingleObject(process_info.hProcess, INFINITE);

        ::CloseHandle(process_info.hProcess);
        ::CloseHandle(process_info.hThread);
    }
    catch (DWORD err)
    {
        return err;
    }
    return 0;
}





7 Replies

@szilvaa I believe that this is a change in the 2004 Runtime.  

 

Prior to 2004 OS, my experience was that by default child processes would run outside of the container, but now on 2004 breakaway is disabled.  My recollection is that if I controlled the process launch, the controls you show could be used to control breakaway previously, but now on 2004 those controls are ignored.

@TIMOTHY MANGAN Thanks!
Yeah, in the meantime I figured out that child process breaks away if the exe image is under AppData (i.e. LocalCache). The child process does NOT break away if the exe image is in VFS. This makes some sense. 

So, my "only" remaining problem is that PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE does not appear to work at all with 2004. The process launched with this flag does not "see" the containerized files and registry keys. I need this flag to work so that child processes whose exe image is in AppData  will remain in the container. At this point, I don't have any way to force this.

For good measure, I also tried to combine PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE | PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_OVERRIDE but it doesn't help.

The documentation for PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE is "interesting". It doesn't say anything about the "process being created". It only talks about child processes of the process being created. The documentation for PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_OVERRIDE is does talk about the process being created so the combination should definitely work. 

This appears to be a bug. Do you know how I can report these?

@szilvaa There is a chance that one of the Microsoft Engineers will respond here, but running a test and then entering it using the Feedback Hub on your device would be the way to report this.

 

I suspect that you will find that this is "by design" now.

 

An interesting thing to look at is to use Process Explorer (started with RunAsAdmin) and look at the "Jobs" tab.  The Container is where Microsoft sets the Breakaway by setting it in the Job of the first process inside the container.  This is what changed in 2004.  Any breakaway controls placed on the job appear in the lower pane.

@TIMOTHY MANGAN Thanks for your responses! The Jobs tab in process explorer is nice debugging aid! 

I have some more news:
I was able to confirm that "Windows October 2020 Update" (aka 10.0.19042.541 ) fixes the change in behavior (I think we can call it "regression" now) in Windows 10 2004 (aka 10.0.19041.508) affecting PROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE. This flag works again as documented.

I guess MSIX isn't as mature as I expected it if major parts of the behavior can still regress like this.

@szilvaa Well yes, MSIX is a work in progress...

 

And I happened to notice  last night that an additional change was made to the PSF by Microsoft over the summer that looks like they are continuing to change things with breakaway.  I am unsure exactly what that change allows at present, but it would only be available on builds including the change, and we don't have any real "versions" with the PSF that we can specify to know if you are getting it.  I think the change was to allow more flexibility on configuring breakaway, at least on OS versions that allow it.

@TIMOTHY MANGAN Thanks! I don't use PSF. There are enough moving parts without it. :)