https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2391e31cf0d82b3d48a11…
commit 2391e31cf0d82b3d48a11bc7551b341cdc06be84
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sun Apr 26 00:23:13 2020 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sun Apr 26 14:59:04 2020 +0200
[USETUP] Move loading of requested font from blue.sys to usetup
---
base/setup/usetup/console.c | 66 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 63 insertions(+), 3 deletions(-)
diff --git a/base/setup/usetup/console.c b/base/setup/usetup/console.c
index 8b56bbe2ef7..57b396aafde 100644
--- a/base/setup/usetup/console.c
+++ b/base/setup/usetup/console.c
@@ -44,6 +44,31 @@ static UINT LastLoadedCodepage;
/* FUNCTIONS *****************************************************************/
+typedef struct _CONSOLE_CABINET_CONTEXT
+{
+ CABINET_CONTEXT CabinetContext;
+ PVOID Data;
+ ULONG Size;
+} CONSOLE_CABINET_CONTEXT, *PCONSOLE_CABINET_CONTEXT;
+
+static PVOID
+ConsoleCreateFileHandler(
+ IN PCABINET_CONTEXT CabinetContext,
+ IN ULONG FileSize)
+{
+ PCONSOLE_CABINET_CONTEXT ConsoleCabinetContext;
+
+ ConsoleCabinetContext = (PCONSOLE_CABINET_CONTEXT)CabinetContext;
+ ConsoleCabinetContext->Data = RtlAllocateHeap(ProcessHeap, 0, FileSize);
+ if (!ConsoleCabinetContext->Data)
+ {
+ DPRINT("Failed to allocate %d bytes\n", FileSize);
+ return NULL;
+ }
+ ConsoleCabinetContext->Size = FileSize;
+ return ConsoleCabinetContext->Data;
+}
+
BOOL
WINAPI
AllocConsole(VOID)
@@ -667,6 +692,12 @@ WINAPI
SetConsoleOutputCP(
IN UINT wCodepage)
{
+ WCHAR FontName[100];
+ WCHAR FontFile[] = L"\\SystemRoot\\vgafonts.cab";
+ CONSOLE_CABINET_CONTEXT ConsoleCabinetContext;
+ PCABINET_CONTEXT CabinetContext = &ConsoleCabinetContext.CabinetContext;
+ CAB_SEARCH Search;
+ ULONG CabStatus;
HANDLE hConsoleOutput;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
@@ -676,14 +707,43 @@ SetConsoleOutputCP(
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ CabinetInitialize(CabinetContext);
+ CabinetSetEventHandlers(CabinetContext,
+ NULL, NULL, NULL, ConsoleCreateFileHandler);
+ CabinetSetCabinetName(CabinetContext, FontFile);
+
+ CabStatus = CabinetOpen(CabinetContext);
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT("CabinetOpen('%S') returned 0x%08x\n", FontFile,
CabStatus);
+ return FALSE;
+ }
+
+ swprintf(FontName, L"%u-8x8.bin", wCodepage);
+ CabStatus = CabinetFindFirst(CabinetContext, FontName, &Search);
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT("CabinetFindFirst('%S', '%S') returned
0x%08x\n", FontFile, FontName, CabStatus);
+ CabinetClose(CabinetContext);
+ return FALSE;
+ }
+
+ CabStatus = CabinetExtractFile(CabinetContext, &Search);
+ CabinetClose(CabinetContext);
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT("CabinetLoadFile('%S', '%S') returned 0x%08x\n",
FontFile, FontName, CabStatus);
+ return FALSE;
+ }
+
Status = NtDeviceIoControlFile(hConsoleOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
- IOCTL_CONSOLE_LOADFONT,
- &wCodepage,
- sizeof(ULONG),
+ IOCTL_CONSOLE_SETFONT,
+ ConsoleCabinetContext.Data,
+ ConsoleCabinetContext.Size,
NULL,
0);
if (!NT_SUCCESS(Status))