Add InteractivityOneCore/RendererWddmCon projects (#13007)

`InteractivityOneCore` and `RendererWddmCon` were the last two remaining
projects which are relevant for our internal console builds, but couldn't be
easily compiled publicly by users on GitHub. This commit adds all definitions
required to compile the two projects into dysfunctional libraries at least.
(Since the added definitions are deliberately incorrect.)

Additionally this commit fixes the AuditMode build for the two projects.

## Validation Steps Performed
The two new projects compile fine.
This commit is contained in:
Leonard Hecker 2022-05-04 02:49:43 +02:00 committed by GitHub
parent 223af3a54a
commit eb5c26cc69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 930 additions and 535 deletions

View File

@ -1064,6 +1064,7 @@ ico
IComponent IComponent
ICONERROR ICONERROR
Iconified Iconified
iconify
Iconify Iconify
ICONINFORMATION ICONINFORMATION
IConsole IConsole
@ -2748,8 +2749,8 @@ windowsapp
windowsdeveloper windowsdeveloper
windowsinternalstring windowsinternalstring
WINDOWSIZE WINDOWSIZE
windowsx
windowsterminal windowsterminal
windowsx
WINDOWTEXT WINDOWTEXT
windowtheme windowtheme
WINDOWTITLE WINDOWTITLE
@ -2887,12 +2888,12 @@ XTest
XTPOPSGR XTPOPSGR
XTPUSHSGR XTPUSHSGR
xtr xtr
XTWINOPS
xunit xunit
xutr xutr
xvalue xvalue
XVIRTUALSCREEN XVIRTUALSCREEN
XWalk XWalk
XTWINOPS
Xzn Xzn
yact yact
YAML YAML

View File

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.29001.49 VisualStudioVersion = 17.2.32422.2
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Terminal", "Terminal", "{59840756-302F-44DF-AA47-441A9D673202}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Terminal", "Terminal", "{59840756-302F-44DF-AA47-441A9D673202}"
EndProject EndProject
@ -406,6 +406,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{61901E80
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RendererAtlas", "src\renderer\atlas\atlas.vcxproj", "{8222900C-8B6C-452A-91AC-BE95DB04B95F}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RendererAtlas", "src\renderer\atlas\atlas.vcxproj", "{8222900C-8B6C-452A-91AC-BE95DB04B95F}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InteractivityOneCore", "src\interactivity\onecore\lib\onecore.LIB.vcxproj", "{06EC74CB-9A12-428C-B551-8537EC964726}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RendererWddmCon", "src\renderer\wddmcon\lib\wddmcon.vcxproj", "{75C6F576-18E9-4566-978A-F0A301CAC090}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
AuditMode|Any CPU = AuditMode|Any CPU AuditMode|Any CPU = AuditMode|Any CPU
@ -3375,6 +3379,76 @@ Global
{8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x64.Build.0 = Release|x64 {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x64.Build.0 = Release|x64
{8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x86.ActiveCfg = Release|Win32 {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x86.ActiveCfg = Release|Win32
{8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x86.Build.0 = Release|Win32 {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x86.Build.0 = Release|Win32
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|Any CPU.ActiveCfg = AuditMode|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|ARM.ActiveCfg = AuditMode|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|ARM64.ActiveCfg = AuditMode|ARM64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|DotNet_x64Test.ActiveCfg = AuditMode|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|DotNet_x86Test.ActiveCfg = AuditMode|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|x64.ActiveCfg = AuditMode|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|x64.Build.0 = AuditMode|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.AuditMode|x86.ActiveCfg = AuditMode|Win32
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|Any CPU.ActiveCfg = Debug|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|ARM.ActiveCfg = Debug|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|ARM64.ActiveCfg = Debug|ARM64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|ARM64.Build.0 = Debug|ARM64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|DotNet_x64Test.ActiveCfg = Debug|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|DotNet_x86Test.ActiveCfg = Debug|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|x64.ActiveCfg = Debug|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|x64.Build.0 = Debug|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|x86.ActiveCfg = Debug|Win32
{06EC74CB-9A12-428C-B551-8537EC964726}.Debug|x86.Build.0 = Debug|Win32
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|Any CPU.ActiveCfg = Fuzzing|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|ARM.ActiveCfg = Fuzzing|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|ARM64.ActiveCfg = Fuzzing|ARM64
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|DotNet_x86Test.ActiveCfg = Fuzzing|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|x64.ActiveCfg = Fuzzing|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|Any CPU.ActiveCfg = Release|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|ARM.ActiveCfg = Release|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|ARM64.ActiveCfg = Release|ARM64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|ARM64.Build.0 = Release|ARM64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|DotNet_x64Test.ActiveCfg = Release|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|DotNet_x86Test.ActiveCfg = Release|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|x64.ActiveCfg = Release|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|x64.Build.0 = Release|x64
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|x86.ActiveCfg = Release|Win32
{06EC74CB-9A12-428C-B551-8537EC964726}.Release|x86.Build.0 = Release|Win32
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|Any CPU.ActiveCfg = AuditMode|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|ARM.ActiveCfg = AuditMode|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|ARM64.ActiveCfg = AuditMode|ARM64
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|DotNet_x64Test.ActiveCfg = AuditMode|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|DotNet_x86Test.ActiveCfg = AuditMode|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|x64.ActiveCfg = AuditMode|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.AuditMode|x86.ActiveCfg = AuditMode|Win32
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|Any CPU.ActiveCfg = Debug|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|ARM.ActiveCfg = Debug|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|ARM64.ActiveCfg = Debug|ARM64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|ARM64.Build.0 = Debug|ARM64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|DotNet_x64Test.ActiveCfg = Debug|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|DotNet_x86Test.ActiveCfg = Debug|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|x64.ActiveCfg = Debug|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|x64.Build.0 = Debug|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|x86.ActiveCfg = Debug|Win32
{75C6F576-18E9-4566-978A-F0A301CAC090}.Debug|x86.Build.0 = Debug|Win32
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|Any CPU.ActiveCfg = Fuzzing|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|ARM.ActiveCfg = Fuzzing|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|ARM64.ActiveCfg = Fuzzing|ARM64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|DotNet_x86Test.ActiveCfg = Fuzzing|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|x64.ActiveCfg = Fuzzing|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|x64.Build.0 = Fuzzing|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|Any CPU.ActiveCfg = Release|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|ARM.ActiveCfg = Release|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|ARM64.ActiveCfg = Release|ARM64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|ARM64.Build.0 = Release|ARM64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|DotNet_x64Test.ActiveCfg = Release|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|DotNet_x86Test.ActiveCfg = Release|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|x64.ActiveCfg = Release|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|x64.Build.0 = Release|x64
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|x86.ActiveCfg = Release|Win32
{75C6F576-18E9-4566-978A-F0A301CAC090}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -3476,6 +3550,8 @@ Global
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5} = {89CDCC5C-9F53-4054-97A4-639D99F169CD} {9CF74355-F018-4C19-81AD-9DC6B7F2C6F5} = {89CDCC5C-9F53-4054-97A4-639D99F169CD}
{61901E80-E97D-4D61-A9BB-E8F2FDA8B40C} = {59840756-302F-44DF-AA47-441A9D673202} {61901E80-E97D-4D61-A9BB-E8F2FDA8B40C} = {59840756-302F-44DF-AA47-441A9D673202}
{8222900C-8B6C-452A-91AC-BE95DB04B95F} = {05500DEF-2294-41E3-AF9A-24E580B82836} {8222900C-8B6C-452A-91AC-BE95DB04B95F} = {05500DEF-2294-41E3-AF9A-24E580B82836}
{06EC74CB-9A12-428C-B551-8537EC964726} = {E8F24881-5E37-4362-B191-A3BA0ED7F4EB}
{75C6F576-18E9-4566-978A-F0A301CAC090} = {05500DEF-2294-41E3-AF9A-24E580B82836}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3140B1B7-C8EE-43D1-A772-D82A7061A271} SolutionGuid = {3140B1B7-C8EE-43D1-A772-D82A7061A271}

76
dep/Console/ConIoSrv.h Normal file
View File

@ -0,0 +1,76 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
--*/
#pragma once
#include <ntlpcapi.h>
#define CIS_ALPC_PORT_NAME L""
#define CIS_EVENT_TYPE_INPUT (0)
#define CIS_EVENT_TYPE_FOCUS (1)
#define CIS_EVENT_TYPE_FOCUS_ACK (2)
#define CIS_MSG_TYPE_GETDISPLAYSIZE (3)
#define CIS_MSG_TYPE_GETFONTSIZE (4)
#define CIS_MSG_TYPE_SETCURSOR (5)
#define CIS_MSG_TYPE_UPDATEDISPLAY (6)
#define CIS_MSG_ATTR_FLAGS (0)
#define CIS_MSG_ATTR_BUFFER_SIZE (1024)
#define CIS_DISPLAY_MODE_NONE (0)
#define CIS_DISPLAY_MODE_BGFX (1)
#define CIS_DISPLAY_MODE_DIRECTX (2)
typedef struct {
PORT_MESSAGE AlpcHeader;
UCHAR Type;
union {
struct {
CD_IO_DISPLAY_SIZE DisplaySize;
NTSTATUS ReturnValue;
} GetDisplaySizeParams;
struct {
CD_IO_FONT_SIZE FontSize;
NTSTATUS ReturnValue;
} GetFontSizeParams;
struct {
CD_IO_CURSOR_INFORMATION CursorInformation;
NTSTATUS ReturnValue;
} SetCursorParams;
struct {
SHORT RowIndex;
NTSTATUS ReturnValue;
} UpdateDisplayParams;
struct {
USHORT DisplayMode;
} GetDisplayModeParams;
};
} CIS_MSG, *PCIS_MSG;
typedef struct {
UCHAR Type;
union {
struct {
INPUT_RECORD Record;
} InputEvent;
struct {
BOOLEAN IsActive;
} FocusEvent;
};
} CIS_EVENT, *PCIS_EVENT;

View File

@ -158,8 +158,8 @@ typedef struct _CD_IO_DISPLAY_SIZE {
} CD_IO_DISPLAY_SIZE, *PCD_IO_DISPLAY_SIZE; } CD_IO_DISPLAY_SIZE, *PCD_IO_DISPLAY_SIZE;
typedef struct _CD_IO_CHARACTER { typedef struct _CD_IO_CHARACTER {
WCHAR Character; WCHAR Character;
USHORT Atribute; USHORT Attribute;
} CD_IO_CHARACTER, *PCD_IO_CHARACTER; } CD_IO_CHARACTER, *PCD_IO_CHARACTER;
typedef struct _CD_IO_ROW_INFORMATION { typedef struct _CD_IO_ROW_INFORMATION {
@ -175,6 +175,11 @@ typedef struct _CD_IO_CURSOR_INFORMATION {
BOOLEAN IsVisible; BOOLEAN IsVisible;
} CD_IO_CURSOR_INFORMATION, *PCD_IO_CURSOR_INFORMATION; } CD_IO_CURSOR_INFORMATION, *PCD_IO_CURSOR_INFORMATION;
typedef struct _CD_IO_FONT_SIZE {
ULONG Width;
ULONG Height;
} CD_IO_FONT_SIZE, *PCD_IO_FONT_SIZE;
#define IOCTL_CONDRV_READ_IO \ #define IOCTL_CONDRV_READ_IO \
CTL_CODE(FILE_DEVICE_CONSOLE, 1, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) CTL_CODE(FILE_DEVICE_CONSOLE, 1, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
@ -213,3 +218,6 @@ typedef struct _CD_IO_CURSOR_INFORMATION {
#define IOCTL_CONDRV_LAUNCH_SERVER \ #define IOCTL_CONDRV_LAUNCH_SERVER \
CTL_CODE(FILE_DEVICE_CONSOLE, 13, METHOD_NEITHER, FILE_ANY_ACCESS) CTL_CODE(FILE_DEVICE_CONSOLE, 13, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_CONDRV_GET_FONT_SIZE \
CTL_CODE(FILE_DEVICE_CONSOLE, 14, METHOD_NEITHER, FILE_ANY_ACCESS)

24
dep/Console/csrmsg.h Normal file
View File

@ -0,0 +1,24 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
--*/
#pragma once
#include <ntcsrmsg.h>
typedef enum _USER_API_NUMBER {
UserpEndTask,
} USER_API_NUMBER, *PUSER_API_NUMBER;
typedef struct _ENDTASKMSG {
HANDLE ProcessId;
ULONG ConsoleEventCode;
ULONG ConsoleFlags;
} ENDTASKMSG, *PENDTASKMSG;
typedef struct _USER_API_MSG {
union {
ENDTASKMSG EndTask;
} u;
} USER_API_MSG, *PUSER_API_MSG;

15
dep/Console/ntcsrdll.h Normal file
View File

@ -0,0 +1,15 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
--*/
#pragma once
#include <ntcsrmsg.h>
NTSTATUS CsrClientCallServer(
PCSR_API_MSG m,
PCSR_CAPTURE_HEADER CaptureBuffer OPTIONAL,
ULONG ApiNumber,
ULONG ArgLength
);

16
dep/Console/ntcsrmsg.h Normal file
View File

@ -0,0 +1,16 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
--*/
#pragma once
#include <ntlpcapi.h>
typedef struct _CSR_CAPTURE_HEADER {
} CSR_CAPTURE_HEADER, *PCSR_CAPTURE_HEADER;
typedef struct _CSR_API_MSG {
} CSR_API_MSG, *PCSR_API_MSG;
#define CSR_MAKE_API_NUMBER(DllIndex, ApiIndex) 0

126
dep/Console/ntlpcapi.h Normal file
View File

@ -0,0 +1,126 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
--*/
#pragma once
#define OB_FILE_OBJECT_TYPE 1
typedef struct _PORT_MESSAGE {
union {
struct {
SHORT DataLength;
SHORT TotalLength;
} s1;
} u1;
union {
ULONG ZeroInit;
} u2;
union {
CLIENT_ID ClientId;
};
ULONG MessageId;
} PORT_MESSAGE, *PPORT_MESSAGE;
#define ALPC_MSGFLG_SYNC_REQUEST 0
#define ALPC_PORFLG_ACCEPT_DUP_HANDLES 1
#define ALPC_PORFLG_ACCEPT_INDIRECT_HANDLES 2
typedef struct _ALPC_DATA_VIEW_ATTR {
PVOID ViewBase;
SIZE_T ViewSize;
} ALPC_DATA_VIEW_ATTR, *PALPC_DATA_VIEW_ATTR;
typedef struct _ALPC_CONTEXT_ATTR {
} ALPC_CONTEXT_ATTR, *PALPC_CONTEXT_ATTR;
#define ALPC_INDIRECT_HANDLE_MAX 512
typedef struct _ALPC_HANDLE_ATTR {
union {
ULONG HandleCount;
};
} ALPC_HANDLE_ATTR, *PALPC_HANDLE_ATTR;
#define ALPC_FLG_MSG_DATAVIEW_ATTR 1
#define ALPC_FLG_MSG_HANDLE_ATTR 2
typedef struct _ALPC_MESSAGE_ATTRIBUTES {
} ALPC_MESSAGE_ATTRIBUTES, *PALPC_MESSAGE_ATTRIBUTES;
typedef struct _ALPC_PORT_ATTRIBUTES {
ULONG Flags;
SECURITY_QUALITY_OF_SERVICE SecurityQos;
SIZE_T MaxMessageLength;
SIZE_T MemoryBandwidth;
SIZE_T MaxPoolUsage;
SIZE_T MaxSectionSize;
SIZE_T MaxViewSize;
SIZE_T MaxTotalSectionSize;
ULONG DupObjectTypes;
#ifdef _WIN64
ULONG Reserved;
#endif
} ALPC_PORT_ATTRIBUTES, *PALPC_PORT_ATTRIBUTES;
typedef enum _ALPC_MESSAGE_INFORMATION_CLASS {
AlpcMessageHandleInformation
} ALPC_MESSAGE_INFORMATION_CLASS;
typedef struct _ALPC_MESSAGE_HANDLE_INFORMATION {
ULONG Index;
ULONG Handle;
} ALPC_MESSAGE_HANDLE_INFORMATION, *PALPC_MESSAGE_HANDLE_INFORMATION;
NTSTATUS AlpcInitializeMessageAttribute(
ULONG AttributeFlags,
PALPC_MESSAGE_ATTRIBUTES Buffer,
SIZE_T BufferSize,
PSIZE_T RequiredBufferSize
);
PVOID AlpcGetMessageAttribute(
PALPC_MESSAGE_ATTRIBUTES Buffer,
ULONG AttributeFlag
);
#define ALPC_GET_DATAVIEW_ATTRIBUTES(MsgAttr) \
((PALPC_DATA_VIEW_ATTR)AlpcGetMessageAttribute(MsgAttr, ALPC_FLG_MSG_DATAVIEW_ATTR))
#define ALPC_GET_HANDLE_ATTRIBUTES(MsgAttr) \
((PALPC_HANDLE_ATTR)AlpcGetMessageAttribute(MsgAttr, ALPC_FLG_MSG_HANDLE_ATTR))
NTSTATUS NtAlpcConnectPort(
PHANDLE PortHandle,
PUNICODE_STRING PortName,
POBJECT_ATTRIBUTES ObjectAttributes,
PALPC_PORT_ATTRIBUTES PortAttributes,
ULONG Flags,
PSID RequiredServerSid,
PPORT_MESSAGE ConnectionMessage,
PSIZE_T BufferLength,
PALPC_MESSAGE_ATTRIBUTES OutMessageAttributes,
PALPC_MESSAGE_ATTRIBUTES InMessageAttributes,
PLARGE_INTEGER Timeout
);
NTSTATUS NtAlpcSendWaitReceivePort(
HANDLE PortHandle,
ULONG Flags,
PPORT_MESSAGE SendMessage,
PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes,
PPORT_MESSAGE ReceiveMessage,
PSIZE_T BufferLength,
PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes,
PLARGE_INTEGER Timeout
);
NTSTATUS NtAlpcQueryInformationMessage(
HANDLE PortHandle,
PPORT_MESSAGE PortMessage,
ALPC_MESSAGE_INFORMATION_CLASS MessageInformationClass,
PVOID MessageInformation,
ULONG Length,
PULONG ReturnLength
);

View File

@ -15,11 +15,12 @@ and it's easier to include a copy of the infrequently changing defs here.
#ifndef _DDK_INCLUDED #ifndef _DDK_INCLUDED
extern "C" {
#pragma region wdm.h(public DDK) #pragma region wdm.h(public DDK)
// //
// Define the base asynchronous I/O argument types // Define the base asynchronous I/O argument types
// //
extern "C" {
// //
// ClientId // ClientId
@ -92,17 +93,50 @@ typedef CONST OBJECT_ATTRIBUTES* PCOBJECT_ATTRIBUTES;
//-- //--
#define InitializeObjectAttributes(p, n, a, r, s) \ #define InitializeObjectAttributes(p, n, a, r, s) \
do \
{ \ { \
(p)->Length = sizeof(OBJECT_ATTRIBUTES); \ (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
(p)->RootDirectory = r; \ (p)->RootDirectory = r; \
(p)->Attributes = a; \ (p)->Attributes = a; \
(p)->ObjectName = n; \ (p)->ObjectName = n; \
(p)->SecurityDescriptor = s; \ (p)->SecurityDescriptor = s; \
(p)->SecurityQualityOfService = NULL; \ (p)->SecurityQualityOfService = nullptr; \
} } while (0)
// UNICODE_STRING // UNICODE_STRING
extern "C++" {
char _RTL_CONSTANT_STRING_type_check(const char* s);
char _RTL_CONSTANT_STRING_type_check(const WCHAR* s);
template<size_t N>
class _RTL_CONSTANT_STRING_remove_const_template_class;
template<>
class _RTL_CONSTANT_STRING_remove_const_template_class<sizeof(char)>
{
public:
typedef char T;
};
template<>
class _RTL_CONSTANT_STRING_remove_const_template_class<sizeof(WCHAR)>
{
public:
typedef WCHAR T;
};
#define _RTL_CONSTANT_STRING_remove_const_macro(s) \
(const_cast<_RTL_CONSTANT_STRING_remove_const_template_class<sizeof((s)[0])>::T*>(s))
#define RTL_CONSTANT_STRING(s) \
{ \
sizeof(s) - sizeof((s)[0]), \
sizeof(s) / sizeof(_RTL_CONSTANT_STRING_type_check(s)), \
_RTL_CONSTANT_STRING_remove_const_macro(s) \
}
}
// OBJ_CASE_INSENSITIVE // OBJ_CASE_INSENSITIVE
// OBJ_INHERIT // OBJ_INHERIT
// InitializeObjectAttributes // InitializeObjectAttributes
@ -197,12 +231,11 @@ typedef struct _FILE_FS_DEVICE_INFORMATION
#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT
#pragma endregion #pragma endregion
};
#pragma endregion #pragma endregion
#pragma region ntifs.h(public DDK) #pragma region ntifs.h(public DDK)
extern "C" {
#define RtlOffsetToPointer(B, O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O)))) #define RtlOffsetToPointer(B, O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
__kernel_entry NTSYSCALLAPI __kernel_entry NTSYSCALLAPI
@ -214,8 +247,12 @@ __kernel_entry NTSYSCALLAPI
_Out_writes_bytes_(Length) PVOID FsInformation, _Out_writes_bytes_(Length) PVOID FsInformation,
_In_ ULONG Length, _In_ ULONG Length,
_In_ FS_INFORMATION_CLASS FsInformationClass); _In_ FS_INFORMATION_CLASS FsInformationClass);
};
#pragma endregion #pragma endregion
// InteractivityOneCore depends on this private function. The IsPresent checks
// are automatically generated by forwarder.template and aren't part of the DDK.
// I've placed it here because I couldn't come up with a better place.
BOOL IsGetSystemMetricsPresent();
}
#endif // _DDK_INCLUDED #endif // _DDK_INCLUDED

View File

@ -27,7 +27,7 @@ namespace Microsoft::Console::Interactivity
CaretVisible CaretVisible
}; };
virtual ~IAccessibilityNotifier() = 0; virtual ~IAccessibilityNotifier() = default;
virtual void NotifyConsoleCaretEvent(_In_ RECT rectangle) = 0; virtual void NotifyConsoleCaretEvent(_In_ RECT rectangle) = 0;
virtual void NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags flags, _In_ LONG position) = 0; virtual void NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags flags, _In_ LONG position) = 0;
@ -37,13 +37,5 @@ namespace Microsoft::Console::Interactivity
virtual void NotifyConsoleLayoutEvent() = 0; virtual void NotifyConsoleLayoutEvent() = 0;
virtual void NotifyConsoleStartApplicationEvent(_In_ DWORD processId) = 0; virtual void NotifyConsoleStartApplicationEvent(_In_ DWORD processId) = 0;
virtual void NotifyConsoleEndApplicationEvent(_In_ DWORD processId) = 0; virtual void NotifyConsoleEndApplicationEvent(_In_ DWORD processId) = 0;
protected:
IAccessibilityNotifier() {}
IAccessibilityNotifier(const IAccessibilityNotifier&) = delete;
IAccessibilityNotifier& operator=(const IAccessibilityNotifier&) = delete;
}; };
inline IAccessibilityNotifier::~IAccessibilityNotifier() {}
} }

