mirror of
https://github.com/reactos/reactos.git
synced 2025-04-04 04:26:32 +00:00
[USETUP] Move loading of requested font from blue.sys to usetup
This commit is contained in:
parent
04ec14e23e
commit
2391e31cf0
1 changed files with 63 additions and 3 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue