Merged PR 5923545: Reflect OS build fixes on top of ab6f41f4b

We needed to suppress a bunch of the handoff establishing code inside Windows.
This commit is contained in:
Dustin Howett 2021-04-15 16:55:01 +00:00
parent 806c4c5d5c
commit c90215b4e1
3 changed files with 21 additions and 9 deletions

View file

@ -5,11 +5,14 @@
#include "ConsoleArguments.hpp"
#include "srvinit.h"
#include "CConsoleHandoff.h"
#include "../server/Entrypoints.h"
#include "../interactivity/inc/ServiceLocator.hpp"
#include "../inc/conint.h"
#ifndef __INSIDE_WINDOWS
#include "CConsoleHandoff.h"
#endif
// Define TraceLogging provider
TRACELOGGING_DEFINE_PROVIDER(
g_ConhostLauncherProvider,
@ -29,8 +32,8 @@ class DefaultOutOfProcModuleWithRegistrationFlag;
template<int RegClsType, typename ModuleT = DefaultOutOfProcModuleWithRegistrationFlag<RegClsType>>
class OutOfProcModuleWithRegistrationFlag : public Microsoft::WRL::Module<Microsoft::WRL::ModuleType::OutOfProc, ModuleT>
{
using Elsewhere = Module<OutOfProc, ModuleT>;
using Super = Details::OutOfProcModuleBase<ModuleT>;
using Elsewhere = Microsoft::WRL::Module<Microsoft::WRL::ModuleType::OutOfProc, ModuleT>;
using Super = Microsoft::WRL::Details::OutOfProcModuleBase<ModuleT>;
public:
STDMETHOD(RegisterCOMObject)
@ -181,6 +184,7 @@ static bool ShouldUseLegacyConhost(const ConsoleArguments& args)
// Routine Description:
// - Called back when COM says there is nothing left for our server to do and we can tear down.
#pragma warning (suppress : 4505) // this is unused, and therefore discarded, when built inside windows
static void _releaseNotifier() noexcept
{
_comServerExitEvent.SetEvent();
@ -239,7 +243,9 @@ int CALLBACK wWinMain(
// messages going forward.
// 7. The out-of-box `OpenConsole.exe` can then attempt to lookup and invoke a `CTerminalHandoff` to ask a registered
// Terminal to become the UI. This OpenConsole.exe will put itself in PTY mode and let the Terminal handle user interaction.
#ifndef __INSIDE_WINDOWS
auto& module = OutOfProcModuleWithRegistrationFlag<REGCLS_SINGLEUSE>::Create(&_releaseNotifier);
#endif
// Register Trace provider by GUID
TraceLoggingRegister(g_ConhostLauncherProvider);

View file

@ -32,8 +32,7 @@ CETCOMPAT=1
SOURCES = \
$(SOURCES) \
.\CConsoleHandoff.cpp \
.\exemain.cpp \
exemain.cpp \
..\res.rc \
# -------------------------------------

View file

@ -23,10 +23,13 @@
#include "renderData.hpp"
#include "../renderer/base/renderer.hpp"
#include "ITerminalHandoff.h"
#include "../inc/conint.h"
#include "../propslib/DelegationConfig.hpp"
#ifndef __INSIDE_WINDOWS
#include "ITerminalHandoff.h"
#endif // __INSIDE_WINDOWS
#pragma hdrstop
using namespace Microsoft::Console::Interactivity;
@ -357,11 +360,14 @@ HRESULT ConsoleCreateIoThread(_In_ HANDLE Server,
// errors from the creating the thread for the
// standard IO thread loop for the server to process messages
// from the driver... or an S_OK success.
[[nodiscard]] HRESULT ConsoleEstablishHandoff(_In_ HANDLE Server,
HANDLE driverInputEvent,
PCONSOLE_API_MSG connectMessage)
[[nodiscard]] HRESULT ConsoleEstablishHandoff([[maybe_unused]] _In_ HANDLE Server,
[[maybe_unused]] HANDLE driverInputEvent,
[[maybe_unused]] PCONSOLE_API_MSG connectMessage)
try
{
#ifdef __INSIDE_WINDOWS
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
#else // !__INSIDE_WINDOWS
auto& g = ServiceLocator::LocateGlobals();
g.handoffTarget = true;
@ -426,6 +432,7 @@ try
RETURN_IF_FAILED(consoleArgs.ParseCommandline());
return ConsoleCreateIoThread(Server, &consoleArgs, driverInputEvent, connectMessage);
#endif // __INSIDE_WINDOWS
}
CATCH_RETURN()