Only try to hand off to ConhostV1 if building for Windows (#15131)

Some of our automated tooling detects this as being a private API that
we're accessing via LoadLibrary/GetProcAddress. It's not *wrong*, but
it's also not *right*.

It's easier for us to just not do it (and save all the code for it!) in
OpenConsole.
This commit is contained in:
Dustin L. Howett
2023-04-06 16:32:40 -05:00
committed by GitHub
parent de09671d8a
commit 7fbd3be8c3
2 changed files with 33 additions and 20 deletions

View File

@@ -67,6 +67,15 @@
</alwaysEnabledBrandingTokens>
</feature>
<feature>
<name>Feature_LegacyConhost</name>
<description>conhost should support ForceV2=false, and try to load conhostv1.dll</description>
<stage>AlwaysDisabled</stage>
<alwaysEnabledBrandingTokens>
<brandingToken>WindowsInbox</brandingToken>
</alwaysEnabledBrandingTokens>
</feature>
<feature>
<name>Feature_AtlasEngine</name>
<description>If enabled, AtlasEngine is used by default</description>

View File

@@ -52,6 +52,27 @@ class DefaultOutOfProcModuleWithRegistrationFlag : public OutOfProcModuleWithReg
// Holds the wwinmain open until COM tells us there are no more server connections
wil::unique_event _comServerExitEvent;
[[nodiscard]] static HRESULT ValidateServerHandle(const HANDLE handle)
{
// Make sure this is a console file.
FILE_FS_DEVICE_INFORMATION DeviceInformation;
IO_STATUS_BLOCK IoStatusBlock;
const auto Status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, &DeviceInformation, sizeof(DeviceInformation), FileFsDeviceInformation);
if (FAILED_NTSTATUS(Status))
{
RETURN_NTSTATUS(Status);
}
else if (DeviceInformation.DeviceType != FILE_DEVICE_CONSOLE)
{
return E_INVALIDARG;
}
else
{
return S_OK;
}
}
#if TIL_FEATURE_LEGACYCONHOST_ENABLED
static bool useV2 = true;
static bool ConhostV2ForcedInRegistry()
{
@@ -101,26 +122,6 @@ static bool ConhostV2ForcedInRegistry()
return fShouldUseConhostV2;
}
[[nodiscard]] static HRESULT ValidateServerHandle(const HANDLE handle)
{
// Make sure this is a console file.
FILE_FS_DEVICE_INFORMATION DeviceInformation;
IO_STATUS_BLOCK IoStatusBlock;
const auto Status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, &DeviceInformation, sizeof(DeviceInformation), FileFsDeviceInformation);
if (FAILED_NTSTATUS(Status))
{
RETURN_NTSTATUS(Status);
}
else if (DeviceInformation.DeviceType != FILE_DEVICE_CONSOLE)
{
return E_INVALIDARG;
}
else
{
return S_OK;
}
}
static bool ShouldUseLegacyConhost(const ConsoleArguments& args)
{
if (args.InConptyMode())
@@ -185,6 +186,7 @@ static bool ShouldUseLegacyConhost(const ConsoleArguments& args)
return hr;
}
#endif // TIL_FEATURE_LEGACYCONHOST_ENABLED
// Routine Description:
// - Called back when COM says there is nothing left for our server to do and we can tear down.
@@ -303,6 +305,7 @@ int CALLBACK wWinMain(
else
#endif
{
#if TIL_FEATURE_LEGACYCONHOST_ENABLED
if (ShouldUseLegacyConhost(args))
{
useV2 = false;
@@ -321,6 +324,7 @@ int CALLBACK wWinMain(
}
}
if (useV2)
#endif // TIL_FEATURE_LEGACYCONHOST_ENABLED
{
if (args.ShouldCreateServerHandle())
{