From 1c97b84600096f775faefb9244faacebb3c54616 Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Sat, 22 May 2021 16:31:31 +0200 Subject: [PATCH] [WIN32SS] Skip . and .. when enumerating fonts --- win32ss/gdi/ntgdi/freetype.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index 79c825f0170..efcb2c2c477 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -960,6 +960,11 @@ IntLoadSystemFonts(VOID) RTL_CONSTANT_STRING(L"*.fon"), RTL_CONSTANT_STRING(L"*.fnt") }; + static UNICODE_STRING IgnoreFiles[] = + { + RTL_CONSTANT_STRING(L"."), + RTL_CONSTANT_STRING(L".."), + }; RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Fonts\\"); @@ -1022,14 +1027,33 @@ IntLoadSystemFonts(VOID) DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer; while (1) { + SIZE_T ign; + TempString.Buffer = DirInfo->FileName; - TempString.Length = - TempString.MaximumLength = DirInfo->FileNameLength; - RtlCopyUnicodeString(&FileName, &Directory); - RtlAppendUnicodeStringToString(&FileName, &TempString); - IntGdiAddFontResourceEx(&FileName, 0, AFRX_WRITE_REGISTRY); + TempString.Length = 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); + RtlAppendUnicodeStringToString(&FileName, &TempString); + if (!IntGdiAddFontResourceEx(&FileName, 0, AFRX_WRITE_REGISTRY)) + { + DPRINT1("ERR: Failed to load %wZ\n", &FileName); + } + } + if (DirInfo->NextEntryOffset == 0) break; + DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset); }