Fixed a small bug in my code and removed DbgPrint.

svn path=/trunk/; revision=7911
This commit is contained in:
Richard Campbell 2004-01-29 22:23:27 +00:00
parent 8904505d1f
commit 0d2c4c19fd

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: text.c,v 1.70 2004/01/29 22:17:54 rcampbell Exp $ */ /* $Id: text.c,v 1.71 2004/01/29 22:23:27 rcampbell Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
@ -253,80 +253,72 @@ BOOL FASTCALL InitFontSupport(VOID)
PVOID pBuff; PVOID pBuff;
BOOLEAN bRestartScan = TRUE; BOOLEAN bRestartScan = TRUE;
InitializeListHead(&FontListHead);
ExInitializeFastMutex(&FontListLock);
ExInitializeFastMutex(&FreeTypeLock);
ulError = FT_Init_FreeType(&library);
if(pBuff)
{
InitializeListHead(&FontListHead);
ExInitializeFastMutex(&FontListLock);
ExInitializeFastMutex(&FreeTypeLock);
ulError = FT_Init_FreeType(&library);
if(!ulError) if(!ulError)
{ {
RtlInitUnicodeString(&cchDir, L"\\SystemRoot\\Media\\Fonts\\"); RtlInitUnicodeString(&cchDir, L"\\SystemRoot\\Media\\Fonts\\");
//RtlInitUnicodeString(&cchFilename, (PWCHAR)ExAllocatePool(NonPagedPool,0x4000)); RtlInitUnicodeString(&cchSearchPattern,L"*.ttf");
RtlInitUnicodeString(&cchSearchPattern,L"*.ttf"); InitializeObjectAttributes( &obAttr,
&cchDir,
InitializeObjectAttributes( &obAttr, OBJ_CASE_INSENSITIVE,
&cchDir, NULL,
OBJ_CASE_INSENSITIVE, NULL );
NULL,
NULL );
Status = ZwOpenFile( &hDirectory, Status = ZwOpenFile( &hDirectory,
SYNCHRONIZE | FILE_LIST_DIRECTORY, SYNCHRONIZE | FILE_LIST_DIRECTORY,
&obAttr, &obAttr,
&Iosb, &Iosb,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE ); FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE );
if( NT_SUCCESS(Status) ) if( NT_SUCCESS(Status) )
{ {
while(1) while(1)
{ {
iFileData = NULL; iFileData = NULL;
pBuff = ExAllocatePool(NonPagedPool,0x4000); pBuff = ExAllocatePool(NonPagedPool,0x4000);
RtlInitUnicodeString(&cchFilename,0); RtlInitUnicodeString(&cchFilename,0);
cchFilename.MaximumLength = 0x1000; cchFilename.MaximumLength = 0x1000;
cchFilename.Buffer = ExAllocatePool(PagedPool,cchFilename.MaximumLength); cchFilename.Buffer = ExAllocatePool(PagedPool,cchFilename.MaximumLength);
cchFilename.Length = 0; cchFilename.Length = 0;
Status = NtQueryDirectoryFile( hDirectory, Status = NtQueryDirectoryFile( hDirectory,
NULL, NULL,
NULL, NULL,
NULL, NULL,
&Iosb, &Iosb,
pBuff, pBuff,
0x4000, 0x4000,
FileDirectoryInformation, FileDirectoryInformation,
TRUE, TRUE,
&cchSearchPattern, &cchSearchPattern,
bRestartScan ); bRestartScan );
iFileData = (PFILE_DIRECTORY_INFORMATION)pBuff; iFileData = (PFILE_DIRECTORY_INFORMATION)pBuff;
RtlAppendUnicodeToString(&cchFilename, cchDir.Buffer); RtlAppendUnicodeToString(&cchFilename, cchDir.Buffer);
RtlAppendUnicodeToString(&cchFilename, iFileData->FileName); RtlAppendUnicodeToString(&cchFilename, iFileData->FileName);
RtlAppendUnicodeToString(&cchFilename, L"\0"); RtlAppendUnicodeToString(&cchFilename, L"\0");
if( !NT_SUCCESS(Status) || Status == STATUS_NO_MORE_FILES ) if( !NT_SUCCESS(Status) || Status == STATUS_NO_MORE_FILES )
break; break;
DbgPrint("Adding Font: \"%S\"\n", cchFilename.Buffer); IntGdiAddFontResource(&cchFilename, 0);
//NtGdiAddFontResource(&cchFilename, 0);
IntGdiAddFontResource(&cchFilename, 0);
ExFreePool(pBuff);
ExFreePool(cchFilename.Buffer);
bRestartScan = FALSE;
}
ExFreePool(pBuff); ExFreePool(pBuff);
return TRUE; ExFreePool(cchFilename.Buffer);
} bRestartScan = FALSE;
}
ExFreePool(cchFilename.Buffer);
ExFreePool(pBuff);
return TRUE;
} }
} }
return FALSE; return FALSE;
} }