Repository: microsoft/terminal (language: cpp)

Issue:
WT crashes on saving settings when HKCU\Console is write-protected
### Windows Terminal version

1.18.1421.0 / 1.18.230522001-preview

### Windows build number

10.0.19045.2728

### Other Software

_No response_

### Steps to reproduce

Run WT.
Go to settings.
Press Save.

### Expected Behavior

Nothing - I haven't even changed anything.

### Actual Behavior

WT crashes:

<details>

```
Unhandled exception at 0x00007FF9356CFD12 (KernelBase.dll) in WindowsTerminal.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0000020EC6570320, 0x0000000000000002).
```

```
>	KernelBase.dll!RaiseFailFastException()	Unknown	Symbols loaded.
 	combase.dll!RoFailFastWithErrorContextInternal2(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 1455	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!DirectUI::ErrorHelper::ProcessUnhandledError(DirectUI::ErrorInfo & errorInfo={...}, unsigned int fSkipFailFastIfNoErrorContext=0, unsigned int * pfHandled=0x000000724dffc3b0) Line 616	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!DirectUI::ErrorHelper::ReportUnhandledError(HRESULT hrError=0xd0070005) Line 502	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CCoreServices::CLR_FireEvent(CDependencyObject * pListener=0x0000000000000000, EventHandle hEvent, CDependencyObject * pSender=0x0000020ec4c37840, CEventArgs * pArgs=0x0000020ec6328bf0, unsigned int flags=160) Line 3231	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CommonBrowserHost::CLR_FireEvent(CDependencyObject * pListener, EventHandle hEvent={...}, CDependencyObject * pSender, CEventArgs * pArgs=0x0000020ec6328bf0, unsigned int flags=160) Line 771	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CControlBase::ScriptCallback(void * pControl=0x0000020eb83671b8, CDependencyObject * pListener=0x0000000000000000, EventHandle hEvent, CDependencyObject * pSender=0x0000020ec4c37840, CEventArgs * pArgs=0x0000020ec6328bf0, int flags=160, IScriptObject * pScriptObject=0x0000000000000000, HRESULT(*)(CDependencyObject *, CEventArgs *) pInternalHandler=0x0000000000000000) Line 267	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::OnScriptCallback(CEventInfo *) Line 1338	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CXcpDispatcher::OnWindowMessage(HWND__ * msg, unsigned int wParam, unsigned __int64 lParam=490934880872, __int64) Line 1105	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::ProcessMessage(HWND__ *) Line 911	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CXcpDispatcher::WindowProc(HWND__ * hwnd=0x0000000000c3145a, unsigned int msg=1045, unsigned __int64 wParam=0, __int64 lParam=490934880872) Line 842	C++	Symbols loaded.
 	user32.dll!UserCallWinProcCheckWow()	Unknown	Symbols loaded.
 	user32.dll!DispatchClientMessage()	Unknown	Symbols loaded.
 	user32.dll!__fnDWORD()	Unknown	Symbols loaded.
 	ntdll.dll!KiUserCallbackDispatcherContinue()	Unknown	Symbols loaded.
 	win32u.dll!NtUserMessageCall()	Unknown	Symbols loaded.
 	user32.dll!SendMessageWorker(struct tagWND *,unsigned int,unsigned __int64,__int64,int)	Unknown	Symbols loaded.
 	user32.dll!SendMessageW()	Unknown	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::SendMessageW(unsigned int) Line 809	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CXcpBrowserHost::SyncScriptCallbackRequest(void * pVoidBH, CDependencyObject * pListener, EventHandle hEvent={...}, CDependencyObject * pSender=0x0000020ec4c37840, CEventArgs * pArgs=0x0000020ec6328bf0, int flags=160, IScriptObject * pScriptObject=0x0000000000000000, HRESULT(*)(CDependencyObject *, CEventArgs *) pHandler=0x0000000000000000) Line 1048	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CEventManager::RaiseControlEvents(EventHandle) Line 1133	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CEventManager::Raise(EventHandle hEvent, int bRefire=1, CDependencyObject * pSender=0x0000020ec4c37840, CEventArgs * pArgs=0x0000020ec6328bf0, bool fRaiseSync=true, bool fInputEvent=true, bool bAllowErrorFallback=true, CDependencyObject * pSenderOverride=0x0000000000000000) Line 887	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CEventManager::RaiseRoutedEventBubbling(EventHandle hEvent, CDependencyObject * pSource=0x0000020ec4c37840, CRoutedEventArgs * pArgs=0x0000020ec6328bf0, bool bIgnoreVisibility=false, bool fRaiseSync=true, bool fInputEvent=true, CDependencyObject * coerceToHandledAtElement=0x0000000000000000) Line 1334	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CEventManager::RaiseRoutedEvent(EventHandle) Line 1241	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CInputServices::RaiseDelayedPointerUpEvent(TouchInteractionMsg * pMsgGesture=0x000000724dffce30, CDependencyObject * pElement) Line 2664	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CInputServices::ProcessGestureInput(CDependencyObject * pElement=0x0000020ec61a14c0, TouchInteractionMsg * pMsg=0x000000724dffce30) Line 2415	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CInputServices::ProcessTouchInteractionCallback(const xref_ptr<CUIElement> & element={...}, TouchInteractionMsg * message=0x000000724dffce30) Line 2311	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CCoreServices::ProcessTouchInteractionCallback(const xref_ptr<CUIElement> & element, TouchInteractionMsg * message) Line 1018	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!GestureRecognizerAdapter::OnTapped(ElementGestureTracker * elementGestureTracker=0x0000020ec64e3aa0, Windows::UI::Input::IGestureRecognizer * args=0x0000020ec4eff960, Windows::UI::Input::ITappedEventArgs *) Line 162	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!GestureRecognizerAdapter::Init::__l3::<lambda_c84124b77aa695306b3da5613df6029b>::operator()(Windows::UI::Input::IGestureRecognizer *) Line 30	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::Foundation::ITypedEventHandler_impl<Windows::Foundation::Internal::AggregateType<Windows::UI::Input::GestureRecognizer *,Windows::UI::Input::IGestureRecognizer *>,Windows::Foundation::Internal::AggregateType<Windows::UI::Input::TappedEventArgs *,Windows::UI::Input::ITappedEventArgs *>>::*)(Windows::UI::Input::IGestureRecognizer *,Windows::UI::Input::ITappedEventArgs *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::Foundation::ITypedEventHandler<Windows::UI::Input::GestureRecognizer *,Windows::UI::Input::TappedEventArgs *>,Microsoft::WRL::FtmBase>,<lambda_c84124b77aa695306b3da5613df6029b> &,-1,Windows::UI::Input::IGestureRecognizer *,Windows::UI::Input::ITappedEventArgs *>::Invoke(Windows::UI::Input::IGestureRecognizer * <args_0>=0x00007ff91d861149, Windows::UI::Input::ITappedEventArgs * <args_1>) Line 245	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::ViewManagement::UISettings *,Windows::UI::ViewManagement::UISettingsMessageDurationChangedEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll::__l2::<lambda_af115b29ef429a3d47d88b1961613d6e>::operator()(Microsoft::WRL::ComPtr<IUnknown> &) Line 820	C++	Symbols loaded.
 	Windows.UI.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<<lambda_af115b29ef429a3d47d88b1961613d6e>,Windows::Foundation::ITypedEventHandler<Windows::UI::ViewManagement::UISettings *,Windows::UI::ViewManagement::UISettingsMessageDurationChangedEventArgs *>>(Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::ViewManagement::UISettings *,Windows::UI::ViewManagement::UISettingsMessageDurationChangedEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll::__l2::<lambda_af115b29ef429a3d47d88b1961613d6e> invokeOne={...}, Microsoft::WRL::Details::EventTargetArray * targetArray, Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::ViewManagement::UISettings *,Windows::UI::ViewManagement::UISettingsMessageDurationChangedEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>> * pEvent=0x0000020eb39ca610) Line 119	C++	Symbols loaded.
 	Windows.UI.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::ViewManagement::UISettings *,Windows::UI::ViewManagement::UISettingsMessageDurationChangedEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>>::DoInvoke<<lambda_af115b29ef429a3d47d88b1961613d6e>>(Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::ViewManagement::UISettings *,Windows::UI::ViewManagement::UISettingsMessageDurationChangedEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll::__l2::<lambda_af115b29ef429a3d47d88b1961613d6e> invokeOne={...}) Line 812	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::GestureRecognizer *,Windows::UI::Input::TappedEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll(Windows::UI::Input::GestureRecognizerServer * <args_0>=0x0000020eb39ca5e0, Windows::UI::Input::CTappedEventArgs * <args_1>=0x0000020ec4eff960) Line 820	C++	Symbols loaded.
 	Windows.UI.dll!Windows::UI::Input::GestureRecognizerServer::OnTappedEvent(Windows::Devices::Input::PointerDeviceType type=PointerDeviceType_Mouse, Windows::Foundation::Point position={...}, unsigned int tapCount=1, unsigned int contactCount=1) Line 2532	C++	Symbols loaded.
 	Windows.UI.dll!Windows::UI::Input::GestureRecognizerServer::OnOutput(const INTERACTION_CONTEXT_OUTPUT2 * output2=0x000000724dffd290) Line 961	C++	Symbols loaded.
 	Windows.UI.dll!Windows::UI::Input::GestureRecognizerServer::OutputCallback(void * clientData, const INTERACTION_CONTEXT_OUTPUT2 * output2) Line 874	C++	Symbols loaded.
 	ninput.dll!COutputConverter::Process(class CInteractionContextConfiguration const &,enum InteractionContextProperties::MeasurementUnits,enum CInteractionContextGlobal::FeedbackSettings,struct DigitizerInfo const *,struct INTERACTION_INPUT const *,unsigned int,unsigned int,unsigned int,struct INTERACTION_OUTPUT const &,int)	Unknown	Symbols loaded.
 	ninput.dll!CInteractionContextImpl::OutputCallback(void *,struct INTERACTION_OUTPUT const *)	Unknown	Symbols loaded.
 	ninput.dll!CInteractionGroupingFilter::_SendOutput(struct INTERACTION_OUTPUT const &)	Unknown	Symbols loaded.
 	ninput.dll!CInteractionGroupingFilter::_OnInput(struct INTERACTION_OUTPUT const &)	Unknown	Symbols loaded.
 	ninput.dll!COutputCoalescingFilter::Flush(void)	Unknown	Symbols loaded.
 	ninput.dll!COutputCoalescingFilter::_OnInput(struct INTERACTION_OUTPUT const &)	Unknown	Symbols loaded.
 	ninput.dll!CInteractionEngineImpl::DigitizerInput(enum DIGITIZER_KIND,unsigned __int64,unsigned int,unsigned int,struct INTERACTION_INPUT const *)	Unknown	Symbols loaded.
 	ninput.dll!CInteractionContextImpl::ProcessFrameHistory(unsigned int,unsigned int,struct tagPOINTER_INFO const *)	Unknown	Symbols loaded.
 	ninput.dll!CInteractionContextImpl::ProcessBufferedPackets(void)	Unknown	Symbols loaded.
 	ninput.dll!ProcessBufferedPacketsInteractionContext()	Unknown	Symbols loaded.
 	Windows.UI.dll!Windows::UI::Input::GestureRecognizerServer::ProcessUpEvent(Windows::UI::Input::IPointerPoint * value=0x0000020ec4f06400) Line 3243	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!ElementGestureTracker::ProcessPointerInformation(const InputMessage & msg={...}, Windows::UI::Input::IPointerPointStatics * const pointerPointStatics=0x0000020eb39acd98) Line 715	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!ElementGestureTracker::ProcessPointerMessage(const InputMessage & msg={...}, Windows::UI::Input::IPointerPointStatics * const pointerPointStatics=0x0000020eb39acd98) Line 91	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CInputServices::ProcessPointerMessagesWithInteractionEngine(unsigned int pMsg={...}, InputMessage * pInteractionElement=0x0000020ec61a14c0, CUIElement * pManipulationElement=0x0000020ec61a14c0, CUIElement * bIgnoreManipulationElement=1, unsigned int pInteractionContext={...}, ElementGestureTracker * bForceDisableGesture=0, unsigned int) Line 1993	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CInputServices::ProcessInteractionPointerMessages(unsigned int pointerId=1, InputMessage * pMsg=0x0000020ec64b47f0) Line 1759	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!ContentRootInput::PointerInputProcessor::ProcessPointerInput(InputMessage * pMsg=0x0000020ec64b47f0, int * handled=0x000000724dffede0) Line 716	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CInputServices::ProcessInput(InputMessage * pMsg, CContentRoot * contentRoot=0x0000020eb83c10f0, int * handled=0x000000724dffede0) Line 888	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CCoreServices::ProcessInput(InputMessage * pMessage, CContentRoot * contentRoot, int * fHandled) Line 992	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CXcpBrowserHost::HandleInputMessage(unsigned int uMsg=583, MsgPacket * pMsgPack=0x000000724dffee10, CContentRoot * contentRoot=0x0000020eb83c10f0, bool & fHandled) Line 1411	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CJupiterControl::HandlePointerMessage(unsigned int uMsg=583, unsigned __int64 wParam=1, __int64 lParam=0, CContentRoot * contentRoot=0x0000020eb83c10f0, Windows::UI::Input::IPointerPoint * pointerPoint=0x0000020ec4f06400, Windows::UI::Core::IPointerEventArgs * pointerArgs=0x0000020ec612c090) Line 750	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CJupiterWindow::OnIslandPointerMessage(unsigned int uMsg=583, CContentRoot * contentRoot=0x0000020eb83c10f0, Windows::UI::Core::IPointerEventArgs * args=0x0000020ec612c090) Line 2315	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!CXamlIslandRoot::InjectPointerMessage(unsigned int msg=583, Windows::UI::Core::IPointerEventArgs * args=0x0000020ec612c090) Line 617	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CXamlIslandRoot::OnIslandPointerReleased(IInspectable *) Line 563	C++	Symbols loaded.
 	[Inline Frame] Windows.UI.Xaml.dll!CXamlIslandRoot::SubscribeToPointerInputObserverEvents::__l43::<lambda_85fbf4d407c7e311044a83519608d385>::operator()(Windows::UI::Internal::Input::IPointerInputObserver *) Line 1406	C++	Symbols loaded.
 	Windows.UI.Xaml.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::Foundation::ITypedEventHandler_impl<Windows::Foundation::Internal::AggregateType<Windows::UI::Internal::Input::PointerInputObserver *,Windows::UI::Internal::Input::IPointerInputObserver *>,Windows::Foundation::Internal::AggregateType<Windows::UI::Core::PointerEventArgs *,Windows::UI::Core::IPointerEventArgs *>>::*)(Windows::UI::Internal::Input::IPointerInputObserver *,Windows::UI::Core::IPointerEventArgs *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::Foundation::ITypedEventHandler<Windows::UI::Internal::Input::PointerInputObserver *,Windows::UI::Core::PointerEventArgs *>,Microsoft::WRL::FtmBase>,<lambda_85fbf4d407c7e311044a83519608d385> &,-1,Windows::UI::Internal::Input::IPointerInputObserver *,Windows::UI::Core::IPointerEventArgs *>::Invoke(Windows::UI::Internal::Input::IPointerInputObserver * <args_0>, Windows::UI::Core::IPointerEventArgs * <args_1>=0x0000020ec612c090) Line 245	C++	Symbols loaded.
 	InputHost.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::Foundation::ITypedEventHandler_impl<Windows::Foundation::Internal::AggregateType<Windows::UI::Internal::Input::PointerInputObserver *,Windows::UI::Internal::Input::IPointerInputObserver *>,Windows::Foundation::Internal::AggregateType<Windows::UI::Core::PointerEventArgs *,Windows::UI::Core::IPointerEventArgs *>>::*)(Windows::UI::Internal::Input::IPointerInputObserver *,Windows::UI::Core::IPointerEventArgs *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::Foundation::ITypedEventHandler<Windows::UI::Internal::Input::PointerInputObserver *,Windows::UI::Core::PointerEventArgs *>,Microsoft::WRL::FtmBase>,<lambda_b5222d234632a4a0be2fddaf062a0811>,-1,Windows::UI::Internal::Input::IPointerInputObserver *,Windows::UI::Core::IPointerEventArgs *>::Invoke()	Unknown	Symbols loaded.
 	InputHost.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<class <lambda_02db4e955b30bd185b6cca5865064547>,struct Windows::Foundation::ITypedEventHandler<class Windows::UI::Internal::Input::KeyboardDockWatcher *,class Windows::UI::Internal::Input::KeyboardUndockedEventArgs *> >(class <lambda_02db4e955b30bd185b6cca5865064547>,class Microsoft::WRL::Details::EventTargetArray *,class Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Windows::UI::Internal::Input::KeyboardDockWatcher *,class Windows::UI::Internal::Input::KeyboardUndockedEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<-2> > *)	Unknown	Symbols loaded.
 	InputHost.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Windows::UI::Internal::Input::KeyboardDockWatcher *,class Windows::UI::Internal::Input::KeyboardUndockedEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<-2> >::DoInvoke<class <lambda_02db4e955b30bd185b6cca5865064547> >(class <lambda_02db4e955b30bd185b6cca5865064547>)	Unknown	Symbols loaded.
 	InputHost.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Windows::UI::Internal::Input::FocusObserver *,class Windows::UI::Internal::Input::FocusChangedEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<-2> >::InvokeAll<class FocusObserverWinRT<struct details::SystemTypes>::Api *,class FocusChangedEventArgs<struct details::SystemTypes> *>(class FocusObserverWinRT<struct details::SystemTypes>::Api *,class FocusChangedEventArgs<struct details::SystemTypes> *)	Unknown	Symbols loaded.
 	InputHost.dll!Microsoft::WRL2::ContextSession::LeaveSession_Callback<<lambda_dc5a5187f83b4b3afd6cedb0371c398d>>()	Unknown	Symbols loaded.
 	InputHost.dll!PointerInputObserverWinRT<struct details::SystemTypes>::OnPointerReleasedMessage_Callback(struct WindowsMessageDeliveryMessage *)	Unknown	Symbols loaded.
 	InputHost.dll!PointerInputObserverWinRT<struct details::SystemTypes>::OnWindowMessage(struct WindowsMessageDeliveryMessage *)	Unknown	Symbols loaded.
 	InputHost.dll!WindowsMessageDeliveryInputObject::Private::OnWindowMessage(struct WindowsMessageDeliveryMessage *)	Unknown	Symbols loaded.
 	InputHost.dll!<lambda>(void)()	Unknown	Symbols loaded.
 	InputHost.dll!InputSiteWinRT::ForEachAttachedObject(class std::function<enum InputSiteIterationDecision > const &)	Unknown	Symbols loaded.
 	InputHost.dll!WindowsMessageDeliveryInputSiteWinRT::OnWindowMessage(struct WindowsMessageDeliveryMessage *)	Unknown	Symbols loaded.
 	InputHost.dll!IslandInputSiteWinRTBase::OnWindowMessage(struct WindowsMessageDeliveryMessage *)	Unknown	Symbols loaded.
 	InputHost.dll!WindowsMessageDeliveryInputSiteWinRT::Private::OnWindowMessage(struct WindowsMessageDeliveryMessage *)	Unknown	Symbols loaded.
 	InputHost.dll!WindowsMessageDeliveryAdapter::ProcessWindowMessage(struct HWND__ *,unsigned int,unsigned __int64,__int64)	Unknown	Symbols loaded.
 	InputHost.dll!WindowsMessageDeliveryAdapter::StaticWndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)	Unknown	Symbols loaded.
 	user32.dll!UserCallWinProcCheckWow()	Unknown	Symbols loaded.
 	user32.dll!DispatchMessageWorker()	Unknown	Symbols loaded.
 	WindowsTerminal.exe!WindowThread::_messagePump() Line 86	C++	Symbols loaded.
 	[Inline Frame] WindowsTerminal.exe!WindowThread::RunMessagePump() Line 38	C++	Symbols loaded.
 	WindowsTerminal.exe!WindowEmperor::_createNewWindowThread::__l2::<lambda_1>::operator()() Line 173	C++	Symbols loaded.
 	[Inline Frame] WindowsTerminal.exe!std::invoke(WindowEmperor::_createNewWindowThread::__l2::<lambda_1> &&) Line 1562	C++	Non-user code. Symbols loaded.
 	WindowsTerminal.exe!std::thread::_Invoke<std::tuple<`WindowEmperor::_createNewWindowThread'::`2'::<lambda_1>>,0>(void * _RawVals=0x0000020eb82c5740) Line 56	C++	Non-user code. Symbols loaded.
 	ucrtbase.dll!thread_start<unsigned int (__cdecl*)(void *),1>()	Unknown	Non-user code. Symbols loaded without source information.
 	kernel32.dll!BaseThreadInitThunk()	Unknown	Non-user code. Symbols loaded without source information.
 	ntdll.dll!RtlUserThreadStart()	Unknown	Non-user code. Symbols loaded without source information.