View File

@ -20,17 +20,9 @@ namespace Microsoft::Console::Interactivity
class IConsoleControl class IConsoleControl
{ {
public: public:
virtual ~IConsoleControl() = 0; virtual ~IConsoleControl() = default;
[[nodiscard]] virtual NTSTATUS NotifyConsoleApplication(DWORD dwProcessId) = 0; [[nodiscard]] virtual NTSTATUS NotifyConsoleApplication(DWORD dwProcessId) = 0;
[[nodiscard]] virtual NTSTATUS SetForeground(HANDLE hProcess, BOOL fForeground) = 0; [[nodiscard]] virtual NTSTATUS SetForeground(HANDLE hProcess, BOOL fForeground) = 0;
[[nodiscard]] virtual NTSTATUS EndTask(HANDLE hProcessId, DWORD dwEventType, ULONG ulCtrlFlags) = 0; [[nodiscard]] virtual NTSTATUS EndTask(HANDLE hProcessId, DWORD dwEventType, ULONG ulCtrlFlags) = 0;
protected:
IConsoleControl() {}
IConsoleControl(const IConsoleControl&) = delete;
IConsoleControl& operator=(const IConsoleControl&) = delete;
}; };
inline IConsoleControl::~IConsoleControl() {}
} }

View File

@ -20,11 +20,11 @@ namespace Microsoft::Console::Interactivity
class IConsoleInputThread class IConsoleInputThread
{ {
public: public:
virtual ~IConsoleInputThread() = 0; virtual ~IConsoleInputThread() = default;
virtual HANDLE Start() = 0; virtual HANDLE Start() = 0;
HANDLE GetHandle() { return _hThread; } HANDLE GetHandle() noexcept { return _hThread; }
DWORD GetThreadId() { return _dwThreadId; } DWORD GetThreadId() noexcept { return _dwThreadId; }
protected: protected:
// Prevent accidental copies. // Prevent accidental copies.
@ -32,7 +32,7 @@ namespace Microsoft::Console::Interactivity
IConsoleInputThread& operator=(const IConsoleInputThread&) = delete; IConsoleInputThread& operator=(const IConsoleInputThread&) = delete;
// .ctor // .ctor
IConsoleInputThread() : IConsoleInputThread() noexcept :
_hThread(nullptr), _hThread(nullptr),
_dwThreadId(gsl::narrow_cast<DWORD>(-1)) {} _dwThreadId(gsl::narrow_cast<DWORD>(-1)) {}
@ -40,6 +40,4 @@ namespace Microsoft::Console::Interactivity
HANDLE _hThread; HANDLE _hThread;
DWORD _dwThreadId; DWORD _dwThreadId;
}; };
inline IConsoleInputThread::~IConsoleInputThread() {}
} }

View File

@ -23,7 +23,7 @@ namespace Microsoft::Console::Types
class IConsoleWindow class IConsoleWindow
{ {
public: public:
virtual ~IConsoleWindow() = 0; virtual ~IConsoleWindow() = default;
virtual BOOL EnableBothScrollBars() = 0; virtual BOOL EnableBothScrollBars() = 0;
virtual int UpdateScrollBar(_In_ bool isVertical, virtual int UpdateScrollBar(_In_ bool isVertical,
@ -69,6 +69,4 @@ namespace Microsoft::Console::Types
[[nodiscard]] virtual HRESULT UiaSetTextAreaFocus() = 0; [[nodiscard]] virtual HRESULT UiaSetTextAreaFocus() = 0;
virtual RECT GetWindowRect() const noexcept = 0; virtual RECT GetWindowRect() const noexcept = 0;
}; };
inline IConsoleWindow::~IConsoleWindow() {}
} }

View File

@ -22,14 +22,6 @@ namespace Microsoft::Console::Interactivity
virtual BOOL SetProcessDpiAwarenessContext() = 0; virtual BOOL SetProcessDpiAwarenessContext() = 0;
[[nodiscard]] virtual HRESULT SetProcessPerMonitorDpiAwareness() = 0; [[nodiscard]] virtual HRESULT SetProcessPerMonitorDpiAwareness() = 0;
virtual ~IHighDpiApi() = 0; virtual ~IHighDpiApi() = default;
protected:
IHighDpiApi() {}
IHighDpiApi(const IHighDpiApi&) = delete;
IHighDpiApi& operator=(const IHighDpiApi&) = delete;
}; };
inline IHighDpiApi::~IHighDpiApi() {}
} }

View File

@ -31,7 +31,7 @@ namespace Microsoft::Console::Interactivity
class IInteractivityFactory class IInteractivityFactory
{ {
public: public:
virtual ~IInteractivityFactory() = 0; virtual ~IInteractivityFactory() = default;
[[nodiscard]] virtual NTSTATUS CreateConsoleControl(_Inout_ std::unique_ptr<IConsoleControl>& control) = 0; [[nodiscard]] virtual NTSTATUS CreateConsoleControl(_Inout_ std::unique_ptr<IConsoleControl>& control) = 0;
[[nodiscard]] virtual NTSTATUS CreateConsoleInputThread(_Inout_ std::unique_ptr<IConsoleInputThread>& thread) = 0; [[nodiscard]] virtual NTSTATUS CreateConsoleInputThread(_Inout_ std::unique_ptr<IConsoleInputThread>& thread) = 0;
@ -43,6 +43,4 @@ namespace Microsoft::Console::Interactivity
virtual void SetPseudoWindowCallback(std::function<void(bool)> func) = 0; virtual void SetPseudoWindowCallback(std::function<void(bool)> func) = 0;
[[nodiscard]] virtual NTSTATUS CreatePseudoWindow(HWND& hwnd, const HWND owner) = 0; [[nodiscard]] virtual NTSTATUS CreatePseudoWindow(HWND& hwnd, const HWND owner) = 0;
}; };
inline IInteractivityFactory::~IInteractivityFactory() {}
} }

View File

@ -22,7 +22,7 @@ namespace Microsoft::Console::Interactivity
class ISystemConfigurationProvider class ISystemConfigurationProvider
{ {
public: public:
virtual ~ISystemConfigurationProvider() = 0; virtual ~ISystemConfigurationProvider() = default;
virtual bool IsCaretBlinkingEnabled() = 0; virtual bool IsCaretBlinkingEnabled() = 0;
@ -37,13 +37,5 @@ namespace Microsoft::Console::Interactivity
_Inout_ PDWORD pdwTitleLength, _Inout_ PDWORD pdwTitleLength,
_In_ PCWSTR pwszCurrDir, _In_ PCWSTR pwszCurrDir,
_In_ PCWSTR pwszAppName) = 0; _In_ PCWSTR pwszAppName) = 0;
protected:
ISystemConfigurationProvider(){};
ISystemConfigurationProvider(const ISystemConfigurationProvider&) = delete;
ISystemConfigurationProvider& operator=(const ISystemConfigurationProvider&) = delete;
}; };
inline ISystemConfigurationProvider::~ISystemConfigurationProvider() {}
} }

View File

@ -20,16 +20,8 @@ namespace Microsoft::Console::Interactivity
class IWindowMetrics class IWindowMetrics
{ {
public: public:
virtual ~IWindowMetrics() = 0; virtual ~IWindowMetrics() = default;
virtual RECT GetMinClientRectInPixels() = 0; virtual RECT GetMinClientRectInPixels() = 0;
virtual RECT GetMaxClientRectInPixels() = 0; virtual RECT GetMaxClientRectInPixels() = 0;
protected:
IWindowMetrics() {}
IWindowMetrics(const IWindowMetrics&) = delete;
IWindowMetrics& operator=(const IWindowMetrics&) = delete;
}; };
inline IWindowMetrics::~IWindowMetrics() {}
} }

View File

@ -7,34 +7,34 @@
using namespace Microsoft::Console::Interactivity::OneCore; using namespace Microsoft::Console::Interactivity::OneCore;
void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ RECT /*rectangle*/) void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ RECT /*rectangle*/) noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags /*flags*/, _In_ LONG /*position*/) void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags /*flags*/, _In_ LONG /*position*/) noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleUpdateScrollEvent(_In_ LONG /*x*/, _In_ LONG /*y*/) void AccessibilityNotifier::NotifyConsoleUpdateScrollEvent(_In_ LONG /*x*/, _In_ LONG /*y*/) noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleUpdateSimpleEvent(_In_ LONG /*start*/, _In_ LONG /*charAndAttribute*/) void AccessibilityNotifier::NotifyConsoleUpdateSimpleEvent(_In_ LONG /*start*/, _In_ LONG /*charAndAttribute*/) noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleUpdateRegionEvent(_In_ LONG /*startXY*/, _In_ LONG /*endXY*/) void AccessibilityNotifier::NotifyConsoleUpdateRegionEvent(_In_ LONG /*startXY*/, _In_ LONG /*endXY*/) noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleLayoutEvent() void AccessibilityNotifier::NotifyConsoleLayoutEvent() noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleStartApplicationEvent(_In_ DWORD /*processId*/) void AccessibilityNotifier::NotifyConsoleStartApplicationEvent(_In_ DWORD /*processId*/) noexcept
{ {
} }
void AccessibilityNotifier::NotifyConsoleEndApplicationEvent(_In_ DWORD /*processId*/) void AccessibilityNotifier::NotifyConsoleEndApplicationEvent(_In_ DWORD /*processId*/) noexcept
{ {
} }

View File

@ -20,16 +20,16 @@ Author(s):
namespace Microsoft::Console::Interactivity::OneCore namespace Microsoft::Console::Interactivity::OneCore
{ {
class AccessibilityNotifier sealed : public IAccessibilityNotifier class AccessibilityNotifier : public IAccessibilityNotifier
{ {
public: public:
void NotifyConsoleCaretEvent(_In_ RECT rectangle); void NotifyConsoleCaretEvent(_In_ RECT rectangle) noexcept override;
void NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags flags, _In_ LONG position); void NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags flags, _In_ LONG position) noexcept override;
void NotifyConsoleUpdateScrollEvent(_In_ LONG x, _In_ LONG y); void NotifyConsoleUpdateScrollEvent(_In_ LONG x, _In_ LONG y) noexcept override;
void NotifyConsoleUpdateSimpleEvent(_In_ LONG start, _In_ LONG charAndAttribute); void NotifyConsoleUpdateSimpleEvent(_In_ LONG start, _In_ LONG charAndAttribute) noexcept override;
void NotifyConsoleUpdateRegionEvent(_In_ LONG startXY, _In_ LONG endXY); void NotifyConsoleUpdateRegionEvent(_In_ LONG startXY, _In_ LONG endXY) noexcept override;
void NotifyConsoleLayoutEvent(); void NotifyConsoleLayoutEvent() noexcept override;
void NotifyConsoleStartApplicationEvent(_In_ DWORD processId); void NotifyConsoleStartApplicationEvent(_In_ DWORD processId) noexcept override;
void NotifyConsoleEndApplicationEvent(_In_ DWORD processId); void NotifyConsoleEndApplicationEvent(_In_ DWORD processId) noexcept override;
}; };
} }

View File

