{
if (FT_IS_SFNT(Face))
{
- Status = DuplicateUnicodeString(&Entry->FaceName, pValueName);
- // TODO: Check return value
+ // L"Name StyleName\0"
+ Length = NameLength + sizeof(L' ') + Entry->StyleName.Length + sizeof(UNICODE_NULL);
+ pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
+ if (pszBuffer)
+ {
+ RtlInitEmptyUnicodeString(pValueName, pszBuffer, Length);
+ RtlCopyUnicodeString(pValueName, &Entry->FaceName);
+ if (Entry->StyleName.Length > 0)
+ {
+ RtlAppendUnicodeToString(pValueName, L" ");
+ RtlAppendUnicodeStringToString(pValueName, &Entry->StyleName);
+ }
+ }
+ else
+ {
+ break; /* failure */
+ }
}
else
{
pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
if (pszBuffer)
{
- RtlInitEmptyUnicodeString(pValueName, pszBuffer, (USHORT)Length);
+ RtlInitEmptyUnicodeString(pValueName, pszBuffer, Length);
RtlCopyUnicodeString(pValueName, &Entry->FaceName);
RtlAppendUnicodeToString(pValueName, szSize);
}
else
{
- // FIXME!
+ break; /* failure */
}
}
}
{
if (FT_IS_SFNT(Face))
{
- Length = pValueName->Length + 3 * sizeof(WCHAR) + NameLength + sizeof(UNICODE_NULL);
+ // L"... & Name StyleName\0"
+ Length = pValueName->Length + 3 * sizeof(WCHAR) + Entry->FaceName.Length +
+ sizeof(L' ') + Entry->StyleName.Length + sizeof(UNICODE_NULL);
pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
if (pszBuffer)
{
- RtlInitEmptyUnicodeString(&NewString, pszBuffer, (USHORT)Length);
+ RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
RtlCopyUnicodeString(&NewString, pValueName);
RtlAppendUnicodeToString(&NewString, L" & ");
RtlAppendUnicodeStringToString(&NewString, &Entry->FaceName);
+ if (Entry->StyleName.Length > 0)
+ {
+ RtlAppendUnicodeToString(&NewString, L" ");
+ RtlAppendUnicodeStringToString(&NewString, &Entry->StyleName);
+ }
}
else
{
- // FIXME!
+ RtlFreeUnicodeString(pValueName);
+ break; /* failure */
}
}
else
pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
if (pszBuffer)
{
- RtlInitEmptyUnicodeString(&NewString, pszBuffer, (USHORT)Length);
+ RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
RtlCopyUnicodeString(&NewString, pValueName);
RtlAppendUnicodeToString(&NewString, szSize);
}
else
{
- // FIXME!
+ RtlFreeUnicodeString(pValueName);
+ break; /* failure */
}
}
PVOID Buffer = NULL;
IO_STATUS_BLOCK Iosb;
PVOID SectionObject;
- SIZE_T ViewSize = 0;
+ SIZE_T ViewSize = 0, Length;
LARGE_INTEGER SectionSize;
OBJECT_ATTRIBUTES ObjectAttributes;
GDI_LOAD_FONT LoadFont;
INT FontCount;
HANDLE KeyHandle;
+ UNICODE_STRING PathName;
+ LPWSTR pszBuffer;
+ PFILE_OBJECT FileObject;
static const UNICODE_STRING TrueTypePostfix = RTL_CONSTANT_STRING(L" (TrueType)");
+ static const UNICODE_STRING DosPathPrefix = RTL_CONSTANT_STRING(L"\\??\\");
+
+ /* Build PathName */
+ if (dwFlags & AFRX_DOS_DEVICE_PATH)
+ {
+ Length = DosPathPrefix.Length + FileName->Length + sizeof(UNICODE_NULL);
+ pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
+ if (!pszBuffer)
+ return 0; /* failure */
+
+ RtlInitEmptyUnicodeString(&PathName, pszBuffer, Length);
+ RtlAppendUnicodeStringToString(&PathName, &DosPathPrefix);
+ RtlAppendUnicodeStringToString(&PathName, FileName);
+ }
+ else
+ {
+ Status = DuplicateUnicodeString(FileName, &PathName);
+ if (!NT_SUCCESS(Status))
+ return 0; /* failure */
+ }
/* Open the font file */
- InitializeObjectAttributes(&ObjectAttributes, FileName, 0, NULL, NULL);
+ InitializeObjectAttributes(&ObjectAttributes, &PathName,
+ OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ZwOpenFile(
&FileHandle,
FILE_GENERIC_READ | SYNCHRONIZE,
FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(Status))
{
- DPRINT("Could not load font file: %wZ\n", FileName);
+ DPRINT1("Could not load font file: %wZ\n", &PathName);
+ RtlFreeUnicodeString(&PathName);
+ return 0;
+ }
+
+ Status = ObReferenceObjectByHandle(FileHandle, FILE_READ_DATA, NULL,
+ KernelMode, (PVOID*)&FileObject, NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("ObReferenceObjectByHandle failed.\n");
+ ZwClose(FileHandle);
+ RtlFreeUnicodeString(&PathName);
return 0;
}
SectionSize.QuadPart = 0LL;
- Status = MmCreateSection(&SectionObject, SECTION_ALL_ACCESS,
+ Status = MmCreateSection(&SectionObject,
+ STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ,
NULL, &SectionSize, PAGE_READONLY,
- SEC_COMMIT, FileHandle, NULL);
+ SEC_COMMIT, FileHandle, FileObject);
if (!NT_SUCCESS(Status))
{
- DPRINT("Could not map file: %wZ\n", FileName);
+ DPRINT1("Could not map file: %wZ\n", &PathName);
ZwClose(FileHandle);
+ ObDereferenceObject(FileObject);
+ RtlFreeUnicodeString(&PathName);
return 0;
}
ZwClose(FileHandle);
Status = MmMapViewInSystemSpace(SectionObject, &Buffer, &ViewSize);
if (!NT_SUCCESS(Status))
{
- DPRINT("Could not map file: %wZ\n", FileName);
+ DPRINT1("Could not map file: %wZ\n", &PathName);
ObDereferenceObject(SectionObject);
+ ObDereferenceObject(FileObject);
+ RtlFreeUnicodeString(&PathName);
return 0;
}
- LoadFont.pFileName = FileName;
+ LoadFont.pFileName = &PathName;
LoadFont.Memory = SharedMem_Create(Buffer, ViewSize, TRUE);
LoadFont.Characteristics = Characteristics;
RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
ObDereferenceObject(SectionObject);
+ ObDereferenceObject(FileObject);
+
/* Save the loaded font name into the registry */
if (FontCount > 0 && (dwFlags & AFRX_WRITE_REGISTRY))
{
pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
if (pszBuffer)
{
- RtlInitEmptyUnicodeString(&NewString, pszBuffer, (USHORT)Length);
+ RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
NewString.Buffer[0] = UNICODE_NULL;
RtlAppendUnicodeStringToString(&NewString, &LoadFont.RegValueName);
RtlAppendUnicodeStringToString(&NewString, &TrueTypePostfix);
pszBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_USTR);
if (pszBuffer)
{
- RtlInitEmptyUnicodeString(&NewString, pszBuffer, (USHORT)Length);
+ RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
NewString.Buffer[0] = UNICODE_NULL;
RtlAppendUnicodeStringToString(&NewString, &LoadFont.RegValueName);
RtlAppendUnicodeToString(&NewString, L" (");
if (dwFlags & AFRX_ALTERNATIVE_PATH)
{
- pFileName = FileName->Buffer;
+ pFileName = PathName.Buffer;
}
else
{
- pFileName = wcsrchr(FileName->Buffer, L'\\');
+ pFileName = wcsrchr(PathName.Buffer, L'\\');
}
if (pFileName)
}
RtlFreeUnicodeString(&LoadFont.RegValueName);
+ RtlFreeUnicodeString(&PathName);
return FontCount;
}
Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
if (!NT_SUCCESS(Status))
{
- DPRINT("ZwOpenKey failed: 0x%08X\n", Status);
+ DPRINT1("ZwOpenKey failed: 0x%08X\n", Status);
return FALSE; /* failure */
}
&KeyFullInfo, sizeof(KeyFullInfo), &Length);
if (!NT_SUCCESS(Status))
{
- DPRINT("ZwQueryKey failed: 0x%08X\n", Status);
+ DPRINT1("ZwQueryKey failed: 0x%08X\n", Status);
ZwClose(KeyHandle);
return FALSE; /* failure */
}
}
if (!NT_SUCCESS(Status))
{
- DPRINT("ZwEnumerateValueKey failed: 0x%08X\n", Status);
+ DPRINT1("ZwEnumerateValueKey failed: 0x%08X\n", Status);
break; /* failure */
}
if (!Success)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
- DPRINT("RtlCreateUnicodeString failed\n");
+ DPRINT1("RtlCreateUnicodeString failed\n");
break; /* failure */
}
pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
if (!NT_SUCCESS(Status) || !pInfo->DataLength)
{
- DPRINT("ZwQueryValueKey failed: 0x%08X\n", Status);
+ DPRINT1("ZwQueryValueKey failed: 0x%08X\n", Status);
RtlFreeUnicodeString(&FontTitleW);
break; /* failure */
}
pchPath[Length] = UNICODE_NULL; /* truncate */
/* Load font(s) without writing registry */
- dwFlags = 0;
if (PathIsRelativeW(pchPath))
{
+ dwFlags = 0;
Status = RtlStringCbPrintfW(szPath, sizeof(szPath),
- L"%s\\Fonts\\%s",
- SharedUserData->NtSystemRoot, pchPath);
+ L"\\SystemRoot\\Fonts\\%s", pchPath);
}
else
{
- dwFlags |= AFRX_ALTERNATIVE_PATH;
+ dwFlags = AFRX_ALTERNATIVE_PATH | AFRX_DOS_DEVICE_PATH;
Status = RtlStringCbCopyW(szPath, sizeof(szPath), pchPath);
}