```
</details>

Removing settings.json does not help, but running as a different user does.
This is probably not a recent regression, I can reproduce it on 1.17 as well.


Discussion / hints:
> but running as a different user does

well THAT is interesting, for sure. Are we talking something like "over the shoulder" running as another user (i.e. you're logged in as "Desktop\Foo" but then run the Terminal as "Desktop\Bar", or as "Desktop\MyAdminAccount")? Or just, you have two users, this repros for one of them, but not the other?

A /Feedback Hub dump _might_ be helpful - if anything, it might link us to an existing bug. 

There's... basically none of our code in that stack. That makes me think this might be a platform bug, but which?

A possibly dumb question - did you _tap_ save, like, with a touch screen? Or use a mouse?

---

misc notes:
* MSFT:44808462 - open, the same stack (more or less), but definitely not us
> you're logged in as "Desktop\Foo" but then run the Terminal as "Desktop\Bar"

Yes.

> A possibly dumb question - did you tap save, like, with a touch screen? Or use a mouse?

Just a mouse.


Do you happen to have a dump or the ability to capture one? Alternatively, I'd settle for a Windows Error Reporting bucket ID (from the event viewer).

This is definitely us -- not XAML, probably -- but we don't know much beyond that from this stack.
Will this one do?
[WindowsTerminal.dmp.zip](https://github.com/microsoft/terminal/files/11619218/WindowsTerminal.dmp.zip)

Close! I'm looking at it now, and as a minidump it doesn't have a bunch of the more helpful stuff.

Still, though, it does have this...

```
$$ At this frame
03 000000e4`601fc540 00007ff9`198a24ec     Windows_UI_Xaml!DirectUI::ErrorHelper::ReportUnhandledError+0xf1 [onecoreuap\windows\dxaml\xcp\dxaml\lib\errorhelper.cpp @ 502] 