@ -20,17 +20,17 @@ using namespace Microsoft::Console::Render;
using namespace Microsoft::Console::Interactivity; using namespace Microsoft::Console::Interactivity;
using namespace Microsoft::Console::Interactivity::OneCore; using namespace Microsoft::Console::Interactivity::OneCore;
BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWidth, LONG FontWidth, LONG FontHeight) : BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWidth, LONG FontWidth, LONG FontHeight) noexcept :
RenderEngineBase(), RenderEngineBase(),
_sharedViewBase((ULONG_PTR)SharedViewBase), _sharedViewBase(static_cast<std::byte*>(SharedViewBase)),
_displayHeight(DisplayHeight), _displayHeight(gsl::narrow_cast<SIZE_T>(DisplayHeight)),
_displayWidth(DisplayWidth), _displayWidth(gsl::narrow_cast<SIZE_T>(DisplayWidth)),
_currentLegacyColorAttribute(DEFAULT_COLOR_ATTRIBUTE) _currentLegacyColorAttribute(DEFAULT_COLOR_ATTRIBUTE)
{ {
_runLength = sizeof(CD_IO_CHARACTER) * DisplayWidth; _runLength = sizeof(CD_IO_CHARACTER) * DisplayWidth;
_fontSize.X = FontWidth > SHORT_MAX ? SHORT_MAX : (SHORT)FontWidth; _fontSize.X = FontWidth > SHORT_MAX ? SHORT_MAX : gsl::narrow_cast<SHORT>(FontWidth);
_fontSize.Y = FontHeight > SHORT_MAX ? SHORT_MAX : (SHORT)FontHeight; _fontSize.Y = FontHeight > SHORT_MAX ? SHORT_MAX : gsl::narrow_cast<SHORT>(FontHeight);
} }
[[nodiscard]] HRESULT BgfxEngine::Invalidate(const SMALL_RECT* const /*psrRegion*/) noexcept [[nodiscard]] HRESULT BgfxEngine::Invalidate(const SMALL_RECT* const /*psrRegion*/) noexcept
@ -75,26 +75,23 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
} }
[[nodiscard]] HRESULT BgfxEngine::EndPaint() noexcept [[nodiscard]] HRESULT BgfxEngine::EndPaint() noexcept
try
{ {
NTSTATUS Status; const auto Status = ConIoSrvComm::GetConIoSrvComm()->RequestUpdateDisplay(0);
PVOID OldRunBase;
PVOID NewRunBase;
Status = ConIoSrvComm::GetConIoSrvComm()->RequestUpdateDisplay(0);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
for (SHORT i = 0; i < _displayHeight; i++) for (SIZE_T i = 0; i < _displayHeight; i++)
{ {
OldRunBase = (PVOID)(_sharedViewBase + (i * 2 * _runLength)); const auto OldRunBase = _sharedViewBase + (i * 2 * _runLength);
NewRunBase = (PVOID)(_sharedViewBase + (i * 2 * _runLength) + _runLength); const auto NewRunBase = OldRunBase + _runLength;
memcpy_s(OldRunBase, _runLength, NewRunBase, _runLength); memcpy_s(OldRunBase, _runLength, NewRunBase, _runLength);
} }
} }
return HRESULT_FROM_NT(Status); return HRESULT_FROM_NT(Status);
} }
CATCH_RETURN()
// Routine Description: // Routine Description:
// - Used to perform longer running presentation steps outside the lock so the other threads can continue. // - Used to perform longer running presentation steps outside the lock so the other threads can continue.
@ -115,21 +112,11 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
[[nodiscard]] HRESULT BgfxEngine::PaintBackground() noexcept [[nodiscard]] HRESULT BgfxEngine::PaintBackground() noexcept
{ {
PVOID OldRunBase; for (SIZE_T i = 0; i < _displayHeight; i++)
PVOID NewRunBase;
PCD_IO_CHARACTER OldRun;
PCD_IO_CHARACTER NewRun;
for (SHORT i = 0; i < _displayHeight; i++)
{ {
OldRunBase = (PVOID)(_sharedViewBase + (i * 2 * _runLength)); const auto NewRun = reinterpret_cast<PCD_IO_CHARACTER>(_sharedViewBase + (i * 2 * _runLength) + _runLength);
NewRunBase = (PVOID)(_sharedViewBase + (i * 2 * _runLength) + _runLength);
OldRun = (PCD_IO_CHARACTER)OldRunBase; for (SIZE_T j = 0; j < _displayWidth; j++)
NewRun = (PCD_IO_CHARACTER)NewRunBase;
for (SHORT j = 0; j < _displayWidth; j++)
{ {
NewRun[j].Character = L' '; NewRun[j].Character = L' ';
NewRun[j].Attribute = 0; NewRun[j].Attribute = 0;
@ -146,10 +133,10 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
{ {
try try
{ {
PVOID NewRunBase = (PVOID)(_sharedViewBase + (coord.Y * 2 * _runLength) + _runLength); const auto y = gsl::narrow_cast<SIZE_T>(coord.Y);
PCD_IO_CHARACTER NewRun = (PCD_IO_CHARACTER)NewRunBase; const auto NewRun = reinterpret_cast<PCD_IO_CHARACTER>(_sharedViewBase + (y * 2 * _runLength) + _runLength);
for (size_t i = 0; i < clusters.size() && i < (size_t)_displayWidth; i++) for (SIZE_T i = 0; i < clusters.size() && i < _displayWidth; i++)
{ {
NewRun[coord.X + i].Character = til::at(clusters, i).GetTextAsSingle(); NewRun[coord.X + i].Character = til::at(clusters, i).GetTextAsSingle();
NewRun[coord.X + i].Attribute = _currentLegacyColorAttribute; NewRun[coord.X + i].Attribute = _currentLegacyColorAttribute;
@ -157,7 +144,7 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
return S_OK; return S_OK;
} }
CATCH_RETURN(); CATCH_RETURN()
} }
[[nodiscard]] HRESULT BgfxEngine::PaintBufferGridLines(GridLineSet const /*lines*/, [[nodiscard]] HRESULT BgfxEngine::PaintBufferGridLines(GridLineSet const /*lines*/,
@ -174,6 +161,7 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
} }
[[nodiscard]] HRESULT BgfxEngine::PaintCursor(const CursorOptions& options) noexcept [[nodiscard]] HRESULT BgfxEngine::PaintCursor(const CursorOptions& options) noexcept
try
{ {
// TODO: MSFT: 11448021 - Modify BGFX to support rendering full-width // TODO: MSFT: 11448021 - Modify BGFX to support rendering full-width
// characters and a full-width cursor. // characters and a full-width cursor.
@ -183,10 +171,11 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
CursorInfo.Height = options.ulCursorHeightPercent; CursorInfo.Height = options.ulCursorHeightPercent;
CursorInfo.IsVisible = TRUE; CursorInfo.IsVisible = TRUE;
NTSTATUS Status = ConIoSrvComm::GetConIoSrvComm()->RequestSetCursor(&CursorInfo); const auto Status = ConIoSrvComm::GetConIoSrvComm()->RequestSetCursor(&CursorInfo);
return HRESULT_FROM_NT(Status); return HRESULT_FROM_NT(Status);
} }
CATCH_RETURN()
[[nodiscard]] HRESULT BgfxEngine::UpdateDrawingBrushes(const TextAttribute& textAttributes, [[nodiscard]] HRESULT BgfxEngine::UpdateDrawingBrushes(const TextAttribute& textAttributes,
const RenderSettings& /*renderSettings*/, const RenderSettings& /*renderSettings*/,
@ -228,8 +217,8 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
[[nodiscard]] HRESULT BgfxEngine::GetDirtyArea(gsl::span<const til::rect>& area) noexcept [[nodiscard]] HRESULT BgfxEngine::GetDirtyArea(gsl::span<const til::rect>& area) noexcept
{ {
_dirtyArea.bottom = std::max<LONG>(0, _displayHeight); _dirtyArea.bottom = gsl::narrow_cast<til::CoordType>(std::max(static_cast<SIZE_T>(0), _displayHeight));
_dirtyArea.right = std::max<LONG>(0, _displayWidth); _dirtyArea.right = gsl::narrow_cast<til::CoordType>(std::max(static_cast<SIZE_T>(0), _displayWidth));
area = { &_dirtyArea, area = { &_dirtyArea,
1 }; 1 };

View File

@ -29,8 +29,7 @@ namespace Microsoft::Console::Render
class BgfxEngine final : public RenderEngineBase class BgfxEngine final : public RenderEngineBase
{ {
public: public:
BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWidth, LONG FontWidth, LONG FontHeight); BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWidth, LONG FontWidth, LONG FontHeight) noexcept;
~BgfxEngine() override = default;
// IRenderEngine Members // IRenderEngine Members
[[nodiscard]] HRESULT Invalidate(const SMALL_RECT* const psrRegion) noexcept override; [[nodiscard]] HRESULT Invalidate(const SMALL_RECT* const psrRegion) noexcept override;
@ -76,11 +75,11 @@ namespace Microsoft::Console::Render
[[nodiscard]] HRESULT _DoUpdateTitle(_In_ const std::wstring_view newTitle) noexcept override; [[nodiscard]] HRESULT _DoUpdateTitle(_In_ const std::wstring_view newTitle) noexcept override;
private: private:
ULONG_PTR _sharedViewBase; std::byte* _sharedViewBase;
SIZE_T _runLength; SIZE_T _runLength;
LONG _displayHeight; SIZE_T _displayHeight;
LONG _displayWidth; SIZE_T _displayWidth;
til::rect _dirtyArea; til::rect _dirtyArea;
COORD _fontSize; COORD _fontSize;

View File

@ -27,9 +27,9 @@ using namespace Microsoft::Console::Interactivity::OneCore;
static std::unique_ptr<ConIoSrvComm> s_conIoSrvComm; static std::unique_ptr<ConIoSrvComm> s_conIoSrvComm;
ConIoSrvComm* ConIoSrvComm::GetConIoSrvComm() ConIoSrvComm* ConIoSrvComm::GetConIoSrvComm()
{ {
static bool initialized = []() { static auto initialized = []() {
s_conIoSrvComm = std::make_unique<ConIoSrvComm>(); s_conIoSrvComm = std::make_unique<ConIoSrvComm>();
ServiceLocator::SetOneCoreTeardownFunction([] { ServiceLocator::SetOneCoreTeardownFunction([]() noexcept {
s_conIoSrvComm.reset(nullptr); s_conIoSrvComm.reset(nullptr);
}); });
return true; return true;
@ -37,16 +37,15 @@ ConIoSrvComm* ConIoSrvComm::GetConIoSrvComm()
return s_conIoSrvComm.get(); return s_conIoSrvComm.get();
} }
ConIoSrvComm::ConIoSrvComm() : ConIoSrvComm::ConIoSrvComm() noexcept :
_inputPipeThreadHandle(nullptr), _inputPipeThreadHandle(nullptr),
_pipeReadHandle(INVALID_HANDLE_VALUE), _pipeReadHandle(INVALID_HANDLE_VALUE),
_pipeWriteHandle(INVALID_HANDLE_VALUE), _pipeWriteHandle(INVALID_HANDLE_VALUE),
_alpcClientCommunicationPort(INVALID_HANDLE_VALUE), _alpcClientCommunicationPort(INVALID_HANDLE_VALUE),
_alpcSharedViewSize(0), _alpcSharedViewSize(0),
_alpcSharedViewBase(NULL), _alpcSharedViewBase(nullptr),
_displayMode(CIS_DISPLAY_MODE_NONE), _displayMode(CIS_DISPLAY_MODE_NONE),
_fIsInputInitialized(false), _fIsInputInitialized(false)
pWddmConEngine(nullptr)
{ {
} }
@ -55,6 +54,7 @@ ConIoSrvComm::~ConIoSrvComm()
// Cancel pending IOs on the input thread that might get us stuck. // Cancel pending IOs on the input thread that might get us stuck.
if (_inputPipeThreadHandle) if (_inputPipeThreadHandle)
{ {
#pragma warning(suppress : 26447)
LOG_IF_WIN32_BOOL_FALSE(CancelSynchronousIo(_inputPipeThreadHandle)); LOG_IF_WIN32_BOOL_FALSE(CancelSynchronousIo(_inputPipeThreadHandle));
CloseHandle(_inputPipeThreadHandle); CloseHandle(_inputPipeThreadHandle);
_inputPipeThreadHandle = nullptr; _inputPipeThreadHandle = nullptr;
@ -84,8 +84,6 @@ ConIoSrvComm::~ConIoSrvComm()
[[nodiscard]] NTSTATUS ConIoSrvComm::Connect() [[nodiscard]] NTSTATUS ConIoSrvComm::Connect()
{ {
NTSTATUS Status = STATUS_SUCCESS;
// Port handle and name. // Port handle and name.
HANDLE PortHandle; HANDLE PortHandle;
static UNICODE_STRING PortName = RTL_CONSTANT_STRING(CIS_ALPC_PORT_NAME); static UNICODE_STRING PortName = RTL_CONSTANT_STRING(CIS_ALPC_PORT_NAME);
@ -101,29 +99,25 @@ ConIoSrvComm::~ConIoSrvComm()
// Connection message attributes. // Connection message attributes.
SIZE_T ConnectionMessageAttributesBufferLength; SIZE_T ConnectionMessageAttributesBufferLength;
UCHAR ConnectionMessageAttributesBuffer[CIS_MSG_ATTR_BUFFER_SIZE]; std::aligned_storage_t<CIS_MSG_ATTR_BUFFER_SIZE, alignof(ALPC_MESSAGE_ATTRIBUTES)> ConnectionMessageAttributesBuffer;
// Type-specific pointers into the connection message attributes.
PALPC_HANDLE_ATTR HandleAttributes;
PALPC_DATA_VIEW_ATTR ViewAttributes;
// Structure used to iterate over the handles given to us by the server. // Structure used to iterate over the handles given to us by the server.
ALPC_MESSAGE_HANDLE_INFORMATION HandleInfo; ALPC_MESSAGE_HANDLE_INFORMATION HandleInfo;
// Initialize the attributes of the port object. // Initialize the attributes of the port object.
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
NULL, nullptr,
0, 0,
NULL, nullptr,
NULL); nullptr);
// Initialize the connection message attributes. // Initialize the connection message attributes.
PALPC_MESSAGE_ATTRIBUTES ConnectionMessageAttributes = (PALPC_MESSAGE_ATTRIBUTES)&ConnectionMessageAttributesBuffer; const auto ConnectionMessageAttributes = reinterpret_cast<PALPC_MESSAGE_ATTRIBUTES>(&ConnectionMessageAttributesBuffer);
Status = AlpcInitializeMessageAttribute(CIS_MSG_ATTR_FLAGS, auto Status = AlpcInitializeMessageAttribute(CIS_MSG_ATTR_FLAGS,
ConnectionMessageAttributes, ConnectionMessageAttributes,
CIS_MSG_ATTR_BUFFER_SIZE, CIS_MSG_ATTR_BUFFER_SIZE,
&ConnectionMessageAttributesBufferLength); &ConnectionMessageAttributesBufferLength);
// Set up the default security QoS descriptor. // Set up the default security QoS descriptor.
const SECURITY_QUALITY_OF_SERVICE DefaultQoS = { const SECURITY_QUALITY_OF_SERVICE DefaultQoS = {
@ -152,26 +146,26 @@ ConIoSrvComm::~ConIoSrvComm()
ConnectionMessage.AlpcHeader.u1.s1.TotalLength = sizeof(CIS_MSG); ConnectionMessage.AlpcHeader.u1.s1.TotalLength = sizeof(CIS_MSG);
ConnectionMessage.AlpcHeader.u1.s1.DataLength = sizeof(CIS_MSG) - sizeof(PORT_MESSAGE); ConnectionMessage.AlpcHeader.u1.s1.DataLength = sizeof(CIS_MSG) - sizeof(PORT_MESSAGE);
ConnectionMessage.AlpcHeader.ClientId.UniqueProcess = 0; ConnectionMessage.AlpcHeader.ClientId.UniqueProcess = nullptr;
ConnectionMessage.AlpcHeader.ClientId.UniqueThread = 0; ConnectionMessage.AlpcHeader.ClientId.UniqueThread = nullptr;
// Request to connect to the server. // Request to connect to the server.
ConnectionMessageLength = sizeof(CIS_MSG); ConnectionMessageLength = sizeof(CIS_MSG);
Status = NtAlpcConnectPort(&PortHandle, Status = NtAlpcConnectPort(&PortHandle,
&PortName, &PortName,
NULL, nullptr,
&PortAttributes, &PortAttributes,
ALPC_MSGFLG_SYNC_REQUEST, ALPC_MSGFLG_SYNC_REQUEST,
NULL, nullptr,
(PPORT_MESSAGE)&ConnectionMessage, &ConnectionMessage.AlpcHeader,
&ConnectionMessageLength, &ConnectionMessageLength,
NULL, nullptr,
ConnectionMessageAttributes, ConnectionMessageAttributes,
0); nullptr);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
ViewAttributes = ALPC_GET_DATAVIEW_ATTRIBUTES(ConnectionMessageAttributes); const auto ViewAttributes = ALPC_GET_DATAVIEW_ATTRIBUTES(ConnectionMessageAttributes);
HandleAttributes = ALPC_GET_HANDLE_ATTRIBUTES(ConnectionMessageAttributes); const auto HandleAttributes = ALPC_GET_HANDLE_ATTRIBUTES(ConnectionMessageAttributes);
// We must have exactly two handles, one for read, and one for write for // We must have exactly two handles, one for read, and one for write for
// the pipe. // the pipe.
@ -189,11 +183,11 @@ ConIoSrvComm::~ConIoSrvComm()
HandleInfo.Index = Index; HandleInfo.Index = Index;
Status = NtAlpcQueryInformationMessage(PortHandle, Status = NtAlpcQueryInformationMessage(PortHandle,
(PPORT_MESSAGE)&ConnectionMessage, &ConnectionMessage.AlpcHeader,
AlpcMessageHandleInformation, AlpcMessageHandleInformation,
&HandleInfo, &HandleInfo,
sizeof(HandleInfo), sizeof(HandleInfo),
NULL); nullptr);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
if (Index == 0) if (Index == 0)
@ -253,17 +247,15 @@ VOID ConIoSrvComm::ServiceInputPipe()
FALSE, FALSE,
DUPLICATE_SAME_ACCESS)); DUPLICATE_SAME_ACCESS));
BOOL Ret; CIS_EVENT Event{};
CIS_EVENT Event = { 0 };
while (TRUE) while (TRUE)
{ {
Ret = ReadFile(_pipeReadHandle, const auto Ret = ReadFile(_pipeReadHandle,
&Event, &Event,
sizeof(CIS_EVENT), sizeof(CIS_EVENT),
NULL, nullptr,
NULL); nullptr);
if (Ret != FALSE) if (Ret != FALSE)
{ {
@ -273,8 +265,8 @@ VOID ConIoSrvComm::ServiceInputPipe()
case CIS_EVENT_TYPE_INPUT: case CIS_EVENT_TYPE_INPUT:
try try
{ {
KEY_EVENT_RECORD keyRecord = Event.InputEvent.Record.Event.KeyEvent; const auto keyRecord = Event.InputEvent.Record.Event.KeyEvent;
KeyEvent keyEvent{ keyRecord }; const KeyEvent keyEvent{ keyRecord };
HandleGenericKeyEvent(keyEvent, false); HandleGenericKeyEvent(keyEvent, false);
} }
catch (...) catch (...)
@ -282,10 +274,11 @@ VOID ConIoSrvComm::ServiceInputPipe()
LOG_HR(wil::ResultFromCaughtException()); LOG_HR(wil::ResultFromCaughtException());
} }
break; break;
case CIS_EVENT_TYPE_FOCUS: case CIS_EVENT_TYPE_FOCUS:
HandleFocusEvent(&Event); HandleFocusEvent(&Event);
break; break;
default:
break;
} }
UnlockConsole(); UnlockConsole();
} }
@ -299,38 +292,34 @@ VOID ConIoSrvComm::ServiceInputPipe()
[[nodiscard]] NTSTATUS ConIoSrvComm::SendRequestReceiveReply(PCIS_MSG Message) const [[nodiscard]] NTSTATUS ConIoSrvComm::SendRequestReceiveReply(PCIS_MSG Message) const
{ {
NTSTATUS Status;
Message->AlpcHeader.MessageId = 0; Message->AlpcHeader.MessageId = 0;
Message->AlpcHeader.u2.ZeroInit = 0; Message->AlpcHeader.u2.ZeroInit = 0;
Message->AlpcHeader.u1.s1.TotalLength = sizeof(CIS_MSG); Message->AlpcHeader.u1.s1.TotalLength = sizeof(CIS_MSG);
Message->AlpcHeader.u1.s1.DataLength = sizeof(CIS_MSG) - sizeof(PORT_MESSAGE); Message->AlpcHeader.u1.s1.DataLength = sizeof(CIS_MSG) - sizeof(PORT_MESSAGE);
Message->AlpcHeader.ClientId.UniqueProcess = 0; Message->AlpcHeader.ClientId.UniqueProcess = nullptr;
Message->AlpcHeader.ClientId.UniqueThread = 0; Message->AlpcHeader.ClientId.UniqueThread = nullptr;
SIZE_T ActualReceiveMessageLength = sizeof(CIS_MSG); SIZE_T ActualReceiveMessageLength = sizeof(CIS_MSG);
Status = NtAlpcSendWaitReceivePort(_alpcClientCommunicationPort, const auto Status = NtAlpcSendWaitReceivePort(_alpcClientCommunicationPort,
0, 0,
(PPORT_MESSAGE)Message, &Message->AlpcHeader,
NULL, nullptr,
(PPORT_MESSAGE)Message, &Message->AlpcHeader,
&ActualReceiveMessageLength, &ActualReceiveMessageLength,
NULL, nullptr,
0); nullptr);
return Status; return Status;
} }
VOID ConIoSrvComm::HandleFocusEvent(PCIS_EVENT Event) VOID ConIoSrvComm::HandleFocusEvent(const CIS_EVENT* const Event)
{ {
BOOL Ret;
Renderer* Renderer;
CIS_EVENT ReplyEvent; CIS_EVENT ReplyEvent;
Renderer = ServiceLocator::LocateGlobals().pRender; auto Renderer = ServiceLocator::LocateGlobals().pRender;
switch (_displayMode) switch (_displayMode)
{ {
@ -348,7 +337,7 @@ VOID ConIoSrvComm::HandleFocusEvent(PCIS_EVENT Event)
case CIS_DISPLAY_MODE_DIRECTX: case CIS_DISPLAY_MODE_DIRECTX:
{ {
Globals& globals = ServiceLocator::LocateGlobals(); auto& globals = ServiceLocator::LocateGlobals();
if (Event->FocusEvent.IsActive) if (Event->FocusEvent.IsActive)
{ {
@ -367,13 +356,13 @@ VOID ConIoSrvComm::HandleFocusEvent(PCIS_EVENT Event)
// Right after we initialize, synchronize the screen/viewport states with the WddmCon surface dimensions // Right after we initialize, synchronize the screen/viewport states with the WddmCon surface dimensions
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
const RECT rcOld = { 0 }; const RECT rcOld{};
// WddmEngine reports display size in characters, adjust to pixels for resize window calc. // WddmEngine reports display size in characters, adjust to pixels for resize window calc.
RECT rcDisplay = pWddmConEngine->GetDisplaySize(); auto rcDisplay = pWddmConEngine->GetDisplaySize();
// Get font to adjust char to pixels. // Get font to adjust char to pixels.
COORD coordFont = { 0 }; COORD coordFont{};
LOG_IF_FAILED(pWddmConEngine->GetFontSize(&coordFont)); LOG_IF_FAILED(pWddmConEngine->GetFontSize(&coordFont));
rcDisplay.right *= coordFont.X; rcDisplay.right *= coordFont.X;
@ -415,11 +404,11 @@ VOID ConIoSrvComm::HandleFocusEvent(PCIS_EVENT Event)
// Let the Console IO Server that we have relinquished // Let the Console IO Server that we have relinquished
// control of the display. // control of the display.
ReplyEvent.Type = CIS_EVENT_TYPE_FOCUS_ACK; ReplyEvent.Type = CIS_EVENT_TYPE_FOCUS_ACK;
Ret = WriteFile(_pipeWriteHandle, WriteFile(_pipeWriteHandle,
&ReplyEvent, &ReplyEvent,
sizeof(CIS_EVENT), sizeof(CIS_EVENT),
NULL, nullptr,
NULL); nullptr);
} }
} }
} }
@ -471,12 +460,10 @@ VOID ConIoSrvComm::CleanupForHeadless(const NTSTATUS status)
[[nodiscard]] NTSTATUS ConIoSrvComm::RequestGetDisplaySize(_Inout_ PCD_IO_DISPLAY_SIZE pCdDisplaySize) const [[nodiscard]] NTSTATUS ConIoSrvComm::RequestGetDisplaySize(_Inout_ PCD_IO_DISPLAY_SIZE pCdDisplaySize) const
{ {
NTSTATUS Status; CIS_MSG Message{};
CIS_MSG Message = { 0 };
Message.Type = CIS_MSG_TYPE_GETDISPLAYSIZE; Message.Type = CIS_MSG_TYPE_GETDISPLAYSIZE;
Status = SendRequestReceiveReply(&Message); auto Status = SendRequestReceiveReply(&Message);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*pCdDisplaySize = Message.GetDisplaySizeParams.DisplaySize; *pCdDisplaySize = Message.GetDisplaySizeParams.DisplaySize;
@ -488,12 +475,10 @@ VOID ConIoSrvComm::CleanupForHeadless(const NTSTATUS status)
[[nodiscard]] NTSTATUS ConIoSrvComm::RequestGetFontSize(_Inout_ PCD_IO_FONT_SIZE pCdFontSize) const [[nodiscard]] NTSTATUS ConIoSrvComm::RequestGetFontSize(_Inout_ PCD_IO_FONT_SIZE pCdFontSize) const
{ {
NTSTATUS Status; CIS_MSG Message{};
CIS_MSG Message = { 0 };
Message.Type = CIS_MSG_TYPE_GETFONTSIZE; Message.Type = CIS_MSG_TYPE_GETFONTSIZE;
Status = SendRequestReceiveReply(&Message); auto Status = SendRequestReceiveReply(&Message);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*pCdFontSize = Message.GetFontSizeParams.FontSize; *pCdFontSize = Message.GetFontSizeParams.FontSize;
@ -503,15 +488,13 @@ VOID ConIoSrvComm::CleanupForHeadless(const NTSTATUS status)
return Status; return Status;
} }
[[nodiscard]] NTSTATUS ConIoSrvComm::RequestSetCursor(_In_ CD_IO_CURSOR_INFORMATION* const pCdCursorInformation) const [[nodiscard]] NTSTATUS ConIoSrvComm::RequestSetCursor(_In_ const CD_IO_CURSOR_INFORMATION* const pCdCursorInformation) const
{ {
NTSTATUS Status; CIS_MSG Message{};
CIS_MSG Message = { 0 };
Message.Type = CIS_MSG_TYPE_SETCURSOR; Message.Type = CIS_MSG_TYPE_SETCURSOR;
Message.SetCursorParams.CursorInformation = *pCdCursorInformation; Message.SetCursorParams.CursorInformation = *pCdCursorInformation;
Status = SendRequestReceiveReply(&Message); auto Status = SendRequestReceiveReply(&Message);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
Status = Message.SetCursorParams.ReturnValue; Status = Message.SetCursorParams.ReturnValue;
@ -522,13 +505,11 @@ VOID ConIoSrvComm::CleanupForHeadless(const NTSTATUS status)
[[nodiscard]] NTSTATUS ConIoSrvComm::RequestUpdateDisplay(_In_ SHORT RowIndex) const [[nodiscard]] NTSTATUS ConIoSrvComm::RequestUpdateDisplay(_In_ SHORT RowIndex) const
{ {
NTSTATUS Status; CIS_MSG Message{};
CIS_MSG Message = { 0 };
Message.Type = CIS_MSG_TYPE_UPDATEDISPLAY; Message.Type = CIS_MSG_TYPE_UPDATEDISPLAY;
Message.UpdateDisplayParams.RowIndex = RowIndex; Message.UpdateDisplayParams.RowIndex = RowIndex;
Status = SendRequestReceiveReply(&Message); auto Status = SendRequestReceiveReply(&Message);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
Status = Message.UpdateDisplayParams.ReturnValue; Status = Message.UpdateDisplayParams.ReturnValue;
@ -537,12 +518,12 @@ VOID ConIoSrvComm::CleanupForHeadless(const NTSTATUS status)
return Status; return Status;
} }
[[nodiscard]] USHORT ConIoSrvComm::GetDisplayMode() const [[nodiscard]] USHORT ConIoSrvComm::GetDisplayMode() const noexcept
{ {
return _displayMode; return _displayMode;
} }
PVOID ConIoSrvComm::GetSharedViewBase() const PVOID ConIoSrvComm::GetSharedViewBase() const noexcept
{ {
return _alpcSharedViewBase; return _alpcSharedViewBase;
} }
@ -551,20 +532,18 @@ PVOID ConIoSrvComm::GetSharedViewBase() const
[[nodiscard]] NTSTATUS ConIoSrvComm::InitializeBgfx() [[nodiscard]] NTSTATUS ConIoSrvComm::InitializeBgfx()
{ {
NTSTATUS Status; const auto& globals = ServiceLocator::LocateGlobals();
Globals& globals = ServiceLocator::LocateGlobals();
FAIL_FAST_IF_NULL(globals.pRender); FAIL_FAST_IF_NULL(globals.pRender);
IWindowMetrics* const Metrics = ServiceLocator::LocateWindowMetrics(); const auto Metrics = ServiceLocator::LocateWindowMetrics();
// Fetch the display size from the console driver. // Fetch the display size from the console driver.
const RECT DisplaySize = Metrics->GetMaxClientRectInPixels(); const auto DisplaySize = Metrics->GetMaxClientRectInPixels();
Status = GetLastError(); auto Status = GetLastError();
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
// Same with the font size. // Same with the font size.
CD_IO_FONT_SIZE FontSize = { 0 }; CD_IO_FONT_SIZE FontSize{};
Status = RequestGetFontSize(&FontSize); Status = RequestGetFontSize(&FontSize);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -572,13 +551,14 @@ PVOID ConIoSrvComm::GetSharedViewBase() const
try try
{ {
// Create and set the render engine. // Create and set the render engine.
BgfxEngine* const pBgfxEngine = new BgfxEngine(GetSharedViewBase(), _bgfxEngine = std::make_unique<BgfxEngine>(
DisplaySize.bottom / FontSize.Height, GetSharedViewBase(),
DisplaySize.right / FontSize.Width, DisplaySize.bottom / FontSize.Height,
FontSize.Width, DisplaySize.right / FontSize.Width,
FontSize.Height); FontSize.Width,
FontSize.Height);
globals.pRender->AddRenderEngine(pBgfxEngine); globals.pRender->AddRenderEngine(_bgfxEngine.get());
} }
catch (...) catch (...)
{ {
@ -592,13 +572,13 @@ PVOID ConIoSrvComm::GetSharedViewBase() const
[[nodiscard]] NTSTATUS ConIoSrvComm::InitializeWddmCon() [[nodiscard]] NTSTATUS ConIoSrvComm::InitializeWddmCon()
{ {
Globals& globals = ServiceLocator::LocateGlobals(); const auto& globals = ServiceLocator::LocateGlobals();
FAIL_FAST_IF_NULL(globals.pRender); FAIL_FAST_IF_NULL(globals.pRender);
try try
{ {
pWddmConEngine = new WddmConEngine(); pWddmConEngine = std::make_unique<WddmConEngine>();
globals.pRender->AddRenderEngine(pWddmConEngine); globals.pRender->AddRenderEngine(pWddmConEngine.get());
} }
catch (...) catch (...)
{ {

View File

@ -19,7 +19,7 @@ Author(s):
#include "ConIoSrv.h" #include "ConIoSrv.h"
#include "BgfxEngine.hpp" #include "BgfxEngine.hpp"
#include "../../renderer/wddmcon/wddmconrenderer.hpp" #include "../../renderer/wddmcon/WddmConRenderer.hpp"
#pragma hdrstop #pragma hdrstop
@ -28,7 +28,7 @@ namespace Microsoft::Console::Interactivity::OneCore
class ConIoSrvComm final class ConIoSrvComm final
{ {
public: public:
ConIoSrvComm(); ConIoSrvComm() noexcept;
~ConIoSrvComm(); ~ConIoSrvComm();
static ConIoSrvComm* GetConIoSrvComm(); static ConIoSrvComm* GetConIoSrvComm();
@ -38,25 +38,27 @@ namespace Microsoft::Console::Interactivity::OneCore
[[nodiscard]] NTSTATUS RequestGetDisplaySize(_Inout_ PCD_IO_DISPLAY_SIZE pCdDisplaySize) const; [[nodiscard]] NTSTATUS RequestGetDisplaySize(_Inout_ PCD_IO_DISPLAY_SIZE pCdDisplaySize) const;
[[nodiscard]] NTSTATUS RequestGetFontSize(_Inout_ PCD_IO_FONT_SIZE pCdFontSize) const; [[nodiscard]] NTSTATUS RequestGetFontSize(_Inout_ PCD_IO_FONT_SIZE pCdFontSize) const;
[[nodiscard]] NTSTATUS RequestSetCursor(_In_ CD_IO_CURSOR_INFORMATION* const pCdCursorInformation) const; [[nodiscard]] NTSTATUS RequestSetCursor(_In_ const CD_IO_CURSOR_INFORMATION* const pCdCursorInformation) const;
[[nodiscard]] NTSTATUS RequestUpdateDisplay(_In_ SHORT RowIndex) const; [[nodiscard]] NTSTATUS RequestUpdateDisplay(_In_ SHORT RowIndex) const;
[[nodiscard]] USHORT GetDisplayMode() const; [[nodiscard]] USHORT GetDisplayMode() const noexcept;
PVOID GetSharedViewBase() const; PVOID GetSharedViewBase() const noexcept;
VOID CleanupForHeadless(const NTSTATUS status); VOID CleanupForHeadless(const NTSTATUS status);
[[nodiscard]] NTSTATUS InitializeBgfx(); [[nodiscard]] NTSTATUS InitializeBgfx();
[[nodiscard]] NTSTATUS InitializeWddmCon(); [[nodiscard]] NTSTATUS InitializeWddmCon();
Microsoft::Console::Render::WddmConEngine* pWddmConEngine; std::unique_ptr<Render::WddmConEngine> pWddmConEngine;
private: private:
[[nodiscard]] NTSTATUS EnsureConnection(); [[nodiscard]] NTSTATUS EnsureConnection();
[[nodiscard]] NTSTATUS SendRequestReceiveReply(PCIS_MSG Message) const; [[nodiscard]] NTSTATUS SendRequestReceiveReply(PCIS_MSG Message) const;
VOID HandleFocusEvent(PCIS_EVENT const FocusEvent); VOID HandleFocusEvent(const CIS_EVENT* const FocusEvent);
std::unique_ptr<Render::BgfxEngine> _bgfxEngine;
HANDLE _inputPipeThreadHandle; HANDLE _inputPipeThreadHandle;

View File

@ -12,28 +12,28 @@ using namespace Microsoft::Console::Interactivity::OneCore;
#pragma region IConsoleControl Members #pragma region IConsoleControl Members
[[nodiscard]] NTSTATUS ConsoleControl::NotifyConsoleApplication(_In_ DWORD /*dwProcessId*/) [[nodiscard]] NTSTATUS ConsoleControl::NotifyConsoleApplication(_In_ DWORD /*dwProcessId*/) noexcept
{ {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
[[nodiscard]] NTSTATUS ConsoleControl::SetForeground(_In_ HANDLE /*hProcess*/, _In_ BOOL /*fForeground*/) [[nodiscard]] NTSTATUS ConsoleControl::SetForeground(_In_ HANDLE /*hProcess*/, _In_ BOOL /*fForeground*/) noexcept
{ {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
[[nodiscard]] NTSTATUS ConsoleControl::EndTask(_In_ HANDLE hProcessId, _In_ DWORD dwEventType, _In_ ULONG ulCtrlFlags) [[nodiscard]] NTSTATUS ConsoleControl::EndTask(_In_ HANDLE hProcessId, _In_ DWORD dwEventType, _In_ ULONG ulCtrlFlags)
{ {
USER_API_MSG m; USER_API_MSG m{};
PENDTASKMSG a = &m.u.EndTask; const auto a = &m.u.EndTask;
RtlZeroMemory(a, sizeof(*a)); RtlZeroMemory(a, sizeof(*a));
a->ProcessId = hProcessId; a->ProcessId = hProcessId;
a->ConsoleEventCode = dwEventType; a->ConsoleEventCode = dwEventType;
a->ConsoleFlags = ulCtrlFlags; a->ConsoleFlags = ulCtrlFlags;
return CsrClientCallServer((PCSR_API_MSG)&m, return CsrClientCallServer(reinterpret_cast<PCSR_API_MSG>(&m),
NULL, nullptr,
CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpEndTask), CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpEndTask),
sizeof(*a)); sizeof(*a));
} }

View File

@ -20,12 +20,12 @@ Author(s):
namespace Microsoft::Console::Interactivity::OneCore namespace Microsoft::Console::Interactivity::OneCore
{ {
class ConsoleControl sealed : public IConsoleControl class ConsoleControl : public IConsoleControl
{ {
public: public:
// IConsoleControl Members // IConsoleControl Members
[[nodiscard]] NTSTATUS NotifyConsoleApplication(_In_ DWORD dwProcessId); [[nodiscard]] NTSTATUS NotifyConsoleApplication(_In_ DWORD dwProcessId) noexcept override;
[[nodiscard]] NTSTATUS SetForeground(_In_ HANDLE hProcess, _In_ BOOL fForeground); [[nodiscard]] NTSTATUS SetForeground(_In_ HANDLE hProcess, _In_ BOOL fForeground) noexcept override;
[[nodiscard]] NTSTATUS EndTask(_In_ HANDLE hProcessId, _In_ DWORD dwEventType, _In_ ULONG ulCtrlFlags); [[nodiscard]] NTSTATUS EndTask(_In_ HANDLE hProcessId, _In_ DWORD dwEventType, _In_ ULONG ulCtrlFlags) override;
}; };
} }

View File

@ -18,24 +18,23 @@ using namespace Microsoft::Console::Interactivity::OneCore;
DWORD WINAPI ConsoleInputThreadProcOneCore(LPVOID /*lpParam*/) DWORD WINAPI ConsoleInputThreadProcOneCore(LPVOID /*lpParam*/)
{ {
Globals& globals = ServiceLocator::LocateGlobals(); auto& globals = ServiceLocator::LocateGlobals();
ConIoSrvComm* const Server = ConIoSrvComm::GetConIoSrvComm(); const auto Server = ConIoSrvComm::GetConIoSrvComm();
NTSTATUS Status = Server->Connect(); auto Status = Server->Connect();
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
USHORT DisplayMode = Server->GetDisplayMode(); const auto DisplayMode = Server->GetDisplayMode();
if (DisplayMode != CIS_DISPLAY_MODE_NONE) if (DisplayMode != CIS_DISPLAY_MODE_NONE)
{ {
// Create and set the console window. // Create and set the console window.
ConsoleWindow* const wnd = new (std::nothrow) ConsoleWindow(); static ConsoleWindow wnd;
Status = NT_TESTNULL(wnd);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
LOG_IF_FAILED(ServiceLocator::SetConsoleWindowInstance(wnd)); LOG_IF_FAILED(ServiceLocator::SetConsoleWindowInstance(&wnd));
// The console's renderer should be created before we get here. // The console's renderer should be created before we get here.
FAIL_FAST_IF_NULL(globals.pRender); FAIL_FAST_IF_NULL(globals.pRender);
@ -45,10 +44,11 @@ DWORD WINAPI ConsoleInputThreadProcOneCore(LPVOID /*lpParam*/)
case CIS_DISPLAY_MODE_BGFX: case CIS_DISPLAY_MODE_BGFX:
Status = Server->InitializeBgfx(); Status = Server->InitializeBgfx();
break; break;
case CIS_DISPLAY_MODE_DIRECTX: case CIS_DISPLAY_MODE_DIRECTX:
Status = Server->InitializeWddmCon(); Status = Server->InitializeWddmCon();
break; break;
default:
break;
} }
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -106,17 +106,16 @@ DWORD WINAPI ConsoleInputThreadProcOneCore(LPVOID /*lpParam*/)
// Routine Description: // Routine Description:
// - Starts the OneCore-specific console input thread. // - Starts the OneCore-specific console input thread.
HANDLE ConsoleInputThread::Start() HANDLE ConsoleInputThread::Start() noexcept
{ {
HANDLE hThread = nullptr; auto dwThreadId = gsl::narrow_cast<DWORD>(-1);
DWORD dwThreadId = (DWORD)-1;
hThread = CreateThread(nullptr, const auto hThread = CreateThread(nullptr,
0, 0,
ConsoleInputThreadProcOneCore, ConsoleInputThreadProcOneCore,
nullptr, nullptr,
0, 0,
&dwThreadId); &dwThreadId);
if (hThread) if (hThread)
{ {
_hThread = hThread; _hThread = hThread;

View File

@ -21,9 +21,9 @@ Author(s):
namespace Microsoft::Console::Interactivity::OneCore namespace Microsoft::Console::Interactivity::OneCore
{ {
class ConsoleInputThread sealed : public IConsoleInputThread class ConsoleInputThread : public IConsoleInputThread
{ {
public: public:
HANDLE Start(); HANDLE Start() noexcept override;
}; };
} }

View File

@ -11,7 +11,7 @@
using namespace Microsoft::Console::Interactivity::OneCore; using namespace Microsoft::Console::Interactivity::OneCore;
using namespace Microsoft::Console::Types; using namespace Microsoft::Console::Types;
BOOL ConsoleWindow::EnableBothScrollBars() BOOL ConsoleWindow::EnableBothScrollBars() noexcept
{ {
return FALSE; return FALSE;
} }
@ -20,28 +20,28 @@ int ConsoleWindow::UpdateScrollBar(bool /*isVertical*/,
bool /*isAltBuffer*/, bool /*isAltBuffer*/,
UINT /*pageSize*/, UINT /*pageSize*/,
int /*maxSize*/, int /*maxSize*/,
int /*viewportPosition*/) int /*viewportPosition*/) noexcept
{ {
return 0; return 0;
} }
bool ConsoleWindow::IsInFullscreen() const bool ConsoleWindow::IsInFullscreen() const noexcept
{ {
return true; return true;
} }
void ConsoleWindow::SetIsFullscreen(const bool /*fFullscreenEnabled*/) void ConsoleWindow::SetIsFullscreen(const bool /*fFullscreenEnabled*/) noexcept
{ {
} }
void ConsoleWindow::ChangeViewport(const SMALL_RECT NewWindow) void ConsoleWindow::ChangeViewport(const SMALL_RECT NewWindow)
{ {
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation(); auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
SCREEN_INFORMATION& ScreenInfo = gci.GetActiveOutputBuffer(); auto& ScreenInfo = gci.GetActiveOutputBuffer();
const COORD FontSize = ScreenInfo.GetScreenFontSize(); const auto FontSize = ScreenInfo.GetScreenFontSize();
Selection* pSelection = &Selection::Instance(); auto pSelection = &Selection::Instance();
pSelection->HideSelection(); pSelection->HideSelection();
ScreenInfo.SetViewport(Viewport::FromInclusive(NewWindow), true); ScreenInfo.SetViewport(Viewport::FromInclusive(NewWindow), true);
@ -56,87 +56,86 @@ void ConsoleWindow::ChangeViewport(const SMALL_RECT NewWindow)
ScreenInfo.UpdateScrollBars(); ScreenInfo.UpdateScrollBars();
} }
void ConsoleWindow::CaptureMouse() void ConsoleWindow::CaptureMouse() noexcept
{ {
} }
BOOL ConsoleWindow::ReleaseMouse() BOOL ConsoleWindow::ReleaseMouse() noexcept
{ {
return TRUE; return TRUE;
} }
HWND ConsoleWindow::GetWindowHandle() const HWND ConsoleWindow::GetWindowHandle() const noexcept
{ {
return nullptr; return nullptr;
} }
void ConsoleWindow::SetOwner() void ConsoleWindow::SetOwner() noexcept
{ {
} }
BOOL ConsoleWindow::GetCursorPosition(LPPOINT /*lpPoint*/) BOOL ConsoleWindow::GetCursorPosition(LPPOINT /*lpPoint*/) noexcept
{ {
return FALSE; return FALSE;
} }
BOOL ConsoleWindow::GetClientRectangle(LPRECT /*lpRect*/) BOOL ConsoleWindow::GetClientRectangle(LPRECT /*lpRect*/) noexcept
{ {
return FALSE; return FALSE;
} }
int ConsoleWindow::MapPoints(LPPOINT /*lpPoints*/, UINT /*cPoints*/) int ConsoleWindow::MapPoints(LPPOINT /*lpPoints*/, UINT /*cPoints*/) noexcept
{ {
return 0; return 0;
} }
BOOL ConsoleWindow::ConvertScreenToClient(LPPOINT /*lpPoint*/) BOOL ConsoleWindow::ConvertScreenToClient(LPPOINT /*lpPoint*/) noexcept
{ {
return 0; return 0;
} }
BOOL ConsoleWindow::SendNotifyBeep() const BOOL ConsoleWindow::SendNotifyBeep() const noexcept
{ {
return Beep(800, 200); return Beep(800, 200);
} }
BOOL ConsoleWindow::PostUpdateScrollBars() const BOOL ConsoleWindow::PostUpdateScrollBars() const noexcept
{ {
return FALSE; return FALSE;
} }
BOOL ConsoleWindow::PostUpdateWindowSize() const BOOL ConsoleWindow::PostUpdateWindowSize() const noexcept
{ {
return FALSE; return FALSE;
} }
void ConsoleWindow::UpdateWindowSize(const COORD /*coordSizeInChars*/) void ConsoleWindow::UpdateWindowSize(const COORD /*coordSizeInChars*/) noexcept
{ {
} }
void ConsoleWindow::UpdateWindowText() void ConsoleWindow::UpdateWindowText() noexcept
{ {
} }
void ConsoleWindow::HorizontalScroll(const WORD /*wScrollCommand*/, const WORD /*wAbsoluteChange*/) void ConsoleWindow::HorizontalScroll(const WORD /*wScrollCommand*/, const WORD /*wAbsoluteChange*/) noexcept
{ {
} }
void ConsoleWindow::VerticalScroll(const WORD /*wScrollCommand*/, const WORD /*wAbsoluteChange*/) void ConsoleWindow::VerticalScroll(const WORD /*wScrollCommand*/, const WORD /*wAbsoluteChange*/) noexcept
{ {
} }
[[nodiscard]] HRESULT ConsoleWindow::SignalUia(_In_ EVENTID /*id*/) [[nodiscard]] HRESULT ConsoleWindow::SignalUia(_In_ EVENTID /*id*/) noexcept
{ {
return E_NOTIMPL; return E_NOTIMPL;
} }
[[nodiscard]] HRESULT ConsoleWindow::UiaSetTextAreaFocus() [[nodiscard]] HRESULT ConsoleWindow::UiaSetTextAreaFocus() noexcept
{ {
return E_NOTIMPL; return E_NOTIMPL;
} }
RECT ConsoleWindow::GetWindowRect() const noexcept RECT ConsoleWindow::GetWindowRect() const noexcept
{ {
RECT rc = { 0 }; return {};
return rc;
} }

View File

@ -20,43 +20,42 @@ Author(s):
namespace Microsoft::Console::Interactivity::OneCore namespace Microsoft::Console::Interactivity::OneCore
{ {
class ConsoleWindow sealed : public Microsoft::Console::Types::IConsoleWindow class ConsoleWindow : public Microsoft::Console::Types::IConsoleWindow
{ {
public: public:
// Inherited via IConsoleWindow // Inherited via IConsoleWindow
BOOL EnableBothScrollBars(); BOOL EnableBothScrollBars() noexcept override;
int UpdateScrollBar(bool isVertical, bool isAltBuffer, UINT pageSize, int maxSize, int viewportPosition); int UpdateScrollBar(bool isVertical, bool isAltBuffer, UINT pageSize, int maxSize, int viewportPosition) noexcept override;
bool IsInFullscreen() const; bool IsInFullscreen() const noexcept override;
void SetIsFullscreen(const bool fFullscreenEnabled); void SetIsFullscreen(const bool fFullscreenEnabled) noexcept override;
void ChangeViewport(const SMALL_RECT NewWindow); void ChangeViewport(const SMALL_RECT NewWindow) override;
void CaptureMouse(); void CaptureMouse() noexcept override;
BOOL ReleaseMouse(); BOOL ReleaseMouse() noexcept override;
HWND GetWindowHandle() const; HWND GetWindowHandle() const noexcept override;
void SetOwner(); void SetOwner() noexcept override;
BOOL GetCursorPosition(LPPOINT lpPoint); BOOL GetCursorPosition(LPPOINT lpPoint) noexcept override;
BOOL GetClientRectangle(LPRECT lpRect); BOOL GetClientRectangle(LPRECT lpRect) noexcept override;
int MapPoints(LPPOINT lpPoints, UINT cPoints); int MapPoints(LPPOINT lpPoints, UINT cPoints) noexcept override;
BOOL ConvertScreenToClient(LPPOINT lpPoint); BOOL ConvertScreenToClient(LPPOINT lpPoint) noexcept override;
BOOL SendNotifyBeep() const; BOOL SendNotifyBeep() const noexcept override;
BOOL PostUpdateScrollBars() const; BOOL PostUpdateScrollBars() const noexcept override;
BOOL PostUpdateTitleWithCopy(const PCWSTR pwszNewTitle) const; BOOL PostUpdateWindowSize() const noexcept override;
BOOL PostUpdateWindowSize() const;
void UpdateWindowSize(const COORD coordSizeInChars); void UpdateWindowSize(const COORD coordSizeInChars) noexcept override;
void UpdateWindowText(); void UpdateWindowText() noexcept override;
void HorizontalScroll(const WORD wScrollCommand, const WORD wAbsoluteChange); void HorizontalScroll(const WORD wScrollCommand, const WORD wAbsoluteChange) noexcept override;
void VerticalScroll(const WORD wScrollCommand, const WORD wAbsoluteChange); void VerticalScroll(const WORD wScrollCommand, const WORD wAbsoluteChange) noexcept override;
[[nodiscard]] HRESULT SignalUia(_In_ EVENTID id); [[nodiscard]] HRESULT SignalUia(_In_ EVENTID id) noexcept override;
[[nodiscard]] HRESULT UiaSetTextAreaFocus(); [[nodiscard]] HRESULT UiaSetTextAreaFocus() noexcept override;
RECT GetWindowRect() const noexcept; RECT GetWindowRect() const noexcept override;
}; };
} }

View File

@ -7,17 +7,17 @@
using namespace Microsoft::Console::Interactivity::OneCore; using namespace Microsoft::Console::Interactivity::OneCore;
UINT SystemConfigurationProvider::GetCaretBlinkTime() UINT SystemConfigurationProvider::GetCaretBlinkTime() noexcept
{ {
return s_DefaultCaretBlinkTime; return s_DefaultCaretBlinkTime;
} }
bool SystemConfigurationProvider::IsCaretBlinkingEnabled() bool SystemConfigurationProvider::IsCaretBlinkingEnabled() noexcept
{ {
return s_DefaultIsCaretBlinkingEnabled; return s_DefaultIsCaretBlinkingEnabled;
} }
int SystemConfigurationProvider::GetNumberOfMouseButtons() int SystemConfigurationProvider::GetNumberOfMouseButtons() noexcept
{ {
if (IsGetSystemMetricsPresent()) if (IsGetSystemMetricsPresent())
{ {
@ -29,17 +29,17 @@ int SystemConfigurationProvider::GetNumberOfMouseButtons()
} }
} }
ULONG SystemConfigurationProvider::GetCursorWidth() ULONG SystemConfigurationProvider::GetCursorWidth() noexcept
{ {
return s_DefaultCursorWidth; return s_DefaultCursorWidth;
} }
ULONG SystemConfigurationProvider::GetNumberOfWheelScrollLines() ULONG SystemConfigurationProvider::GetNumberOfWheelScrollLines() noexcept
{ {
return s_DefaultNumberOfWheelScrollLines; return s_DefaultNumberOfWheelScrollLines;
} }
ULONG SystemConfigurationProvider::GetNumberOfWheelScrollCharacters() ULONG SystemConfigurationProvider::GetNumberOfWheelScrollCharacters() noexcept
{ {
return s_DefaultNumberOfWheelScrollCharacters; return s_DefaultNumberOfWheelScrollCharacters;
} }

View File

@ -22,30 +22,30 @@ class InputTests;
namespace Microsoft::Console::Interactivity::OneCore namespace Microsoft::Console::Interactivity::OneCore
{ {
class SystemConfigurationProvider sealed : public ISystemConfigurationProvider class SystemConfigurationProvider : public ISystemConfigurationProvider
{ {
public: public:
bool IsCaretBlinkingEnabled(); bool IsCaretBlinkingEnabled() noexcept override;
UINT GetCaretBlinkTime(); UINT GetCaretBlinkTime() noexcept override;
int GetNumberOfMouseButtons(); int GetNumberOfMouseButtons() noexcept override;
ULONG GetCursorWidth() override; ULONG GetCursorWidth() noexcept override;
ULONG GetNumberOfWheelScrollLines(); ULONG GetNumberOfWheelScrollLines() noexcept override;
ULONG GetNumberOfWheelScrollCharacters(); ULONG GetNumberOfWheelScrollCharacters() noexcept override;
void GetSettingsFromLink(_Inout_ Settings* pLinkSettings, void GetSettingsFromLink(_Inout_ Settings* pLinkSettings,
_Inout_updates_bytes_(*pdwTitleLength) LPWSTR pwszTitle, _Inout_updates_bytes_(*pdwTitleLength) LPWSTR pwszTitle,
_Inout_ PDWORD pdwTitleLength, _Inout_ PDWORD pdwTitleLength,
_In_ PCWSTR pwszCurrDir, _In_ PCWSTR pwszCurrDir,
_In_ PCWSTR pwszAppName); _In_ PCWSTR pwszAppName) override;
private: private:
static const UINT s_DefaultCaretBlinkTime = 530; // milliseconds static constexpr UINT s_DefaultCaretBlinkTime = 530; // milliseconds
static const bool s_DefaultIsCaretBlinkingEnabled = true; static constexpr bool s_DefaultIsCaretBlinkingEnabled = true;
static const int s_DefaultNumberOfMouseButtons = 3; static constexpr int s_DefaultNumberOfMouseButtons = 3;
static const ULONG s_DefaultCursorWidth = 1; static constexpr ULONG s_DefaultCursorWidth = 1;
static const ULONG s_DefaultNumberOfWheelScrollLines = 3; static constexpr ULONG s_DefaultNumberOfWheelScrollLines = 3;
static const ULONG s_DefaultNumberOfWheelScrollCharacters = 3; static constexpr ULONG s_DefaultNumberOfWheelScrollCharacters = 3;
friend class ::InputTests; friend class ::InputTests;
}; };

View File

@ -6,7 +6,7 @@
#include "WindowMetrics.hpp" #include "WindowMetrics.hpp"
#include "ConIoSrvComm.hpp" #include "ConIoSrvComm.hpp"
#include "../../renderer/wddmcon/wddmconrenderer.hpp" #include "../../renderer/wddmcon/WddmConRenderer.hpp"
#include "../inc/ServiceLocator.hpp" #include "../inc/ServiceLocator.hpp"
@ -22,34 +22,28 @@ using namespace Microsoft::Console::Interactivity::OneCore;
RECT WindowMetrics::GetMinClientRectInPixels() RECT WindowMetrics::GetMinClientRectInPixels()
{ {
ConIoSrvComm* Server;
NTSTATUS Status;
// We need to always return something viable for this call, // We need to always return something viable for this call,
// so by default, set the font and display size to our headless // so by default, set the font and display size to our headless
// constants. // constants.
// If we get information from the Server, great. We'll calculate // If we get information from the Server, great. We'll calculate
// the values for that at the end. // the values for that at the end.
// If we don't... then at least we have a non-zero rectangle. // If we don't... then at least we have a non-zero rectangle.
COORD FontSize = { 0 }; COORD FontSize{};
FontSize.X = HEADLESS_FONT_SIZE_WIDTH; FontSize.X = HEADLESS_FONT_SIZE_WIDTH;
FontSize.Y = HEADLESS_FONT_SIZE_HEIGHT; FontSize.Y = HEADLESS_FONT_SIZE_HEIGHT;
RECT DisplaySize = { 0 }; RECT DisplaySize{};
DisplaySize.right = HEADLESS_DISPLAY_SIZE_WIDTH; DisplaySize.right = HEADLESS_DISPLAY_SIZE_WIDTH;
DisplaySize.bottom = HEADLESS_DISPLAY_SIZE_HEIGHT; DisplaySize.bottom = HEADLESS_DISPLAY_SIZE_HEIGHT;
CD_IO_FONT_SIZE FontSizeIoctl = { 0 }; CD_IO_FONT_SIZE FontSizeIoctl{};
CD_IO_DISPLAY_SIZE DisplaySizeIoctl = { 0 }; CD_IO_DISPLAY_SIZE DisplaySizeIoctl{};
USHORT DisplayMode;
// Fetch a reference to the Console IO Server. // Fetch a reference to the Console IO Server.
Server = ConIoSrvComm::GetConIoSrvComm(); const auto Server = ConIoSrvComm::GetConIoSrvComm();
// Figure out what kind of display we are using. // Figure out what kind of display we are using.
DisplayMode = Server->GetDisplayMode(); const auto DisplayMode = Server->GetDisplayMode();
// Note on status propagation: // Note on status propagation:
// //
@ -71,7 +65,7 @@ RECT WindowMetrics::GetMinClientRectInPixels()
// might be a problem for plugging/unplugging monitors or perhaps // might be a problem for plugging/unplugging monitors or perhaps
// across KVM sessions. // across KVM sessions.
Status = Server->RequestGetDisplaySize(&DisplaySizeIoctl); auto Status = Server->RequestGetDisplaySize(&DisplaySizeIoctl);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -81,34 +75,34 @@ RECT WindowMetrics::GetMinClientRectInPixels()
{ {
DisplaySize.top = 0; DisplaySize.top = 0;
DisplaySize.left = 0; DisplaySize.left = 0;
DisplaySize.bottom = DisplaySizeIoctl.Height; DisplaySize.bottom = gsl::narrow_cast<LONG>(DisplaySizeIoctl.Height);
DisplaySize.right = DisplaySizeIoctl.Width; DisplaySize.right = gsl::narrow_cast<LONG>(DisplaySizeIoctl.Width);
FontSize.X = (SHORT)FontSizeIoctl.Width; FontSize.X = gsl::narrow_cast<SHORT>(FontSizeIoctl.Width);
FontSize.Y = (SHORT)FontSizeIoctl.Height; FontSize.Y = gsl::narrow_cast<SHORT>(FontSizeIoctl.Height);
} }
} }
else else
{ {
SetLastError(Status); SetLastError(Status);
} }
break;
} }
break;
case CIS_DISPLAY_MODE_DIRECTX: case CIS_DISPLAY_MODE_DIRECTX:
{ {
LOG_IF_FAILED(Server->pWddmConEngine->GetFontSize(&FontSize)); LOG_IF_FAILED(Server->pWddmConEngine->GetFontSize(&FontSize));
DisplaySize = Server->pWddmConEngine->GetDisplaySize(); DisplaySize = Server->pWddmConEngine->GetDisplaySize();
break;
} }
break;
case CIS_DISPLAY_MODE_NONE: case CIS_DISPLAY_MODE_NONE:
{ {
// When in headless mode and using EMS (Emergency Management // When in headless mode and using EMS (Emergency Management
// Services), ensure that the buffer isn't zero-sized by // Services), ensure that the buffer isn't zero-sized by
// using the default values. // using the default values.
break;
} }
break; default:
break;
} }
// The result is expected to be in pixels, not rows/columns. // The result is expected to be in pixels, not rows/columns.

View File

@ -20,10 +20,10 @@ Author(s):
namespace Microsoft::Console::Interactivity::OneCore namespace Microsoft::Console::Interactivity::OneCore
{ {
class WindowMetrics sealed : public IWindowMetrics class WindowMetrics : public IWindowMetrics
{ {
public: public:
RECT GetMinClientRectInPixels(); RECT GetMinClientRectInPixels() override;
RECT GetMaxClientRectInPixels(); RECT GetMaxClientRectInPixels() override;
}; };
} }

View File

@ -6,17 +6,28 @@
<RootNamespace>OneCore</RootNamespace> <RootNamespace>OneCore</RootNamespace>
<ProjectName>InteractivityOneCore</ProjectName> <ProjectName>InteractivityOneCore</ProjectName>
<TargetName>ConInteractivityOneCoreLib</TargetName> <TargetName>ConInteractivityOneCoreLib</TargetName>
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup> </PropertyGroup>
<Import Project="$(SolutionDir)src\common.build.pre.props" /> <Import Project="$(SolutionDir)src\common.build.pre.props" />
<Import Project="$(SolutionDir)src\common.nugetversions.props" />
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<!--
C26429: Symbol '...' is never tested for nullness, it can be marked as not_null (f.23).
C26432: If you define or delete any default operation in the type '...', define or delete them all (c.21).
C26462: The value pointed to by '...' is assigned only once, mark it as a pointer to const (con.4).
C26481: Don't use pointer arithmetic. Use span instead (bounds.1).
C26490: Don't use reinterpret_cast (type.1).
C26494: Variable '...' is uninitialized. Always initialize an object (type.5).
-->
<DisableSpecificWarnings>26429;26432;26462;26481;26490;26494;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<PreprocessorDefinitions>IS_INTERACTIVITYBASE_CONSUMER;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>IS_INTERACTIVITYBASE_CONSUMER;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\host\newdelete.cpp" />
<ClCompile Include="..\AccessibilityNotifier.cpp" /> <ClCompile Include="..\AccessibilityNotifier.cpp" />
<ClCompile Include="..\BgfxEngine.cpp" />
<ClCompile Include="..\ConIoSrvComm.cpp" />
<ClCompile Include="..\ConsoleControl.cpp" /> <ClCompile Include="..\ConsoleControl.cpp" />
<ClCompile Include="..\ConsoleInputThread.cpp" /> <ClCompile Include="..\ConsoleInputThread.cpp" />
<ClCompile Include="..\ConsoleWindow.cpp" /> <ClCompile Include="..\ConsoleWindow.cpp" />
@ -27,8 +38,9 @@
<ClCompile Include="..\WindowMetrics.cpp" /> <ClCompile Include="..\WindowMetrics.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\host\newdelete.hpp" />
<ClInclude Include="..\AccessibilityNotifier.hpp" /> <ClInclude Include="..\AccessibilityNotifier.hpp" />
<ClInclude Include="..\BgfxEngine.hpp" />
<ClInclude Include="..\ConIoSrvComm.hpp" />
<ClInclude Include="..\ConsoleControl.hpp" /> <ClInclude Include="..\ConsoleControl.hpp" />
<ClInclude Include="..\ConsoleInputThread.hpp" /> <ClInclude Include="..\ConsoleInputThread.hpp" />
<ClInclude Include="..\ConsoleWindow.hpp" /> <ClInclude Include="..\ConsoleWindow.hpp" />
@ -36,6 +48,12 @@
<ClInclude Include="..\SystemConfigurationProvider.hpp" /> <ClInclude Include="..\SystemConfigurationProvider.hpp" />
<ClInclude Include="..\WindowMetrics.hpp" /> <ClInclude Include="..\WindowMetrics.hpp" />
</ItemGroup> </ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. --> <!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
<Import Project="$(SolutionDir)src\common.build.post.props" /> <Import Project="$(SolutionDir)src\common.build.post.props" />
<Import Project="$(SolutionDir)src\common.nugetversions.targets" />
</Project> </Project>

View File

@ -39,6 +39,12 @@
<ClCompile Include="..\ConsoleWindow.cpp"> <ClCompile Include="..\ConsoleWindow.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\BgfxEngine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ConIoSrvComm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\precomp.h"> <ClInclude Include="..\precomp.h">
@ -65,5 +71,14 @@
<ClInclude Include="..\ConsoleWindow.hpp"> <ClInclude Include="..\ConsoleWindow.hpp">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\BgfxEngine.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ConIoSrvComm.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -3,6 +3,8 @@
#pragma once #pragma once
#ifdef __INSIDE_WINDOWS
#define NOMINMAX #define NOMINMAX
#include <nt.h> #include <nt.h>
@ -16,3 +18,9 @@
#define _DDK_INCLUDED #define _DDK_INCLUDED
#include "../../host/precomp.h" #include "../../host/precomp.h"
#else
#include "../../host/precomp.h"
#endif

View File

@ -84,8 +84,6 @@ public:
PCWSTR pwszValueName; PCWSTR pwszValueName;
DWORD dwFieldOffset; DWORD dwFieldOffset;
size_t cbFieldSize; size_t cbFieldSize;
_RegPropertyMap& operator=(const _RegPropertyMap&) { return *this; }
} RegPropertyMap; } RegPropertyMap;
static const RegPropertyMap s_PropertyMappings[]; static const RegPropertyMap s_PropertyMappings[];

View File

@ -7,12 +7,6 @@
using namespace Microsoft::Console; using namespace Microsoft::Console;
using namespace Microsoft::Console::Render; using namespace Microsoft::Console::Render;
RenderEngineBase::RenderEngineBase() :
_titleChanged(false),
_lastFrameTitle(L"")
{
}
HRESULT RenderEngineBase::InvalidateTitle(const std::wstring_view proposedTitle) noexcept HRESULT RenderEngineBase::InvalidateTitle(const std::wstring_view proposedTitle) noexcept
{ {
if (proposedTitle != _lastFrameTitle) if (proposedTitle != _lastFrameTitle)

View File

@ -23,16 +23,6 @@ namespace Microsoft::Console::Render
{ {
class RenderEngineBase : public IRenderEngine class RenderEngineBase : public IRenderEngine
{ {
public:
~RenderEngineBase() = 0;
protected:
RenderEngineBase();
RenderEngineBase(const RenderEngineBase&) = default;
RenderEngineBase(RenderEngineBase&&) = default;
RenderEngineBase& operator=(const RenderEngineBase&) = default;
RenderEngineBase& operator=(RenderEngineBase&&) = default;
public: public:
[[nodiscard]] HRESULT InvalidateTitle(const std::wstring_view proposedTitle) noexcept override; [[nodiscard]] HRESULT InvalidateTitle(const std::wstring_view proposedTitle) noexcept override;
@ -60,9 +50,7 @@ namespace Microsoft::Console::Render
protected: protected:
[[nodiscard]] virtual HRESULT _DoUpdateTitle(const std::wstring_view newTitle) noexcept = 0; [[nodiscard]] virtual HRESULT _DoUpdateTitle(const std::wstring_view newTitle) noexcept = 0;
bool _titleChanged; bool _titleChanged = false;
std::wstring _lastFrameTitle; std::wstring _lastFrameTitle;
}; };
inline Microsoft::Console::Render::RenderEngineBase::~RenderEngineBase() {}
} }

View File

@ -20,7 +20,7 @@
using namespace Microsoft::Console::Render; using namespace Microsoft::Console::Render;
WddmConEngine::WddmConEngine() : WddmConEngine::WddmConEngine() noexcept :
RenderEngineBase(), RenderEngineBase(),
_hWddmConCtx(INVALID_HANDLE_VALUE), _hWddmConCtx(INVALID_HANDLE_VALUE),
_displayHeight(0), _displayHeight(0),
@ -63,10 +63,11 @@ void WddmConEngine::FreeResources(ULONG displayHeight)
WddmConEngine::~WddmConEngine() WddmConEngine::~WddmConEngine()
{ {
#pragma warning(suppress : 26447)
FreeResources(_displayHeight); FreeResources(_displayHeight);
} }
[[nodiscard]] HRESULT WddmConEngine::Initialize() noexcept [[nodiscard]] HRESULT WddmConEngine::Initialize()
{ {
HRESULT hr; HRESULT hr;
RECT DisplaySize; RECT DisplaySize;
@ -84,16 +85,16 @@ WddmConEngine::~WddmConEngine()
{ {
DisplaySize.top = 0; DisplaySize.top = 0;
DisplaySize.left = 0; DisplaySize.left = 0;
DisplaySize.bottom = (LONG)DisplaySizeIoctl.Height; DisplaySize.bottom = gsl::narrow_cast<LONG>(DisplaySizeIoctl.Height);
DisplaySize.right = (LONG)DisplaySizeIoctl.Width; DisplaySize.right = gsl::narrow_cast<LONG>(DisplaySizeIoctl.Width);
_displayState = (PCD_IO_ROW_INFORMATION*)calloc(DisplaySize.bottom, sizeof(PCD_IO_ROW_INFORMATION)); _displayState = static_cast<PCD_IO_ROW_INFORMATION*>(calloc(DisplaySize.bottom, sizeof(PCD_IO_ROW_INFORMATION)));
if (_displayState != nullptr) if (_displayState != nullptr)
{ {
for (LONG i = 0; i < DisplaySize.bottom; i++) for (LONG i = 0; i < DisplaySize.bottom; i++)
{ {
_displayState[i] = (PCD_IO_ROW_INFORMATION)calloc(1, sizeof(CD_IO_ROW_INFORMATION)); _displayState[i] = static_cast<PCD_IO_ROW_INFORMATION>(calloc(1, sizeof(CD_IO_ROW_INFORMATION)));
if (_displayState[i] == nullptr) if (_displayState[i] == nullptr)
{ {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
@ -101,9 +102,9 @@ WddmConEngine::~WddmConEngine()
break; break;
} }
_displayState[i]->Index = (SHORT)i; _displayState[i]->Index = gsl::narrow_cast<SHORT>(i);
_displayState[i]->Old = (PCD_IO_CHARACTER)calloc(DisplaySize.right, sizeof(CD_IO_CHARACTER)); _displayState[i]->Old = static_cast<PCD_IO_CHARACTER>(calloc(DisplaySize.right, sizeof(CD_IO_CHARACTER)));
_displayState[i]->New = (PCD_IO_CHARACTER)calloc(DisplaySize.right, sizeof(CD_IO_CHARACTER)); _displayState[i]->New = static_cast<PCD_IO_CHARACTER>(calloc(DisplaySize.right, sizeof(CD_IO_CHARACTER)));
if (_displayState[i]->Old == nullptr || _displayState[i]->New == nullptr) if (_displayState[i]->Old == nullptr || _displayState[i]->New == nullptr)
{ {
@ -144,22 +145,26 @@ WddmConEngine::~WddmConEngine()
return hr; return hr;
} }
bool WddmConEngine::IsInitialized() bool WddmConEngine::IsInitialized() noexcept
{ {
return _hWddmConCtx != INVALID_HANDLE_VALUE; return _hWddmConCtx != INVALID_HANDLE_VALUE;
} }
[[nodiscard]] HRESULT WddmConEngine::Enable() noexcept [[nodiscard]] HRESULT WddmConEngine::Enable() noexcept
try
{ {
RETURN_IF_HANDLE_INVALID(_hWddmConCtx); RETURN_LAST_ERROR_IF(_hWddmConCtx == INVALID_HANDLE_VALUE);
return WDDMConEnableDisplayAccess((PHANDLE)_hWddmConCtx, TRUE); return WDDMConEnableDisplayAccess(_hWddmConCtx, TRUE);
} }
CATCH_RETURN()
[[nodiscard]] HRESULT WddmConEngine::Disable() noexcept [[nodiscard]] HRESULT WddmConEngine::Disable() noexcept
try
{ {
RETURN_IF_HANDLE_INVALID(_hWddmConCtx); RETURN_LAST_ERROR_IF(_hWddmConCtx == INVALID_HANDLE_VALUE);
return WDDMConEnableDisplayAccess((PHANDLE)_hWddmConCtx, FALSE); return WDDMConEnableDisplayAccess(_hWddmConCtx, FALSE);
} }
CATCH_RETURN()
[[nodiscard]] HRESULT WddmConEngine::Invalidate(const SMALL_RECT* const /*psrRegion*/) noexcept [[nodiscard]] HRESULT WddmConEngine::Invalidate(const SMALL_RECT* const /*psrRegion*/) noexcept
{ {
@ -198,16 +203,20 @@ bool WddmConEngine::IsInitialized()
} }
[[nodiscard]] HRESULT WddmConEngine::StartPaint() noexcept [[nodiscard]] HRESULT WddmConEngine::StartPaint() noexcept
try
{ {
RETURN_IF_HANDLE_INVALID(_hWddmConCtx); RETURN_LAST_ERROR_IF(_hWddmConCtx == INVALID_HANDLE_VALUE);
return WDDMConBeginUpdateDisplayBatch(_hWddmConCtx); return WDDMConBeginUpdateDisplayBatch(_hWddmConCtx);
} }
CATCH_RETURN()
[[nodiscard]] HRESULT WddmConEngine::EndPaint() noexcept [[nodiscard]] HRESULT WddmConEngine::EndPaint() noexcept
try
{ {
RETURN_IF_HANDLE_INVALID(_hWddmConCtx); RETURN_LAST_ERROR_IF(_hWddmConCtx == INVALID_HANDLE_VALUE);
return WDDMConEndUpdateDisplayBatch(_hWddmConCtx); return WDDMConEndUpdateDisplayBatch(_hWddmConCtx);
} }
CATCH_RETURN()
// Routine Description: // Routine Description:
// - Used to perform longer running presentation steps outside the lock so the other threads can continue. // - Used to perform longer running presentation steps outside the lock so the other threads can continue.
@ -229,17 +238,14 @@ bool WddmConEngine::IsInitialized()
[[nodiscard]] HRESULT WddmConEngine::PaintBackground() noexcept [[nodiscard]] HRESULT WddmConEngine::PaintBackground() noexcept
{ {
RETURN_IF_HANDLE_INVALID(_hWddmConCtx); RETURN_LAST_ERROR_IF(_hWddmConCtx == INVALID_HANDLE_VALUE);
PCD_IO_CHARACTER OldChar;
PCD_IO_CHARACTER NewChar;
for (LONG rowIndex = 0; rowIndex < _displayHeight; rowIndex++) for (LONG rowIndex = 0; rowIndex < _displayHeight; rowIndex++)
{ {
for (LONG colIndex = 0; colIndex < _displayWidth; colIndex++) for (LONG colIndex = 0; colIndex < _displayWidth; colIndex++)
{ {
OldChar = &_displayState[rowIndex]->Old[colIndex]; const auto OldChar = &_displayState[rowIndex]->Old[colIndex];
NewChar = &_displayState[rowIndex]->New[colIndex]; const auto NewChar = &_displayState[rowIndex]->New[colIndex];
OldChar->Character = NewChar->Character; OldChar->Character = NewChar->Character;
OldChar->Attribute = NewChar->Attribute; OldChar->Attribute = NewChar->Attribute;
@ -259,15 +265,12 @@ bool WddmConEngine::IsInitialized()
{ {
try try
{ {
RETURN_IF_HANDLE_INVALID(_hWddmConCtx); RETURN_LAST_ERROR_IF(_hWddmConCtx == INVALID_HANDLE_VALUE);
PCD_IO_CHARACTER OldChar; for (size_t i = 0; i < clusters.size() && i < gsl::narrow_cast<size_t>(_displayWidth); i++)
PCD_IO_CHARACTER NewChar;
for (size_t i = 0; i < clusters.size() && i < (size_t)_displayWidth; i++)
{ {
OldChar = &_displayState[coord.Y]->Old[coord.X + i]; const auto OldChar = &_displayState[coord.Y]->Old[coord.X + i];
NewChar = &_displayState[coord.Y]->New[coord.X + i]; const auto NewChar = &_displayState[coord.Y]->New[coord.X + i];
OldChar->Character = NewChar->Character; OldChar->Character = NewChar->Character;
OldChar->Attribute = NewChar->Attribute; OldChar->Attribute = NewChar->Attribute;
@ -337,6 +340,7 @@ bool WddmConEngine::IsInitialized()
const int /*iDpi*/) noexcept const int /*iDpi*/) noexcept
{ {
COORD coordSize = { 0 }; COORD coordSize = { 0 };
#pragma warning(suppress : 26447)
LOG_IF_FAILED(GetFontSize(&coordSize)); LOG_IF_FAILED(GetFontSize(&coordSize));
fiFontInfo.SetFromEngine(fiFontInfo.GetFaceName(), fiFontInfo.SetFromEngine(fiFontInfo.GetFaceName(),
@ -360,7 +364,7 @@ bool WddmConEngine::IsInitialized()
return S_OK; return S_OK;
} }
RECT WddmConEngine::GetDisplaySize() RECT WddmConEngine::GetDisplaySize() noexcept
{ {
RECT r; RECT r;
r.top = 0; r.top = 0;

View File

@ -10,11 +10,11 @@ namespace Microsoft::Console::Render
class WddmConEngine final : public RenderEngineBase class WddmConEngine final : public RenderEngineBase
{ {
public: public:
WddmConEngine(); WddmConEngine() noexcept;
~WddmConEngine() override; ~WddmConEngine() override;
[[nodiscard]] HRESULT Initialize() noexcept; [[nodiscard]] HRESULT Initialize();
bool IsInitialized(); bool IsInitialized() noexcept;
// Used to release device resources so that another instance of // Used to release device resources so that another instance of
// conhost can render to the screen (i.e. only one DirectX // conhost can render to the screen (i.e. only one DirectX
@ -22,7 +22,7 @@ namespace Microsoft::Console::Render
[[nodiscard]] HRESULT Enable() noexcept override; [[nodiscard]] HRESULT Enable() noexcept override;
[[nodiscard]] HRESULT Disable() noexcept; [[nodiscard]] HRESULT Disable() noexcept;
RECT GetDisplaySize(); RECT GetDisplaySize() noexcept;
// IRenderEngine Members // IRenderEngine Members
[[nodiscard]] HRESULT Invalidate(const SMALL_RECT* const psrRegion) noexcept override; [[nodiscard]] HRESULT Invalidate(const SMALL_RECT* const psrRegion) noexcept override;

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{75C6F576-18E9-4566-978A-F0A301CAC090}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>wddmcon</RootNamespace>
<ProjectName>RendererWddmCon</ProjectName>
<TargetName>ConRenderWddmCon</TargetName>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(SolutionDir)src\common.build.pre.props" />
<Import Project="$(SolutionDir)src\common.nugetversions.props" />
<ItemDefinitionGroup>
<ClCompile>
<!--
C6001: Using uninitialized memory '...'.
C26408: Avoid malloc() and free(), prefer the nothrow version of new with delete (r.10).
C26429: Symbol '...' is never tested for nullness, it can be marked as not_null (f.23).
C26430: Symbol '...' is not tested for nullness on all paths (f.23).
C26432: If you define or delete any default operation in the type '...', define or delete them all (c.21).
C26446: Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4).
C26481: Don't use pointer arithmetic. Use span instead (bounds.1).
C26482: Only index into arrays using constant expressions (bounds.2).
C26490: Don't use reinterpret_cast (type.1).
C26494: Variable '...' is uninitialized. Always initialize an object (type.5).
-->
<DisableSpecificWarnings>6001;26408;26429;26430;26432;26446;26481;26482;26490;26494;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<PreprocessorDefinitions>IS_INTERACTIVITYBASE_CONSUMER;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\main.cxx" />
<ClCompile Include="..\precomp.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\WddmConRenderer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\main.h" />
<ClInclude Include="..\precomp.h" />
<ClInclude Include="..\WddmConRenderer.hpp" />
</ItemGroup>
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
<Import Project="$(SolutionDir)src\common.build.post.props" />
<Import Project="$(SolutionDir)src\common.nugetversions.targets" />
</Project>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\precomp.cpp" />
<ClCompile Include="..\WddmConRenderer.cpp" />
<ClCompile Include="..\main.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\precomp.h" />
<ClInclude Include="..\WddmConRenderer.hpp" />
<ClInclude Include="..\main.h" />
</ItemGroup>
</Project>

View File

@ -16,7 +16,7 @@ HINSTANCE g_hInstance;
#define REGSTR_VALUE_DISPLAY_INIT_DELAY L"DisplayInitDelay" #define REGSTR_VALUE_DISPLAY_INIT_DELAY L"DisplayInitDelay"
#define REGSTR_VALUE_FONT_SIZE L"FontSize" #define REGSTR_VALUE_FONT_SIZE L"FontSize"
#define SafeRelease(p) if (p) { (p)->Release(); (p) = NULL;} #define SafeRelease(p) if (p) { (p)->Release(); (p) = nullptr;}
typedef struct tagWDDMCONSOLECONTEXT { typedef struct tagWDDMCONSOLECONTEXT {
// Console state // Console state
@ -73,7 +73,7 @@ ReleaseDeviceResources(
{ {
// To ensure the swap chain goes away we must unbind any views from the // To ensure the swap chain goes away we must unbind any views from the
// D3D pipeline // D3D pipeline
pCtx->pD3DDeviceContext->OMSetRenderTargets(0, NULL, NULL); pCtx->pD3DDeviceContext->OMSetRenderTargets(0, nullptr, nullptr);
} }
SafeRelease(pCtx->pD3DDeviceContext); SafeRelease(pCtx->pD3DDeviceContext);
@ -90,31 +90,31 @@ WDDMConDestroy(
_In_ HANDLE hDisplay _In_ HANDLE hDisplay
) )
{ {
if (hDisplay != NULL) { if (hDisplay != nullptr) {
PWDDMCONSOLECONTEXT pCtx = (PWDDMCONSOLECONTEXT)hDisplay; const auto pCtx = static_cast<PWDDMCONSOLECONTEXT>(hDisplay);
ReleaseDeviceResources(pCtx); ReleaseDeviceResources(pCtx);
SafeRelease(pCtx->pDWriteTextFormat); SafeRelease(pCtx->pDWriteTextFormat);
SafeRelease(pCtx->pDWriteFactory); SafeRelease(pCtx->pDWriteFactory);
SafeRelease(pCtx->pD2DFactory); SafeRelease(pCtx->pD2DFactory);
RtlFreeHeap(RtlProcessHeap(), 0, (PVOID)pCtx->pwszGlyphRunAccel); free(pCtx->pwszGlyphRunAccel);
RtlFreeHeap(RtlProcessHeap(), 0, (PVOID)pCtx); free(pCtx);
} }
} }
HRESULT HRESULT
ReadSettings( ReadSettings(
_Inout_ PWDDMCONSOLECONTEXT pCtx _Inout_ PWDDMCONSOLECONTEXT pCtx
) ) noexcept
{ {
auto hr = S_OK; auto hr = S_OK;
DWORD Error = ERROR_SUCCESS; DWORD Error = ERROR_SUCCESS;
HKEY hKey = NULL; HKEY hKey = nullptr;
DWORD ValueType = REG_NONE; auto ValueType = REG_NONE;
DWORD ValueSize = 0; DWORD ValueSize = 0;
DWORD ValueData = 0; DWORD ValueData = 0;
if (pCtx == NULL) { if (pCtx == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} }
@ -135,9 +135,9 @@ ReadSettings(
Error = RegQueryValueEx(hKey, Error = RegQueryValueEx(hKey,
REGSTR_VALUE_DISPLAY_INIT_DELAY, REGSTR_VALUE_DISPLAY_INIT_DELAY,
NULL, nullptr,
&ValueType, &ValueType,
(PBYTE)&ValueData, reinterpret_cast<PBYTE>(&ValueData),
&ValueSize); &ValueSize);
if ((Error == ERROR_SUCCESS) && if ((Error == ERROR_SUCCESS) &&
@ -150,20 +150,20 @@ ReadSettings(
Error = RegQueryValueEx(hKey, Error = RegQueryValueEx(hKey,
REGSTR_VALUE_FONT_SIZE, REGSTR_VALUE_FONT_SIZE,
NULL, nullptr,
&ValueType, &ValueType,
(PBYTE)&ValueData, reinterpret_cast<PBYTE>(&ValueData),
&ValueSize); &ValueSize);
if ((Error == ERROR_SUCCESS) && if ((Error == ERROR_SUCCESS) &&
(ValueType == REG_DWORD) && (ValueType == REG_DWORD) &&
(ValueSize == sizeof(ValueData)) && (ValueSize == sizeof(ValueData)) &&
(ValueData > 0)) { (ValueData > 0)) {
pCtx->FontSize = (float)ValueData; pCtx->FontSize = static_cast<float>(ValueData);
} }
} }
if (hKey != NULL) { if (hKey != nullptr) {
RegCloseKey(hKey); RegCloseKey(hKey);
} }
@ -173,23 +173,23 @@ ReadSettings(
HRESULT HRESULT
CreateTextLayout( CreateTextLayout(
_In_ PWDDMCONSOLECONTEXT pCtx, _In_ PWDDMCONSOLECONTEXT pCtx,
_In_reads_(StringLength) WCHAR *String, _In_reads_(StringLength) const wchar_t *String,
_In_ size_t StringLength, _In_ size_t StringLength,
_Out_ IDWriteTextLayout **ppTextLayout _Out_ IDWriteTextLayout **ppTextLayout
) ) noexcept
{ {
auto hr = S_OK; auto hr = S_OK;
if (pCtx == NULL) { if (pCtx == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = pCtx->pDWriteFactory->CreateTextLayout(String, hr = pCtx->pDWriteFactory->CreateTextLayout(String,
static_cast<UINT32>(StringLength), gsl::narrow_cast<UINT32>(StringLength),
pCtx->pDWriteTextFormat, pCtx->pDWriteTextFormat,
(float)pCtx->DisplayMode.Width, static_cast<float>(pCtx->DisplayMode.Width),
pCtx->LineHeight != 0 ? pCtx->LineHeight : (float)pCtx->DisplayMode.Height, pCtx->LineHeight != 0 ? pCtx->LineHeight : static_cast<float>(pCtx->DisplayMode.Height),
ppTextLayout); ppTextLayout);
} }
@ -250,7 +250,7 @@ CreateDeviceResources(
ReleaseDeviceResources(pCtx); ReleaseDeviceResources(pCtx);
} }
HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&pCtx->pDXGIFactory2)); auto hr = CreateDXGIFactory1(IID_PPV_ARGS(&pCtx->pDXGIFactory2));
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = pCtx->pDXGIFactory2->QueryInterface(IID_PPV_ARGS(&pCtx->pDXGIFactoryDWM)); hr = pCtx->pDXGIFactory2->QueryInterface(IID_PPV_ARGS(&pCtx->pDXGIFactoryDWM));
@ -261,10 +261,10 @@ CreateDeviceResources(
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
DWORD DeviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT | const DWORD DeviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT |
D3D11_CREATE_DEVICE_SINGLETHREADED; D3D11_CREATE_DEVICE_SINGLETHREADED;
D3D_FEATURE_LEVEL FeatureLevels[] = { static constexpr D3D_FEATURE_LEVEL FeatureLevels[] = {
D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_1,
@ -274,13 +274,13 @@ CreateDeviceResources(
hr = D3D11CreateDevice(pCtx->pDXGIAdapter1, hr = D3D11CreateDevice(pCtx->pDXGIAdapter1,
D3D_DRIVER_TYPE_UNKNOWN, D3D_DRIVER_TYPE_UNKNOWN,
NULL, nullptr,
DeviceFlags, DeviceFlags,
FeatureLevels, &FeatureLevels[0],
ARRAYSIZE(FeatureLevels), ARRAYSIZE(FeatureLevels),
D3D11_SDK_VERSION, D3D11_SDK_VERSION,
&pCtx->pD3DDevice, &pCtx->pD3DDevice,
NULL, nullptr,
&pCtx->pD3DDeviceContext); &pCtx->pD3DDeviceContext);
} }
@ -289,7 +289,7 @@ CreateDeviceResources(
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
DXGI_MODE_DESC currentmode = {0}; const DXGI_MODE_DESC currentmode = {0};
hr = pCtx->pDXGIOutput->FindClosestMatchingMode(&currentmode, hr = pCtx->pDXGIOutput->FindClosestMatchingMode(&currentmode,
&pCtx->DisplayMode, &pCtx->DisplayMode,
pCtx->pD3DDevice); pCtx->pD3DDevice);
@ -298,8 +298,8 @@ CreateDeviceResources(
if (fCreateSwapChain) { if (fCreateSwapChain) {
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
D3D11_VIEWPORT viewport; D3D11_VIEWPORT viewport;
viewport.Width = (FLOAT)pCtx->DisplayMode.Width; viewport.Width = static_cast<FLOAT>(pCtx->DisplayMode.Width);
viewport.Height = (FLOAT)pCtx->DisplayMode.Height; viewport.Height = static_cast<FLOAT>(pCtx->DisplayMode.Height);
viewport.TopLeftX = 0; viewport.TopLeftX = 0;
viewport.TopLeftY = 0; viewport.TopLeftY = 0;
viewport.MinDepth = 0; viewport.MinDepth = 0;
@ -309,7 +309,7 @@ CreateDeviceResources(
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
DXGI_SWAP_CHAIN_DESC SwapChainDesc = { 0 }; DXGI_SWAP_CHAIN_DESC SwapChainDesc = { 0 };
DXGI_SAMPLE_DESC LocalSampleDesc = { 1, 0 }; const DXGI_SAMPLE_DESC LocalSampleDesc = { 1, 0 };
SwapChainDesc.BufferDesc.Width = 0; SwapChainDesc.BufferDesc.Width = 0;
SwapChainDesc.BufferDesc.Height = 0; SwapChainDesc.BufferDesc.Height = 0;
@ -322,7 +322,7 @@ CreateDeviceResources(
SwapChainDesc.SampleDesc = LocalSampleDesc; SwapChainDesc.SampleDesc = LocalSampleDesc;
SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER; SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER;
SwapChainDesc.BufferCount = 2; SwapChainDesc.BufferCount = 2;
SwapChainDesc.OutputWindow = NULL; SwapChainDesc.OutputWindow = nullptr;
SwapChainDesc.Windowed = FALSE; SwapChainDesc.Windowed = FALSE;
SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL;
SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_NONPREROTATED; SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_NONPREROTATED;
@ -338,8 +338,7 @@ CreateDeviceResources(
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
const auto props =
D2D1_RENDER_TARGET_PROPERTIES props =
D2D1::RenderTargetProperties( D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED), D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
@ -376,14 +375,11 @@ WDDMConCreate(
) )
{ {
auto hr = S_OK; auto hr = S_OK;
IDWriteTextLayout *pTextLayout = NULL; IDWriteTextLayout *pTextLayout = nullptr;
DWRITE_TEXT_METRICS TextMetrics = {}; DWRITE_TEXT_METRICS TextMetrics = {};
PWDDMCONSOLECONTEXT pCtx = const auto pCtx = static_cast<PWDDMCONSOLECONTEXT>(malloc(sizeof(WDDMCONSOLECONTEXT)));
(PWDDMCONSOLECONTEXT)RtlAllocateHeap(RtlProcessHeap(),
0,
sizeof(WDDMCONSOLECONTEXT));
if (pCtx == NULL) { if (pCtx == nullptr) {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
} else { } else {
RtlZeroMemory(pCtx, sizeof(WDDMCONSOLECONTEXT)); RtlZeroMemory(pCtx, sizeof(WDDMCONSOLECONTEXT));
@ -411,7 +407,7 @@ WDDMConCreate(
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = pCtx->pDWriteFactory->CreateTextFormat(FONT_FACE, hr = pCtx->pDWriteFactory->CreateTextFormat(FONT_FACE,
NULL, nullptr,
DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
@ -448,21 +444,20 @@ WDDMConCreate(
#pragma warning(disable : 4996) // GetDesktopDpi is deprecated. #pragma warning(disable : 4996) // GetDesktopDpi is deprecated.
pCtx->pD2DFactory->GetDesktopDpi(&pCtx->DpiX, &pCtx->DpiY); pCtx->pD2DFactory->GetDesktopDpi(&pCtx->DpiX, &pCtx->DpiY);
#pragma warning(pop) #pragma warning(pop)
float MaxWidth = pTextLayout->GetMaxWidth(); const auto MaxWidth = pTextLayout->GetMaxWidth();
float MaxHeight = pTextLayout->GetMaxHeight(); const auto MaxHeight = pTextLayout->GetMaxHeight();
pCtx->GlyphWidth = (float)(ULONG)(pCtx->GlyphWidth); pCtx->GlyphWidth = floor(pCtx->GlyphWidth);
pCtx->LineHeight = (float)(ULONG)(pCtx->LineHeight); pCtx->LineHeight = floor(pCtx->LineHeight);
pCtx->DisplaySize.Width = (ULONG)(MaxWidth / pCtx->GlyphWidth); pCtx->DisplaySize.Width = static_cast<ULONG>(MaxWidth / pCtx->GlyphWidth);
pCtx->DisplaySize.Height = (ULONG)(MaxHeight / pCtx->LineHeight) + 1; pCtx->DisplaySize.Height = static_cast<ULONG>(MaxHeight / pCtx->LineHeight) + 1;
pCtx->DisplaySize.Width -= CONSOLE_MARGIN * 2; pCtx->DisplaySize.Width -= CONSOLE_MARGIN * 2;
pCtx->DisplaySize.Height -= CONSOLE_MARGIN * 2; pCtx->DisplaySize.Height -= CONSOLE_MARGIN * 2;
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
pCtx->pwszGlyphRunAccel = (WCHAR*)RtlAllocateHeap(RtlProcessHeap(), const size_t width = pCtx->DisplaySize.Width;
0, pCtx->pwszGlyphRunAccel = static_cast<WCHAR*>(malloc(sizeof(WCHAR) * (width + 1)));
sizeof(WCHAR) * (pCtx->DisplaySize.Width + 1)); if (pCtx->pwszGlyphRunAccel == nullptr) {
if (pCtx->pwszGlyphRunAccel == NULL) {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
} }
} }
@ -470,8 +465,8 @@ WDDMConCreate(
SafeRelease(pTextLayout); SafeRelease(pTextLayout);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
*phDisplay = (HANDLE)pCtx; *phDisplay = pCtx;
} else if (pCtx != NULL) { } else if (pCtx != nullptr) {
WDDMConDestroy(pCtx); WDDMConDestroy(pCtx);
} }
@ -502,12 +497,12 @@ WDDMConBeginUpdateDisplayBatch(
) )
{ {
auto hr = S_OK; auto hr = S_OK;
PWDDMCONSOLECONTEXT pCtx = NULL; PWDDMCONSOLECONTEXT pCtx = nullptr;
if (hDisplay == NULL) { if (hDisplay == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} else { } else {
pCtx = (PWDDMCONSOLECONTEXT)hDisplay; pCtx = static_cast<PWDDMCONSOLECONTEXT>(hDisplay);
} }
if (SUCCEEDED(hr) && pCtx->fInD2DBatch) { if (SUCCEEDED(hr) && pCtx->fInD2DBatch) {
@ -535,12 +530,12 @@ WDDMConEndUpdateDisplayBatch(
) )
{ {
auto hr = S_OK; auto hr = S_OK;
PWDDMCONSOLECONTEXT pCtx = NULL; PWDDMCONSOLECONTEXT pCtx = nullptr;
if (hDisplay == NULL) { if (hDisplay == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} else { } else {
pCtx = (PWDDMCONSOLECONTEXT)hDisplay; pCtx = static_cast<PWDDMCONSOLECONTEXT>(hDisplay);
} }
if (SUCCEEDED(hr) && !pCtx->fInD2DBatch) { if (SUCCEEDED(hr) && !pCtx->fInD2DBatch) {
@ -568,17 +563,17 @@ HRESULT
WINAPI WINAPI
WDDMConUpdateDisplay( WDDMConUpdateDisplay(
_In_ HANDLE hDisplay, _In_ HANDLE hDisplay,
_In_ CD_IO_ROW_INFORMATION *pRowInformation, _In_ const CD_IO_ROW_INFORMATION *pRowInformation,
_In_ BOOLEAN fInvalidate _In_ BOOLEAN fInvalidate
) )
{ {
auto hr = S_OK; auto hr = S_OK;
PWDDMCONSOLECONTEXT pCtx = NULL; PWDDMCONSOLECONTEXT pCtx = nullptr;
if (hDisplay == NULL || pRowInformation == NULL) { if (hDisplay == nullptr || pRowInformation == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} else { } else {
pCtx = (PWDDMCONSOLECONTEXT)hDisplay; pCtx = static_cast<PWDDMCONSOLECONTEXT>(hDisplay);
} }
// To prevent an infinite loop, we need to limit the number of times we try to render. // To prevent an infinite loop, we need to limit the number of times we try to render.
@ -589,7 +584,7 @@ WDDMConUpdateDisplay(
ReRender: ReRender:
ULONG ColumnIndex = 0; ULONG ColumnIndex = 0;
float LineY = 0.0f; auto LineY = 0.0f;
if (SUCCEEDED(hr) && pCtx->fOutputEnabled) { if (SUCCEEDED(hr) && pCtx->fOutputEnabled) {
if (SUCCEEDED(hr) && !pCtx->fHaveDeviceResources) { if (SUCCEEDED(hr) && !pCtx->fHaveDeviceResources) {
hr = CreateDeviceResources(pCtx, TRUE); hr = CreateDeviceResources(pCtx, TRUE);
@ -604,15 +599,15 @@ ReRender:
} }
while (SUCCEEDED(hr)) { while (SUCCEEDED(hr)) {
IDWriteTextLayout *pTextLayout = NULL; IDWriteTextLayout *pTextLayout = nullptr;
if (fInvalidate || if (fInvalidate ||
(memcmp(&pRowInformation->New[ColumnIndex], (memcmp(&pRowInformation->New[ColumnIndex],
&pRowInformation->Old[ColumnIndex], &pRowInformation->Old[ColumnIndex],
sizeof(CD_IO_CHARACTER)) != 0)) { sizeof(CD_IO_CHARACTER)) != 0)) {
PCD_IO_CHARACTER pCharacter = &pRowInformation->New[ColumnIndex]; const auto* const pCharacter = &pRowInformation->New[ColumnIndex];
float CharacterOrigin = (ColumnIndex + CONSOLE_MARGIN) * pCtx->GlyphWidth; const auto CharacterOrigin = (ColumnIndex + CONSOLE_MARGIN) * pCtx->GlyphWidth;
ULONG ColumnIndexStart = ColumnIndex; const auto ColumnIndexStart = ColumnIndex;
ULONG ColumnIndexReadAhead = ColumnIndex + 1; auto ColumnIndexReadAhead = ColumnIndex + 1;
ULONG GlyphRunLength; ULONG GlyphRunLength;
pCtx->pwszGlyphRunAccel[ColumnIndex] = pRowInformation->New[ColumnIndex].Character; pCtx->pwszGlyphRunAccel[ColumnIndex] = pRowInformation->New[ColumnIndex].Character;
@ -644,26 +639,26 @@ ReRender:
ColumnIndex = ColumnIndexReadAhead - 1; ColumnIndex = ColumnIndexReadAhead - 1;
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
D2D1_RECT_F GlyphRectangle = D2D1::RectF(CharacterOrigin, auto GlyphRectangle = D2D1::RectF(CharacterOrigin,
LineY, LineY,
CharacterOrigin + pCtx->GlyphWidth * GlyphRunLength, CharacterOrigin + pCtx->GlyphWidth * GlyphRunLength,
LineY + pCtx->LineHeight); LineY + pCtx->LineHeight);
D2D1_POINT_2F Origin = D2D1::Point2F(CharacterOrigin, LineY); const auto Origin = D2D1::Point2F(CharacterOrigin, LineY);
if (ColumnIndexStart == 0) { if (ColumnIndexStart == 0) {
GlyphRectangle.left = 0.0f; GlyphRectangle.left = 0.0f;
} }
if ((UINT)pRowInformation->Index == 0) { if (static_cast<UINT>(pRowInformation->Index) == 0) {
GlyphRectangle.top = 0.0f; GlyphRectangle.top = 0.0f;
} }
if (ColumnIndex == pCtx->DisplaySize.Width - 1) { if (ColumnIndex == pCtx->DisplaySize.Width - 1) {
GlyphRectangle.right = (float)pCtx->DisplayMode.Width; GlyphRectangle.right = static_cast<float>(pCtx->DisplayMode.Width);
} }
if ((UINT)pRowInformation->Index == pCtx->DisplaySize.Height - 1) { if (static_cast<UINT>(pRowInformation->Index) == pCtx->DisplaySize.Height - 1) {
GlyphRectangle.bottom = (float)pCtx->DisplayMode.Height; GlyphRectangle.bottom = static_cast<float>(pCtx->DisplayMode.Height);
} }
pCtx->pD2DColorBrush->SetColor( pCtx->pD2DColorBrush->SetColor(
@ -696,13 +691,14 @@ ReRender:
} }
} }
if (FAILED(hr) && pCtx != NULL && pCtx->fHaveDeviceResources) { if (FAILED(hr) && pCtx != nullptr && pCtx->fHaveDeviceResources) {
ReleaseDeviceResources(pCtx); ReleaseDeviceResources(pCtx);
RenderAttempts++; RenderAttempts++;
if (RenderAttempts < MAX_RENDER_ATTEMPTS) if (RenderAttempts < MAX_RENDER_ATTEMPTS)
{ {
hr = S_OK; hr = S_OK;
#pragma warning(suppress : 26438 26448)
goto ReRender; goto ReRender;
} }
} }
@ -717,15 +713,15 @@ WINAPI
WDDMConGetDisplaySize( WDDMConGetDisplaySize(
_In_ HANDLE hDisplay, _In_ HANDLE hDisplay,
_In_ CD_IO_DISPLAY_SIZE *pDisplaySize _In_ CD_IO_DISPLAY_SIZE *pDisplaySize
) ) noexcept
{ {
auto hr = S_OK; auto hr = S_OK;
PWDDMCONSOLECONTEXT pCtx = NULL; PWDDMCONSOLECONTEXT pCtx = nullptr;
if (hDisplay == NULL) { if (hDisplay == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} else { } else {
pCtx = (PWDDMCONSOLECONTEXT)hDisplay; pCtx = static_cast<PWDDMCONSOLECONTEXT>(hDisplay);
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
@ -743,12 +739,12 @@ WDDMConEnableDisplayAccess(
) )
{ {
auto hr = S_OK; auto hr = S_OK;
PWDDMCONSOLECONTEXT pCtx = NULL; PWDDMCONSOLECONTEXT pCtx = nullptr;
if (hDisplay == NULL) { if (hDisplay == nullptr) {
hr = E_INVALIDARG; hr = E_INVALIDARG;
} else { } else {
pCtx = (PWDDMCONSOLECONTEXT)hDisplay; pCtx = static_cast<PWDDMCONSOLECONTEXT>(hDisplay);
} }
if (SUCCEEDED(hr) && if (SUCCEEDED(hr) &&

View File

@ -32,11 +32,11 @@ HRESULT
WINAPI WINAPI
WDDMConGetDisplaySize( WDDMConGetDisplaySize(
_In_ HANDLE hDisplay, _In_ HANDLE hDisplay,
_In_ CD_IO_DISPLAY_SIZE* pDisplaySize); _In_ CD_IO_DISPLAY_SIZE* pDisplaySize) noexcept;
HRESULT HRESULT
WINAPI WINAPI
WDDMConUpdateDisplay( WDDMConUpdateDisplay(
_In_ HANDLE hDisplay, _In_ HANDLE hDisplay,
_In_ CD_IO_ROW_INFORMATION* pRowInformation, _In_ const CD_IO_ROW_INFORMATION* pRowInformation,
_In_ BOOLEAN fInvalidate); _In_ BOOLEAN fInvalidate);

View File

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
#include "../host/conddkrefs.h"
#include <condrv.h>
// This is a fake interface, not to be confused with the actual private one.
MIDL_INTERFACE("e962a0bf-ba8c-4150-9939-4297b11329b6")
IDXGISwapChainDWM : IUnknown
{
virtual HRESULT STDMETHODCALLTYPE Present(UINT SyncInterval, UINT Flags) = 0;
virtual HRESULT STDMETHODCALLTYPE GetBuffer(UINT Buffer, REFIID riid, void** ppSurface) = 0;
};
// This is a fake interface, not to be confused with the actual private one.
MIDL_INTERFACE("599628c0-c2c6-4720-8885-17abe0fd43f2")
IDXGIFactoryDWM : IUnknown
{
virtual HRESULT STDMETHODCALLTYPE CreateSwapChain(IUnknown * pDevice, DXGI_SWAP_CHAIN_DESC * pDesc, IDXGIOutput * pTarget, IDXGISwapChainDWM * *ppSwapChain) = 0;
};

View File

@ -4,29 +4,25 @@
#pragma once #pragma once
#define NOMINMAX #define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <nt.h> #include <Windows.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <windows.h> #include <dxgi1_2.h>
#include <condrv.h>
#include <cmath>
#include <exception>
#include <typeinfo>
#include <stdexcept>
#include <dxgi.h>
#include <dxgidwm.h>
#include <d3d11.h> #include <d3d11.h>
#include <d2d1.h> #include <d2d1.h>
#include <d2d1helper.h> #include <d2d1helper.h>
#include <dwrite.h> #include <dwrite.h>
#ifdef __INSIDE_WINDOWS
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <dxgidwm.h>
#include <condrv.h>
#else
#include "oss_shim.h"
#endif
// This includes support libraries from the CRT, STL, WIL, and GSL // This includes support libraries from the CRT, STL, WIL, and GSL
#include "LibraryIncludes.h" #include "LibraryIncludes.h"
#pragma hdrstop

View File

@ -44,7 +44,7 @@ public:
#pragma endregion #pragma endregion
virtual ~IApiRoutines(){}; virtual ~IApiRoutines() = default;
#pragma region L1 #pragma region L1
virtual void GetConsoleInputCodePageImpl(ULONG& codepage) noexcept = 0; virtual void GetConsoleInputCodePageImpl(ULONG& codepage) noexcept = 0;

View File

@ -29,15 +29,13 @@ enum class ReplyDataType
class IWaitRoutine class IWaitRoutine
{ {
public: public:
IWaitRoutine(ReplyDataType type) : IWaitRoutine(ReplyDataType type) noexcept :
_ReplyType(type) _ReplyType(type)
{ {
} }
virtual ~IWaitRoutine() virtual ~IWaitRoutine() = default;
{
}
virtual void MigrateUserBuffersOnTransitionToBackgroundWait(const void* oldBuffer, void* newBuffer) = 0; virtual void MigrateUserBuffersOnTransitionToBackgroundWait(const void* oldBuffer, void* newBuffer) = 0;
@ -48,7 +46,7 @@ public:
_Out_ DWORD* const pControlKeyState, _Out_ DWORD* const pControlKeyState,
_Out_ void* const pOutputData) = 0; _Out_ void* const pOutputData) = 0;
ReplyDataType GetReplyType() const ReplyDataType GetReplyType() const noexcept
{ {
return _ReplyType; return _ReplyType;
} }

View File

@ -26,7 +26,7 @@ public:
// NOTE: This class must have a virtual method for the stored "this" pointers to match what we're actually looking for. // NOTE: This class must have a virtual method for the stored "this" pointers to match what we're actually looking for.
// If there is no virtual method, we may have the "this" pointer be offset by 8 from the actual object that inherits ConsoleObjectHeader. // If there is no virtual method, we may have the "this" pointer be offset by 8 from the actual object that inherits ConsoleObjectHeader.
virtual ~ConsoleObjectHeader(){}; virtual ~ConsoleObjectHeader() = default;
[[nodiscard]] HRESULT AllocateIoHandle(const ConsoleHandleData::HandleType ulHandleType, [[nodiscard]] HRESULT AllocateIoHandle(const ConsoleHandleData::HandleType ulHandleType,
const ACCESS_MASK amDesired, const ACCESS_MASK amDesired,