From b6feabe9cc9e1de97489d39724e96d3ae1066571 Mon Sep 17 00:00:00 2001 From: Kieren Wou Date: Tue, 29 Nov 2022 19:34:29 +0000 Subject: [PATCH 01/10] Merged PR 8188601: [Git2Git] !8082133: LKG14 Build Fix - ARM64EC does not support AVX Arm64EC does not support AVX and the usage of it in EC compilation is now an error with the LKG14 compiler update. The fix is to conditionalize using AVX for non-EC compilation. Related work items: MSFT-42045281 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 31ca1e08e001988b95ff29a5e098441cae0363bd --- oss/libpopcnt/libpopcnt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oss/libpopcnt/libpopcnt.h b/oss/libpopcnt/libpopcnt.h index ffcd976b03..de24253d9a 100644 --- a/oss/libpopcnt/libpopcnt.h +++ b/oss/libpopcnt/libpopcnt.h @@ -95,7 +95,7 @@ #define HAVE_AVX512 #endif -#if defined(X86_OR_X64) +#if defined(X86_OR_X64) && !defined(_M_ARM64EC) /* MSVC compatible compilers (Windows) */ #if defined(_MSC_VER) /* clang-cl (LLVM 10 from 2020) requires /arch:AVX2 or From 3c104440a897e551b867225d9fb8cfe4ff158dd8 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Tue, 29 Nov 2022 22:07:37 +0000 Subject: [PATCH 02/10] Merged PR 8189936: [Git2Git] Lift an optional check out of RefreshRowIDs loop to fix a crash In the most recent compiler ingestion into Windows ("LKG14"), we found that this particular construction--checking an optional for a value during this range-for loop--resulted in bad code generation. When optimized, it generates code that looks effectively like this: ```c++ if (!newRowWidth.has_value()) { while (true) { // do the row stuff... ++it; } } ``` The loop never exits, and `_RefreshRowIDs` walks off the end of the buffer. Whoops. This commit fixes that issue by tricking the optimizer to go another way. Leonard tells me it's harmless to call `Resize` a bunch of times, even if it's a no-op, so I trust that this change results in the right outcome with none of the crashing. Fixes MSFT-41456525 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 c2b3697c867bddf5660da8b222e99ff4bfd1ea5b --- src/buffer/out/textBuffer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index 21f153d179..ce7a8ed980 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -1032,6 +1032,7 @@ void TextBuffer::_RefreshRowIDs(std::optional newRowWidth) { std::unordered_map rowMap; til::CoordType i = 0; + til::CoordType newWidth = newRowWidth.value_or(_storage.at(0).size()); for (auto& it : _storage) { // Build a map so we can update Unicode Storage @@ -1043,12 +1044,13 @@ void TextBuffer::_RefreshRowIDs(std::optional newRowWidth) // Also update the char row parent pointers as they can get shuffled up in the rotates. it.GetCharRow().UpdateParent(&it); - // Resize the rows in the X dimension if we have a new width - if (newRowWidth.has_value()) - { - // Realloc in the X direction - THROW_IF_FAILED(it.Resize(newRowWidth.value())); - } + // Realloc in the X direction + // BODGY: We unpack the optional early and resize here unconditionally + // due to a codegen issue in LKG14. We used to check the optional in + // every iteration of the loop, but that resulted in the optimizer + // emitting a copy of the loop, used when the optional was empty, that + // never exited. Oops. + THROW_IF_FAILED(it.Resize(newWidth)); } // Give the new mapping to Unicode Storage From 154ac2b9160177c079f1a93436a0b6240761c5a2 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Wed, 15 Feb 2023 19:15:28 +0000 Subject: [PATCH 03/10] Merged PR 8428085: [Git2Git] Fix a GDI font object leak in FontInfo "Leak in font object 1952 times in last 2k GDI objects created, that lead console to run out of GDI objects." Fixes MSFT-42906562 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 44f47bf7dbe4bff1986ba5fd8940b56f854c58b7 --- src/propsheet/misc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/propsheet/misc.cpp b/src/propsheet/misc.cpp index 1dd7ff4b71..17d089e379 100644 --- a/src/propsheet/misc.cpp +++ b/src/propsheet/misc.cpp @@ -398,6 +398,10 @@ CreateBoldFont: /* * Store the font info */ + if (FontInfo[nFont].hFont != nullptr) + { + DeleteObject(FontInfo[nFont].hFont); + } FontInfo[nFont].hFont = hFont; FontInfo[nFont].Family = tmFamily; FontInfo[nFont].Size = SizeActual; From 553ad121afabe7f73f1e8039c7b902f88977620a Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Tue, 7 Mar 2023 17:54:31 +0000 Subject: [PATCH 04/10] Merged PR 8603508: [Git2Git] Merged PR 8535345: More scrubbing of ONECORE_PRIV_SDK_INC_PATH I have been working feverishly to remove the use of undefined macros used in sources\dirs files (such as this one ONECORE_PRIV_SDK_INC_PATH) that our telemetry constantly catches and reports as an issue. Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 bb08e422cfb4dc2f8b99a2c34bac67a61654a572 Related work items: MSFT-40126326 --- src/host/ft_integrity/sources | 1 - src/tsf/sources | 1 - 2 files changed, 2 deletions(-) diff --git a/src/host/ft_integrity/sources b/src/host/ft_integrity/sources index a7eddd8bef..0dcd996d5c 100644 --- a/src/host/ft_integrity/sources +++ b/src/host/ft_integrity/sources @@ -33,7 +33,6 @@ INCLUDES=\ $(COM_INC_PATH); \ $(ONECOREBASE_INTERNAL_INC_PATH_L)\appmodel\test\common; \ $(ONECOREREDIST_INTERNAL_INC_PATH_L)\TAEF; \ - $(ONECORE_PRIV_SDK_INC_PATH); \ $(MINCORE_INTERNAL_PRIV_SDK_INC_PATH_L); \ TARGETLIBS=\ diff --git a/src/tsf/sources b/src/tsf/sources index d18e015d2c..54c7916209 100644 --- a/src/tsf/sources +++ b/src/tsf/sources @@ -53,7 +53,6 @@ SOURCES = \ INCLUDES = \ $(INCLUDES); \ ..\inc; \ - $(ONECORE_PRIV_SDK_INC_PATH); \ $(MINWIN_INTERNAL_PRIV_SDK_INC_PATH_L); \ $(SDK_INC_PATH)\atl30; \ $(ONECORE_EXTERNAL_SDK_INC_PATH)\atl30; \ From 7aada2fd1e432fdc72383da411fec5d78c7c072d Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Tue, 7 Mar 2023 19:00:36 +0000 Subject: [PATCH 05/10] Merged PR 8612870: [Git2Git] Update WIL's get_token_info output type A customer reports that `wil::get_token_information` and its use of `wistd::unique_ptr` is hitting a code analysis error in that dynamically-sized token information blocks are allocated with `operator new` but deleted with `delete T*`. This is a "mismatched allocator" error and should be removed. ## What changed? The output type of token information changed from `wistd::unique_ptr` to `wil::unique_tokeninfo_ptr` which has a custom deleter that uses `operator delete(p)` to match the allocator. As the new type is incompatible with the old type, all call sites for `wil::GetTokenInformation` were updated to use the new type. ## How was the change tested? 1. Ran the WIL unit tests 2. Prime build of impacted directories Related: https://github.com/microsoft/wil/pull/306 Related: https://github.com/microsoft/wil/issues/276 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 d86d562b7559c2ca8de036085de6e52e80da8c93 --- src/host/ft_integrity/IntegrityTest.cpp | 2 +- src/tools/integrity/lib/util.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/host/ft_integrity/IntegrityTest.cpp b/src/host/ft_integrity/IntegrityTest.cpp index be3db377fe..0ca45b0b5d 100644 --- a/src/host/ft_integrity/IntegrityTest.cpp +++ b/src/host/ft_integrity/IntegrityTest.cpp @@ -312,7 +312,7 @@ PCWSTR IntegrityTest::s_GetMyIntegrityLevel() DWORD dwIntegrityLevel = 0; // Get the Integrity level. - wistd::unique_ptr tokenLabel; + wil::unique_tokeninfo_ptr tokenLabel; THROW_IF_FAILED(wil::GetTokenInformationNoThrow(tokenLabel, GetCurrentProcessToken())); dwIntegrityLevel = *GetSidSubAuthority(tokenLabel->Label.Sid, diff --git a/src/tools/integrity/lib/util.cpp b/src/tools/integrity/lib/util.cpp index 3ea8e4c6e9..557ce8061b 100644 --- a/src/tools/integrity/lib/util.cpp +++ b/src/tools/integrity/lib/util.cpp @@ -14,7 +14,7 @@ PCWSTR GetIntegrityLevel() DWORD dwIntegrityLevel = 0; // Get the Integrity level. - wistd::unique_ptr tokenLabel; + wil::unique_tokeninfo_ptr tokenLabel; THROW_IF_FAILED(wil::GetTokenInformationNoThrow(tokenLabel, GetCurrentProcessToken())); dwIntegrityLevel = *GetSidSubAuthority(tokenLabel->Label.Sid, From a132ba82e7b80df154d514fc78996a093c4cf4e3 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Wed, 15 Mar 2023 17:06:21 +0000 Subject: [PATCH 06/10] Merged PR 8628818: [Git2Git] Merged PR 8561941: Scrubs SDKTOOLS_INC_PATH from onecore, onecoreuap I have been working feverishly to remove the use of undefined macros used in sources\dirs files (such as this one SDKTOOLS_INC_PATH) that our telemetry constantly catches and reports as an issue. Related work items: MSFT-40126326 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 8589e01e23c4ec64ad270dbf0c1beb8a78b5a833 --- src/terminal/adapter/ut_adapter/sources | 1 - 1 file changed, 1 deletion(-) diff --git a/src/terminal/adapter/ut_adapter/sources b/src/terminal/adapter/ut_adapter/sources index 2f3850c2d6..a0618ffe43 100644 --- a/src/terminal/adapter/ut_adapter/sources +++ b/src/terminal/adapter/ut_adapter/sources @@ -144,7 +144,6 @@ DLOAD_ERROR_HANDLER = kernelbase #INCLUDES = $(INCLUDES); \ # ..\..\..\inc; \ -# $(SDKTOOLS_INC_PATH)\WexTest\Cue; \ # #SOURCES = $(SOURCES) \ # From 4b58fc6c8ef82088bb1f4968bc6991e675cc45c0 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Wed, 25 Oct 2023 13:31:53 -0500 Subject: [PATCH 07/10] Migrate sources.dep changes from OS --- src/host/ft_host/sources.dep | 3 --- src/host/ft_integrity/sources.dep | 6 ------ src/tools/vtapp/sources.dep | 3 --- 3 files changed, 12 deletions(-) delete mode 100644 src/host/ft_integrity/sources.dep delete mode 100644 src/tools/vtapp/sources.dep diff --git a/src/host/ft_host/sources.dep b/src/host/ft_host/sources.dep index 11b0599b17..bc61c95c6b 100644 --- a/src/host/ft_host/sources.dep +++ b/src/host/ft_host/sources.dep @@ -1,6 +1,3 @@ BUILD_PASS1_CONSUMES= \ onecore\windows\vcpkg|PASS1 \ -BUILD_PASS2_CONSUMES= \ - onecore\windows\core\console\open\src\tools\nihilist|PASS2 \ - diff --git a/src/host/ft_integrity/sources.dep b/src/host/ft_integrity/sources.dep deleted file mode 100644 index 83c5a0a70e..0000000000 --- a/src/host/ft_integrity/sources.dep +++ /dev/null @@ -1,6 +0,0 @@ -PUBLIC_PASS1_CONSUMES= \ - onecore\base\appmodel\test\common\testhelper\winrt\private|PASS1 \ - -BUILD_PASS2_CONSUMES= \ - onecore\base\appmodel\test\common\testhelper\samples\nativecxapp\appx|PASS2 \ - diff --git a/src/tools/vtapp/sources.dep b/src/tools/vtapp/sources.dep deleted file mode 100644 index 5aef2e2c5c..0000000000 --- a/src/tools/vtapp/sources.dep +++ /dev/null @@ -1,3 +0,0 @@ -PUBLIC_PASS0_CONSUMES= \ - onecore\redist\mspartners\netfx45\core\binary_release|PASS0 \ - From 68b5e587543c8e8901a6d8b829f52d94662321e3 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Fri, 27 Oct 2023 22:20:07 +0000 Subject: [PATCH 08/10] Merged PR 9792152: [Git2Git] Build fixes on top of 188a2ae4c Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 3fc4bb99c75451d0ecadd7e4c8fe06ad67217574 Related work items: MSFT-47266988 --- src/host/ft_host/sources | 1 + src/host/ft_integrity/IntegrityTest.cpp | 12 ++++++------ src/host/sources.inc | 1 + src/inc/HostAndPropsheetIncludes.h | 2 ++ src/inc/LibraryIncludes.h | 3 +++ src/interactivity/onecore/precomp.h | 3 +++ .../win32/ut_interactivity_win32/sources | 1 + src/project.inc | 2 +- src/terminal/adapter/ut_adapter/sources | 1 + src/terminal/parser/ut_parser/sources | 1 + src/types/sources.inc | 1 - 11 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/host/ft_host/sources b/src/host/ft_host/sources index beeba4e675..ba6cf411af 100644 --- a/src/host/ft_host/sources +++ b/src/host/ft_host/sources @@ -55,4 +55,5 @@ TARGETLIBS = \ DELAYLOAD = \ $(DELAYLOAD) \ + icu.dll; \ ext-ms-win-rtcore-ntuser-dpi-l1.dll; \ diff --git a/src/host/ft_integrity/IntegrityTest.cpp b/src/host/ft_integrity/IntegrityTest.cpp index c5cc24d48d..0ca45b0b5d 100644 --- a/src/host/ft_integrity/IntegrityTest.cpp +++ b/src/host/ft_integrity/IntegrityTest.cpp @@ -214,14 +214,14 @@ void IntegrityTest::_TestValidationHelper(const bool fIsBlockExpected, GetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &csbiex); - LOG_OUTPUT(L"Buffer Size X:%d Y:%d", csbiex.dwSize.width, csbiex.dwSize.height); + LOG_OUTPUT(L"Buffer Size X:%d Y:%d", csbiex.dwSize.X, csbiex.dwSize.Y); - size_t cch = csbiex.dwSize.width; + size_t cch = csbiex.dwSize.X; wistd::unique_ptr stringData = wil::make_unique_nothrow(cch); THROW_IF_NULL_ALLOC(stringData); COORD coordRead = { 0 }; - for (coordRead.y = 0; coordRead.y < 8; coordRead.y++) + for (coordRead.Y = 0; coordRead.Y < 8; coordRead.Y++) { ZeroMemory(stringData.get(), sizeof(wchar_t) * cch); @@ -237,7 +237,7 @@ void IntegrityTest::_TestValidationHelper(const bool fIsBlockExpected, WEX::Common::String strActual; // At position 0, check the integrity. - if (coordRead.y == 0) + if (coordRead.Y == 0) { strExpected = pwszIntegrityExpected; } @@ -246,11 +246,11 @@ void IntegrityTest::_TestValidationHelper(const bool fIsBlockExpected, // For the rest, check whether the API call worked. if (fIsBlockExpected) { - strExpected = _rgpwszExpectedFail[coordRead.y - 1]; + strExpected = _rgpwszExpectedFail[coordRead.Y - 1]; } else { - strExpected = _rgpwszExpectedSuccess[coordRead.y - 1]; + strExpected = _rgpwszExpectedSuccess[coordRead.Y - 1]; } } stringData[strExpected.GetLength()] = L'\0'; diff --git a/src/host/sources.inc b/src/host/sources.inc index bf3b16bcae..e3a878161e 100644 --- a/src/host/sources.inc +++ b/src/host/sources.inc @@ -198,6 +198,7 @@ DELAYLOAD = \ DXGI.dll; \ OLEAUT32.dll; \ PROPSYS.dll; \ + icu.dll; \ api-ms-win-core-com-l1.dll; \ api-ms-win-core-registry-l2.dll; \ api-ms-win-mm-playsound-l1.dll; \ diff --git a/src/inc/HostAndPropsheetIncludes.h b/src/inc/HostAndPropsheetIncludes.h index 2a8d588b30..d0480421df 100644 --- a/src/inc/HostAndPropsheetIncludes.h +++ b/src/inc/HostAndPropsheetIncludes.h @@ -14,7 +14,9 @@ #include #undef WIN32_NO_STATUS +#ifndef NO_WINTERNL_INBOX_BUILD #include +#endif #pragma warning(push) #pragma warning(disable:4430) // Must disable 4430 "default int" warning for C++ because ntstatus.h is inflexible SDK definition. diff --git a/src/inc/LibraryIncludes.h b/src/inc/LibraryIncludes.h index 7a7ec3a6a5..511e4d4d95 100644 --- a/src/inc/LibraryIncludes.h +++ b/src/inc/LibraryIncludes.h @@ -18,7 +18,9 @@ // Block minwindef.h min/max macros to prevent conflict #define NOMINMAX // Exclude rarely-used stuff from Windows headers +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #include @@ -65,6 +67,7 @@ // GSL // Block GSL Multi Span include because it both has C++17 deprecated iterators // and uses the C-namespaced "max" which conflicts with Windows definitions. +#include #include #include diff --git a/src/interactivity/onecore/precomp.h b/src/interactivity/onecore/precomp.h index 7a19e74643..6883aa0972 100644 --- a/src/interactivity/onecore/precomp.h +++ b/src/interactivity/onecore/precomp.h @@ -10,13 +10,16 @@ #include #include #include +#define WIN32_NO_STATUS #include +#undef WIN32_NO_STATUS #include "wchar.h" // Extension presence detection #include #define _DDK_INCLUDED +#define NO_WINTERNL_INBOX_BUILD #include "../../host/precomp.h" #else diff --git a/src/interactivity/win32/ut_interactivity_win32/sources b/src/interactivity/win32/ut_interactivity_win32/sources index 4b988d1672..0bfe9148ea 100644 --- a/src/interactivity/win32/ut_interactivity_win32/sources +++ b/src/interactivity/win32/ut_interactivity_win32/sources @@ -110,6 +110,7 @@ DELAYLOAD = \ DXGI.dll; \ D3D11.dll; \ OLEAUT32.dll; \ + icu.dll; \ api-ms-win-mm-playsound-l1.dll; \ api-ms-win-shcore-scaling-l1.dll; \ api-ms-win-shell-dataobject-l1.dll; \ diff --git a/src/project.inc b/src/project.inc index b604f50ea6..4425c3f804 100644 --- a/src/project.inc +++ b/src/project.inc @@ -32,7 +32,7 @@ USE_NATIVE_EH = 1 USE_STD_CPP20 = 1 MSC_WARNING_LEVEL = /W4 /WX -USER_C_FLAGS = $(USER_C_FLAGS) /fp:contract /utf-8 +USER_C_FLAGS = $(USER_C_FLAGS) /Zc:preprocessor /fp:contract /utf-8 # ------------------------------------- # Common Console Includes and Libraries diff --git a/src/terminal/adapter/ut_adapter/sources b/src/terminal/adapter/ut_adapter/sources index a0618ffe43..81cb43dcfa 100644 --- a/src/terminal/adapter/ut_adapter/sources +++ b/src/terminal/adapter/ut_adapter/sources @@ -105,6 +105,7 @@ DELAYLOAD = \ DXGI.dll; \ D3D11.dll; \ OLEAUT32.dll; \ + icu.dll; \ api-ms-win-mm-playsound-l1.dll; \ api-ms-win-shcore-scaling-l1.dll; \ api-ms-win-shell-dataobject-l1.dll; \ diff --git a/src/terminal/parser/ut_parser/sources b/src/terminal/parser/ut_parser/sources index 1c63146466..e754a4e01c 100644 --- a/src/terminal/parser/ut_parser/sources +++ b/src/terminal/parser/ut_parser/sources @@ -96,6 +96,7 @@ DELAYLOAD = \ DXGI.dll; \ D3D11.dll; \ OLEAUT32.dll; \ + icu.dll; \ api-ms-win-mm-playsound-l1.dll; \ api-ms-win-shcore-scaling-l1.dll; \ api-ms-win-shell-dataobject-l1.dll; \ diff --git a/src/types/sources.inc b/src/types/sources.inc index 6527fbed57..44f252a2a1 100644 --- a/src/types/sources.inc +++ b/src/types/sources.inc @@ -31,7 +31,6 @@ SOURCES= \ ..\CodepointWidthDetector.cpp \ ..\ColorFix.cpp \ ..\GlyphWidth.cpp \ - ..\ModifierKeyState.cpp \ ..\Viewport.cpp \ ..\convert.cpp \ ..\colorTable.cpp \ From 65e19ddaf0edab64b6361a17ecb0f6e67179aaa6 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Wed, 15 Nov 2023 21:32:10 +0000 Subject: [PATCH 09/10] Merged PR 9880704: [Git2Git] conhost: remove all EOL velocity keys I've also removed all of the supporting code. Related work items: MSFT-47555635 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 f8ad0110fd81d1b848224158c8f95724f34b1db2 --- src/host/exe/exemain.cpp | 2 +- src/host/srvinit.cpp | 4 ++-- src/inc/conint.h | 6 ------ src/internal/stubs.cpp | 15 --------------- src/propsheet/console.cpp | 19 +++---------------- 5 files changed, 6 insertions(+), 40 deletions(-) diff --git a/src/host/exe/exemain.cpp b/src/host/exe/exemain.cpp index 7aaa45271d..a30680a40a 100644 --- a/src/host/exe/exemain.cpp +++ b/src/host/exe/exemain.cpp @@ -276,7 +276,7 @@ int CALLBACK wWinMain( { // Only try to register as a handoff target if we are NOT a part of Windows. #if TIL_FEATURE_RECEIVEINCOMINGHANDOFF_ENABLED - if (args.ShouldRunAsComServer() && Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy()) + if (args.ShouldRunAsComServer()) { try { diff --git a/src/host/srvinit.cpp b/src/host/srvinit.cpp index 284f448382..afb505ad14 100644 --- a/src/host/srvinit.cpp +++ b/src/host/srvinit.cpp @@ -64,7 +64,7 @@ try // Check if this conhost is allowed to delegate its activities to another. // If so, look up the registered default console handler. - if (Globals.delegationPair.IsUndecided() && Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy()) + if (Globals.delegationPair.IsUndecided()) { Globals.delegationPair = DelegationConfig::s_GetDelegationPair(); @@ -82,7 +82,7 @@ try // If we looked up the registered defterm pair, and it was left as the default (missing or {0}), // AND velocity is enabled for DxD, then we switch the delegation pair to Terminal and // mark that we should check that class for the marker interface later. - if (Globals.delegationPair.IsDefault() && Microsoft::Console::Internal::DefaultApp::CheckShouldTerminalBeDefault()) + if (Globals.delegationPair.IsDefault()) { Globals.delegationPair = DelegationConfig::TerminalDelegationPair; Globals.defaultTerminalMarkerCheckRequired = true; diff --git a/src/inc/conint.h b/src/inc/conint.h index 2a3c8d0fd5..68d9745fcf 100644 --- a/src/inc/conint.h +++ b/src/inc/conint.h @@ -44,10 +44,4 @@ namespace Microsoft::Console::Internal { [[nodiscard]] HRESULT TrySetDarkMode(HWND hwnd) noexcept; } - - namespace DefaultApp - { - [[nodiscard]] bool CheckDefaultAppPolicy() noexcept; - [[nodiscard]] bool CheckShouldTerminalBeDefault() noexcept; - } } diff --git a/src/internal/stubs.cpp b/src/internal/stubs.cpp index f0cf811b01..c7b5dcfaff 100644 --- a/src/internal/stubs.cpp +++ b/src/internal/stubs.cpp @@ -29,18 +29,3 @@ void EdpPolicy::AuditClipboard(const std::wstring_view /*destinationName*/) noex { return S_FALSE; } - -[[nodiscard]] bool DefaultApp::CheckDefaultAppPolicy() noexcept -{ - // True so propsheet will show configuration options but be sure that - // the open one won't attempt handoff from double click of OpenConsole.exe - return true; -} - -[[nodiscard]] bool DefaultApp::CheckShouldTerminalBeDefault() noexcept -{ - // False since setting Terminal as the default app is an OS feature and probably - // should not be done in the open source conhost. We can always decide to turn it - // on in the future though. - return false; -} diff --git a/src/propsheet/console.cpp b/src/propsheet/console.cpp index 68b146c2e1..d605844059 100644 --- a/src/propsheet/console.cpp +++ b/src/propsheet/console.cpp @@ -96,10 +96,7 @@ void SaveConsoleSettingsIfNeeded(const HWND hwnd) gpStateInfo->FaceName[0] = TEXT('\0'); } - if (Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy()) - { - LOG_IF_FAILED(DelegationConfig::s_SetDefaultByPackage(g_selectedPackage)); - } + LOG_IF_FAILED(DelegationConfig::s_SetDefaultByPackage(g_selectedPackage)); if (gpStateInfo->LinkTitle != nullptr) { @@ -552,14 +549,7 @@ BOOL PopulatePropSheetPageArray(_Out_writes_(cPsps) PROPSHEETPAGE* pPsp, const s { pTerminalPage->dwSize = sizeof(PROPSHEETPAGE); pTerminalPage->hInstance = ghInstance; - if (Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy()) - { - pTerminalPage->pszTemplate = MAKEINTRESOURCE(DID_TERMINAL_WITH_DEFTERM); - } - else - { - pTerminalPage->pszTemplate = MAKEINTRESOURCE(DID_TERMINAL); - } + pTerminalPage->pszTemplate = MAKEINTRESOURCE(DID_TERMINAL_WITH_DEFTERM); pTerminalPage->pfnDlgProc = TerminalDlgProc; pTerminalPage->lParam = TERMINAL_PAGE_INDEX; pTerminalPage->dwFlags = PSP_DEFAULT; @@ -629,10 +619,7 @@ INT_PTR ConsolePropertySheet(__in HWND hWnd, __in PCONSOLE_STATE_INFO pStateInfo // Find the available default console/terminal packages // - if (Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy()) - { - LOG_IF_FAILED(DelegationConfig::s_GetAvailablePackages(g_availablePackages, g_selectedPackage)); - } + LOG_IF_FAILED(DelegationConfig::s_GetAvailablePackages(g_availablePackages, g_selectedPackage)); // // Get the current page number From f1ca1566a13791eeb9976b9c5bd5e063d47b1541 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Thu, 11 Jan 2024 22:41:23 +0000 Subject: [PATCH 10/10] Merged PR 10097391: [Git2Git] !10088843: Disable Legacy Console checkbox & display a label when FoD is missing This change adds a different label to the property sheet which will be displayed when conhostv1 is missing. It explains why the legacy console checkbox is not enabled. Related work items: MSFT-46195288 Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 41871b6f4c0bba64852bfbaa9255f7677246d6fe --- src/propsheet/OptionsPage.cpp | 19 ++++++++++++++++++- src/propsheet/console.rc | 6 ++++++ src/propsheet/dialogs.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/propsheet/OptionsPage.cpp b/src/propsheet/OptionsPage.cpp index a7991565f2..eee80476fe 100644 --- a/src/propsheet/OptionsPage.cpp +++ b/src/propsheet/OptionsPage.cpp @@ -174,6 +174,23 @@ INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lPara // Initialize the global handle to this dialog g_hOptionsDlg = hDlg; + { + // Do the check for conhostv1 early, so that we can propagate the new ForceV2 state to everyone. + wil::unique_hmodule conhostV1{ LoadLibraryExW(L"conhostv1.dll", nullptr, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_SEARCH_SYSTEM32) }; + HWND hwndItemToShow, hwndItemToHide; + hwndItemToShow = GetDlgItem(hDlg, IDD_HELP_LEGACY_LINK); + hwndItemToHide = GetDlgItem(hDlg, IDD_HELP_LEGACY_LINK_MISSING); + if (!conhostV1) + { + g_fForceV2 = true; + EnableWindow(GetDlgItem(hDlg, IDD_FORCEV2), FALSE); + std::swap(hwndItemToShow, hwndItemToHide); + } + + ShowWindow(hwndItemToShow, SW_SHOW); + ShowWindow(hwndItemToHide, SW_HIDE); + } + CheckDlgButton(hDlg, IDD_HISTORY_NODUP, gpStateInfo->HistoryNoDup); CheckDlgButton(hDlg, IDD_QUICKEDIT, gpStateInfo->QuickEdit); CheckDlgButton(hDlg, IDD_INSERT, gpStateInfo->InsertMode); @@ -250,7 +267,7 @@ INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lPara case WM_NOTIFY: { - if (lParam && (wParam == IDD_HELP_SYSLINK || wParam == IDD_HELP_LEGACY_LINK)) + if (lParam && (wParam == IDD_HELP_SYSLINK || wParam == IDD_HELP_LEGACY_LINK || wParam == IDD_HELP_LEGACY_LINK_MISSING)) { // handle hyperlink click or keyboard activation switch (((LPNMHDR)lParam)->code) diff --git a/src/propsheet/console.rc b/src/propsheet/console.rc index 18f3077d49..368144c9fd 100644 --- a/src/propsheet/console.rc +++ b/src/propsheet/console.rc @@ -85,6 +85,9 @@ BEGIN CONTROL "&Use legacy console (requires relaunch, affects all consoles)", IDD_FORCEV2, "Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 10, 199, 200, 10 + CONTROL "The legacy console is not installed. Learn more.", + IDD_HELP_LEGACY_LINK_MISSING, "SysLink", WS_TABSTOP, 21, 211, 179, 10 + CONTROL "Learn more about legacy console mode", IDD_HELP_LEGACY_LINK, "SysLink", WS_TABSTOP, 21, 211, 179, 10 @@ -148,6 +151,9 @@ BEGIN CONTROL "&Use legacy console (requires relaunch, affects all consoles)", IDD_FORCEV2, "Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 10, 199, 200, 10 + CONTROL "The legacy console is not installed. Learn more.", + IDD_HELP_LEGACY_LINK_MISSING, "SysLink", WS_TABSTOP, 21, 211, 179, 10 + CONTROL "Learn more about legacy console mode", IDD_HELP_LEGACY_LINK, "SysLink", WS_TABSTOP, 21, 211, 179, 10 diff --git a/src/propsheet/dialogs.h b/src/propsheet/dialogs.h index 9200f9090e..41b5ec8fe6 100644 --- a/src/propsheet/dialogs.h +++ b/src/propsheet/dialogs.h @@ -129,6 +129,7 @@ Revision History: #define IDD_OPACITY_VALUE 514 #define IDD_INTERCEPT_COPY_PASTE 515 #define IDD_HELP_LEGACY_LINK 516 +#define IDD_HELP_LEGACY_LINK_MISSING 517 #define DID_TERMINAL 600