[BLUE] Reformat and add missing success checks + DPRINTs on failure

This commit is contained in:
Timo Kreuzer 2018-07-01 10:24:22 +02:00
parent 64f46045af
commit 741c3c0022

View file

@ -33,8 +33,12 @@ ScrLoadFontTable(
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
FontBitfield = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, 2048, TAG_BLUE); FontBitfield = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, 2048, TAG_BLUE);
if (FontBitfield) if (FontBitfield == NULL)
{ {
DPRINT1("ExAllocatePoolWithTag failed\n");
return;
}
/* open bit plane for font table access */ /* open bit plane for font table access */
OpenBitPlane(); OpenBitPlane();
@ -44,14 +48,19 @@ ScrLoadFontTable(
Status = ExtractFont(CodePage, FontBitfield); Status = ExtractFont(CodePage, FontBitfield);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{
LoadFont(Bitplane, FontBitfield); LoadFont(Bitplane, FontBitfield);
}
else
{
DPRINT1("ExtractFont failed with Status 0x%lx\n", Status);
}
MmUnmapIoSpace(Bitplane, 0xFFFF); MmUnmapIoSpace(Bitplane, 0xFFFF);
ExFreePool(FontBitfield); ExFreePool(FontBitfield);
/* close bit plane */ /* close bit plane */
CloseBitPlane(); CloseBitPlane();
}
} }
/* PRIVATE FUNCTIONS *********************************************************/ /* PRIVATE FUNCTIONS *********************************************************/
@ -93,7 +102,10 @@ ExtractFont(
&ObjectAttributes); &ObjectAttributes);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return(Status); {
DPRINT1("ZwOpenSymbolicLinkObject failed with Status 0x%lx\n", Status);
return Status;
}
SourceName.Length = 0; SourceName.Length = 0;
SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR); SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR);
@ -104,7 +116,19 @@ ExtractFont(
NULL); NULL);
ZwClose(Handle); ZwClose(Handle);
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwQuerySymbolicLinkObject failed with Status 0x%lx\n", Status);
return Status;
}
Status = RtlAppendUnicodeToString(&SourceName, L"\\vgafonts.cab"); Status = RtlAppendUnicodeToString(&SourceName, L"\\vgafonts.cab");
if (!NT_SUCCESS(Status))
{
DPRINT1("RtlAppendUnicodeToString failed with Status 0x%lx\n", Status);
return Status;
}
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&SourceName, &SourceName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
@ -125,8 +149,12 @@ ExtractFont(
ByteOffset.LowPart = ByteOffset.HighPart = 0; ByteOffset.LowPart = ByteOffset.HighPart = 0;
if (NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Error: Cannot open vgafonts.cab (0x%lx)\n", Status);
return Status;
}
Status = ZwReadFile(Handle, Status = ZwReadFile(Handle,
NULL, NULL,
NULL, NULL,
@ -137,10 +165,19 @@ ExtractFont(
&ByteOffset, &ByteOffset,
NULL); NULL);
if (NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
if (CabFileHeader.Signature == CAB_SIGNATURE) DPRINT1("Error: Cannot read from file (0x%lx)\n", Status);
goto Exit;
}
if (CabFileHeader.Signature != CAB_SIGNATURE)
{ {
DPRINT1("Error: CAB signature is missing!\n");
Status = STATUS_UNSUCCESSFUL;
goto Exit;
}
// We have a valid CAB file! // We have a valid CAB file!
// Read the file table now and decrement the file count on every file. When it's zero, we read the complete table. // Read the file table now and decrement the file count on every file. When it's zero, we read the complete table.
ByteOffset.LowPart = CabFileHeader.FileTableOffset; ByteOffset.LowPart = CabFileHeader.FileTableOffset;
@ -208,26 +245,15 @@ ExtractFont(
2048, 2048,
&ByteOffset, &ByteOffset,
NULL); NULL);
ZwClose(Handle); if (!NT_SUCCESS(Status))
return STATUS_SUCCESS;
}
else
{ {
DPRINT1("Error: CAB signature is missing!\n"); DPRINT1("ZwReadFile failed with Status 0x%lx\n", Status);
Status = STATUS_UNSUCCESSFUL;
} }
}
else Exit:
DPRINT1("Error: Cannot read from file\n");
ZwClose(Handle); ZwClose(Handle);
return Status; return Status;
}
else
{
DPRINT1("Error: Cannot open vgafonts.cab\n");
return Status;
}
} }
/* Font-load specific funcs */ /* Font-load specific funcs */