INT FASTCALL IntGdiAddFontResourceEx(PUNICODE_STRING FileName, DWORD Characteristics, BOOL bWriteRegistry) { ... } INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) { return IntGdiAddFontResourceEx(FileName, Characteristics, FALSE); } BOOL FASTCALL IntLoadFontsInRegistry(PLIST_ENTRY pHead) { NTSTATUS Status; HANDLE KeyHandle; OBJECT_ATTRIBUTES ObjectAttributes; KEY_FULL_INFORMATION KeyFullInfo; ULONG i, Length; UNICODE_STRING FontTitleW, FontPathW, FileNameW; BYTE InfoBuffer[128]; PKEY_VALUE_FULL_INFORMATION pInfo; LPWSTR pch; PFONTSUBST_ENTRY pEntry; BOOLEAN Success; WCHAR szPath[MAX_PATH]; INT nFontCount = 0; /* open registry key */ InitializeObjectAttributes(&ObjectAttributes, &g_FontRegPath, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes); if (!NT_SUCCESS(Status)) { DPRINT("ZwOpenKey failed: 0x%08X\n", Status); return FALSE; /* failure */ } /* query count of values */ Status = ZwQueryKey(KeyHandle, KeyFullInformation, &KeyFullInfo, sizeof(KeyFullInfo), &Length); if (!NT_SUCCESS(Status)) { DPRINT("ZwQueryKey failed: 0x%08X\n", Status); ZwClose(KeyHandle); return FALSE; /* failure */ } /* for each value */ for (i = 0; i < KeyFullInfo.Values; ++i) { /* get value name */ Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation, InfoBuffer, sizeof(InfoBuffer), &Length); if (!NT_SUCCESS(Status)) { DPRINT("ZwEnumerateValueKey failed: 0x%08X\n", Status); break; /* failure */ } /* create FontTitleW string */ pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer; Length = pInfo->NameLength / sizeof(WCHAR); pInfo->Name[Length] = UNICODE_NULL; /* truncate */ Success = RtlCreateUnicodeString(&FontTitleW, pInfo->Name); if (!Success) { Status = STATUS_INSUFFICIENT_RESOURCES; DPRINT("RtlCreateUnicodeString failed\n"); break; /* failure */ } /* query value */ Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation, InfoBuffer, sizeof(InfoBuffer), &Length); pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer; if (!NT_SUCCESS(Status) || !pInfo->DataLength) { DPRINT("ZwQueryValueKey failed: 0x%08X\n", Status); RtlFreeUnicodeString(&FontTitleW); break; /* failure */ } /* create FontPathW string */ pch = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset); Length = pInfo->DataLength / sizeof(WCHAR); pch[Length] = UNICODE_NULL; /* truncate */ Success = RtlCreateUnicodeString(&FontPathW, pch); if (!Success) { Status = STATUS_INSUFFICIENT_RESOURCES; DPRINT("RtlCreateUnicodeString failed\n"); RtlFreeUnicodeString(&FontTitleW); break; /* failure */ } if (PathIsRelativeW(pch)) { GetWindowsDirectoryW(szPath, ARRAYSIZE(szPath)); StringCbCatW(szPath, ARRAYSIZE(szPath), L"\\Fonts\\"); StringCbCatW(szPath, ARRAYSIZE(szPath), pch); } else { StringCbCopy(szPath, ARRAYSIZE(szPath), pch); } /* Load font(s) without writing registry */ RtlCreateUnicodeString(&FileNameW, szPath); nFontCount += IntGdiAddFontResourceEx(&FileNameW, 0, TRUE); RtlFreeUnicodeString(&FileNameW); RtlFreeUnicodeString(&FontTitleW); RtlFreeUnicodeString(&FontPathW); } /* close now */ ZwClose(KeyHandle); if (KeyFullInfo.Values == 0 || nFontCount == 0) { DPRINT1("Fonts registry is empty.\n"); /* Load font(s) with writing registry */ IntLoadSystemFonts(); return TRUE; } return NT_SUCCESS(Status); }