cc8faaf04f
This commit renames the functions in conpty.lib to Conpty* so that they can be explicitly linked and introduces a header so they can be located. It also updates the DEF for conpty.dll to reexport them with their original names. The crux of the issue here is that TerminalConnection is consuming the _import_ symbols for the *PseudoConsole family of APIs, which simply cannot be supplanted by a static library. Avenues explored: * Exporting __imp_x from the static library to get all up in kernel32's business. * Using /ALTERNATENAME:__imp_X=StaticX. It turns out ALTERNATENAME is only consulted when the symbol isn't found through traditional means. This, renaming them, is the straightest path forward. Fixes #3553.
68 lines
2.5 KiB
C++
68 lines
2.5 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "ConptyConnection.g.h"
|
|
#include <conpty-static.h>
|
|
|
|
namespace wil
|
|
{
|
|
// These belong in WIL upstream, so when we reingest the change that has them we'll get rid of ours.
|
|
using unique_static_pseudoconsole_handle = wil::unique_any<HPCON, decltype(&::ConptyClosePseudoConsole), ::ConptyClosePseudoConsole>;
|
|
}
|
|
|
|
namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
|
{
|
|
struct ConptyConnection : ConptyConnectionT<ConptyConnection>
|
|
{
|
|
ConptyConnection(const hstring& cmdline, const hstring& startingDirectory, const hstring& startingTitle, const uint32_t rows, const uint32_t cols, const guid& guid);
|
|
|
|
winrt::event_token TerminalOutput(TerminalConnection::TerminalOutputEventArgs const& handler);
|
|
void TerminalOutput(winrt::event_token const& token) noexcept;
|
|
winrt::event_token TerminalDisconnected(TerminalConnection::TerminalDisconnectedEventArgs const& handler);
|
|
void TerminalDisconnected(winrt::event_token const& token) noexcept;
|
|
void Start();
|
|
void WriteInput(hstring const& data);
|
|
void Resize(uint32_t rows, uint32_t columns);
|
|
void Close();
|
|
|
|
winrt::guid Guid() const noexcept;
|
|
|
|
private:
|
|
HRESULT _LaunchAttachedClient() noexcept;
|
|
void _ClientTerminated() noexcept;
|
|
|
|
winrt::event<TerminalConnection::TerminalOutputEventArgs> _outputHandlers;
|
|
winrt::event<TerminalConnection::TerminalDisconnectedEventArgs> _disconnectHandlers;
|
|
|
|
uint32_t _initialRows{};
|
|
uint32_t _initialCols{};
|
|
hstring _commandline;
|
|
hstring _startingDirectory;
|
|
hstring _startingTitle;
|
|
guid _guid{}; // A unique session identifier for connected client
|
|
|
|
bool _connected{};
|
|
std::atomic<bool> _closing{ false };
|
|
bool _recievedFirstByte{ false };
|
|
std::chrono::high_resolution_clock::time_point _startTime{};
|
|
|
|
wil::unique_hfile _inPipe; // The pipe for writing input to
|
|
wil::unique_hfile _outPipe; // The pipe for reading output from
|
|
wil::unique_handle _hOutputThread;
|
|
wil::unique_process_information _piClient;
|
|
wil::unique_static_pseudoconsole_handle _hPC;
|
|
wil::unique_threadpool_wait _clientExitWait;
|
|
|
|
DWORD _OutputThread();
|
|
};
|
|
}
|
|
|
|
namespace winrt::Microsoft::Terminal::TerminalConnection::factory_implementation
|
|
{
|
|
struct ConptyConnection : ConptyConnectionT<ConptyConnection, implementation::ConptyConnection>
|
|
{
|
|
};
|
|
}
|