[WIN32SS] Skip . and .. when enumerating fonts

This commit is contained in:
Mark Jansen 2021-05-22 16:31:31 +02:00
parent 0395049986
commit 1c97b84600
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -960,6 +960,11 @@ IntLoadSystemFonts(VOID)
RTL_CONSTANT_STRING(L"*.fon"), RTL_CONSTANT_STRING(L"*.fon"),
RTL_CONSTANT_STRING(L"*.fnt") RTL_CONSTANT_STRING(L"*.fnt")
}; };
static UNICODE_STRING IgnoreFiles[] =
{
RTL_CONSTANT_STRING(L"."),
RTL_CONSTANT_STRING(L".."),
};
RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Fonts\\"); RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Fonts\\");
@ -1022,14 +1027,33 @@ IntLoadSystemFonts(VOID)
DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer; DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer;
while (1) while (1)
{ {
SIZE_T ign;
TempString.Buffer = DirInfo->FileName; TempString.Buffer = DirInfo->FileName;
TempString.Length = TempString.Length = TempString.MaximumLength = DirInfo->FileNameLength;
TempString.MaximumLength = DirInfo->FileNameLength;
/* Should we ignore this file? */
for (ign = 0; ign < _countof(IgnoreFiles); ++ign)
{
/* Yes.. */
if (RtlEqualUnicodeString(IgnoreFiles + ign, &TempString, FALSE))
break;
}
/* If we tried all Ignore patterns and there was no match, try to create a font */
if (ign == _countof(IgnoreFiles))
{
RtlCopyUnicodeString(&FileName, &Directory); RtlCopyUnicodeString(&FileName, &Directory);
RtlAppendUnicodeStringToString(&FileName, &TempString); RtlAppendUnicodeStringToString(&FileName, &TempString);
IntGdiAddFontResourceEx(&FileName, 0, AFRX_WRITE_REGISTRY); if (!IntGdiAddFontResourceEx(&FileName, 0, AFRX_WRITE_REGISTRY))
{
DPRINT1("ERR: Failed to load %wZ\n", &FileName);
}
}
if (DirInfo->NextEntryOffset == 0) if (DirInfo->NextEntryOffset == 0)
break; break;
DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset); DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset);
} }