$$ ?? errorInfo
class xxx::ErrorInfo
   +0x000 m_spErrorInfo    : ComPtr<IErrorInfo>
   +0x008 m_ErrorInfoInitialized : 0n1
   +0x010 m_spRestrictedErrorInfo : ComPtr<IRestrictedErrorInfo>
   +0x018 m_RestrictedErrorInfoInitialized : 0n1
   +0x020 m_description    : xxx
   +0x028 m_restrictedDescription : xxx
   +0x030 m_ErrorCode      : d0070005
   +0x034 m_ErrorDetailsInitialized : 0n1
```

Most of the members that are heap allocated--strings, etc--are missing... but that error code is shouting `ACCESSDENIED` at me.

Can you share the output of `icacls actual\path\to\settings.json` for the instance of Terminal that is failing like this?
I can record a full dump, just wasn't sure github can handle a ~60MB zip attachment.

The output is:
```
NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
AA51M\Alex:(I)(F)
```
_Interesting_. That set of ACLs should work fine. I guess I'd be interested in the enclosing folder as well (since we try to do an atomic write!)

GitHub should be able to handle that size attachment, but if not my e-mail address is on my GitHub profile! :smile:

> the enclosing folder as well

```
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
BUILTIN\Administrators:(I)(OI)(CI)(F)
AA51M\Alex:(I)(OI)(CI)(F)
```
> GitHub should be able to handle that size attachment

It says "25 MB are allowed".
Can you access this: https://file.io/LpFyCGYknwqG?
If not I'll try e-mail.
> Most of the members that are heap allocated--strings, etc--are missing... but that error code is shouting ACCESSDENIED at me.

Indeed, d0070005 looks like ERROR_ACCESS_DENIED, packed into NTSTATUS with Facility = FACILITY_NTWIN32, Severity=Error, packed again into HRESULT.
The string isn't that exciting though: "The text associated with this error code could not be found..."
Ugh, found it.
It was trying to create a registry key, `HKEY_CURRENT_USER\Console\%%Startup`, and creating subkeys under "Console" was denied (for unrelated reasons).
OHHHH booy. Okay. Are those reasons that would impact, say, a user who has never used Terminal on their machine? Or are those "@alabuzhev reasons" ;P
"I can explain!"

In previous Windows versions, when you open console properties and change something, it was always asking you "Apply properties to current window only" / "Save properties for future windows with same title":

![image](https://github.com/microsoft/terminal/assets/11453922/b843f31d-b66a-4d97-8862-490d4768fa8b)

It was quite useful: if you need to experiment with console settings (and if you develop non-trivial console apps, affected by those settings - you do), you just choose "current window only", and all your silly experiments disappear when you close this console window.

But in newer Windows versions that useful confirmation was removed for unknown reason and the properties are now always quietly saved as if "save for future windows with the same title" was chosen, meaning that all your silly experiments are now persisted immediately and you have to undo them later manually like an idiot. It is no longer possible to make changes *for the current session only*.

Denying "Create subkey" for "Console" is a quick and dirty workaround to say "no, please don't save anything into registry, thank you very much".

By the way, was removing that confirmation a deliberate design decision?
Any chance to get it back?
> Are those reasons that would impact, say, a user who has never used Terminal on their machine?

Maybe, who knows. I shared this workaround with a few people, someone else could have discovered it independently.
> By the way, was removing that confirmation a deliberate design decision?
> Any chance to get it back?

That is an excellent question!

I can't get at the Vista source depot right now, but I _can_ see that it disappeared sometime between Windows Server 2003 and Windows 7. My tooling isn't working quite right, so I can't find the exact changeset that removed it. If I get it working again (🙄) I'll dig further.
I'm taking `Attention` off this and committing it to the triaged list. We should, at the very least, not crash.

Fix patch:
diff --git a/src/cascadia/TerminalSettingsModel/DefaultTerminal.cpp b/src/cascadia/TerminalSettingsModel/DefaultTerminal.cpp
index 7ab0a0b15dc..754ed7cbd82 100644
--- a/src/cascadia/TerminalSettingsModel/DefaultTerminal.cpp
+++ b/src/cascadia/TerminalSettingsModel/DefaultTerminal.cpp
@@ -99,7 +99,9 @@ bool DefaultTerminal::HasCurrent()
 
 void DefaultTerminal::Current(const Model::DefaultTerminal& term)
 {
-    THROW_IF_FAILED(DelegationConfig::s_SetDefaultByPackage(winrt::get_self<DefaultTerminal>(term)->_pkg));
+    // Just log if we fail to write the defterm configuration. It's not worth
+    // exploding over if the regkey is write-protected or something.
+    LOG_IF_FAILED(DelegationConfig::s_SetDefaultByPackage(winrt::get_self<DefaultTerminal>(term)->_pkg));
 
     TraceLoggingWrite(g_hSettingsModelProvider,
                       "DefaultTerminalChanged",


Test patch: