https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1c97b84600096f775faef…
commit 1c97b84600096f775faefb9244faacebb3c54616
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sat May 22 16:31:31 2021 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sat May 22 16:31:31 2021 +0200
[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);
}