-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open-source the PseudoConsole family of functions in a new DLL (#2611)
This pull request introduces a copy of the code from kernel32.dll that implements CreatePseudoConsole, ClosePseudoConsole and ResizePseudoConsole. Apart from some light modifications to fit into the infrastructure in this project and support launching OpenConsole.exe, it is intended to be 1:1 with the code that ships in Windows. Any guideline violations in this code are likely intentional. Since this was built into kernel32, it uses the STL only _very sparingly._ Consumers of this library must make sure that conpty.lib lives earlier in the link line than onecoreuap_apiset, onecoreuap, onecore_apiset, onecore or kernel32. Refs #1130.
- Loading branch information
Showing
10 changed files
with
577 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"/.vs/", | ||
"/build/", | ||
"/src/cascadia/", | ||
"/src/winconpty/", | ||
"/.nuget/", | ||
"/.github/", | ||
"/samples/" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
Module Name: | ||
- device.h | ||
Abstract: | ||
- This header exists to reduce the differences in winconpty | ||
from the in-box windows source. | ||
- Relies on components from Server to reach into ntdll for NtOpenFile | ||
to get at the NT namespace, which is required to open the console device. | ||
--*/ | ||
|
||
#pragma once | ||
|
||
#include "../server/DeviceHandle.h" | ||
|
||
[[nodiscard]] static inline NTSTATUS CreateClientHandle(PHANDLE Handle, HANDLE ServerHandle, PCWSTR Name, BOOLEAN Inheritable) | ||
{ | ||
return DeviceHandle::CreateClientHandle(Handle, ServerHandle, Name, Inheritable); | ||
} | ||
|
||
[[nodiscard]] static inline NTSTATUS CreateServerHandle(PHANDLE Handle, BOOLEAN Inheritable) | ||
{ | ||
return DeviceHandle::CreateServerHandle(Handle, Inheritable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "precomp.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
Module Name: | ||
- precomp.h | ||
Abstract: | ||
- Contains external headers to include in the precompile phase of console build process. | ||
- Avoid including internal project headers. Instead include them only in the classes that need them (helps with test project building). | ||
--*/ | ||
|
||
#pragma once | ||
|
||
// Ignore checked iterators warning from VC compiler. | ||
#define _SCL_SECURE_NO_WARNINGS | ||
|
||
// Block minwindef.h min/max macros to prevent <algorithm> conflict | ||
#define NOMINMAX | ||
|
||
// Define and then undefine WIN32_NO_STATUS because windows.h has no guard to prevent it from double defing certain statuses | ||
// when included with ntstatus.h | ||
#define WIN32_NO_STATUS | ||
#include <windows.h> | ||
#undef WIN32_NO_STATUS | ||
|
||
// From ntdef.h, but that can't be included or it'll fight over PROBE_ALIGNMENT and other such arch specific defs | ||
typedef _Return_type_success_(return >= 0) LONG NTSTATUS; | ||
/*lint -save -e624 */ // Don't complain about different typedefs. | ||
typedef NTSTATUS* PNTSTATUS; | ||
/*lint -restore */ // Resume checking for different typedefs. | ||
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) | ||
|
||
// End From ntdef.h | ||
|
||
#define INLINE_NTSTATUS_FROM_WIN32 1 // Must use inline NTSTATUS or it will call the wrapped function twice. | ||
#pragma warning(push) | ||
#pragma warning(disable : 4430) // Must disable 4430 "default int" warning for C++ because ntstatus.h is inflexible SDK definition. | ||
#include <ntstatus.h> | ||
#pragma warning(pop) | ||
|
||
#include <strsafe.h> | ||
|
||
#include "../host/conddkrefs.h" | ||
|
||
// This includes support libraries from the CRT, STL, WIL, and GSL | ||
#include "LibraryIncludes.h" | ||
|
||
#include <winconp.h> |
Oops, something went wrong.