From 388fc6e94e70eb694d7b62a54872f68f822693c2 Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Mon, 30 Jun 2008 23:58:48 +0000 Subject: [PATCH] - Don't use ntdll's RtlDuplicateUnicodeString in kmode; it allocates from the process heap. Instead, allocate from pool and copy the string manually. - Get rid of other ntdll imports (memcmp in freetype, tan in win32k) and instead link the functions statically, so ntdll is no longer loaded at all in kmode. Saves about 550kB of memory. - Also remove unused hal in freetype. svn path=/trunk/; revision=34227 --- reactos/dll/3rdparty/freetype/freetype.rbuild | 3 +-- reactos/subsystems/win32/win32k/eng/objects.h | 2 +- reactos/subsystems/win32/win32k/objects/text.c | 15 ++++++++++++--- reactos/subsystems/win32/win32k/win32k.rbuild | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/reactos/dll/3rdparty/freetype/freetype.rbuild b/reactos/dll/3rdparty/freetype/freetype.rbuild index c4b240ee960..5d6c44b4294 100644 --- a/reactos/dll/3rdparty/freetype/freetype.rbuild +++ b/reactos/dll/3rdparty/freetype/freetype.rbuild @@ -14,8 +14,7 @@ ntoskrnl - ntdll - hal + libcntpr setjmplongjmp.s diff --git a/reactos/subsystems/win32/win32k/eng/objects.h b/reactos/subsystems/win32/win32k/eng/objects.h index aea3005d21f..37fec8251c6 100644 --- a/reactos/subsystems/win32/win32k/eng/objects.h +++ b/reactos/subsystems/win32/win32k/eng/objects.h @@ -70,7 +70,7 @@ typedef struct _FLOATGDI { typedef struct _FONTGDI { FONTOBJ FontObj; - LPCWSTR Filename; + LPWSTR Filename; FT_Face face; TEXTMETRICW TextMetric; } FONTGDI, *PFONTGDI; diff --git a/reactos/subsystems/win32/win32k/objects/text.c b/reactos/subsystems/win32/win32k/objects/text.c index 9b6d30c5dbf..a5ba4e6a26d 100644 --- a/reactos/subsystems/win32/win32k/objects/text.c +++ b/reactos/subsystems/win32/win32k/objects/text.c @@ -279,7 +279,6 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) PSECTION_OBJECT SectionObject; ULONG ViewSize = 0; FT_Fixed XScale, YScale; - UNICODE_STRING FileNameCopy; /* Open the font file */ @@ -355,8 +354,18 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) return 0; } - RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, FileName, &FileNameCopy); - FontGDI->Filename = FileNameCopy.Buffer; + FontGDI->Filename = ExAllocatePool(PagedPool, FileName->Length + sizeof(WCHAR)); + if (FontGDI->Filename == NULL) + { + EngFreeMem(FontGDI); + FT_Done_Face(Face); + ObDereferenceObject(SectionObject); + ExFreePool(Entry); + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + memcpy(FontGDI->Filename, FileName->Buffer, FileName->Length); + FontGDI->Filename[FileName->Length / sizeof(WCHAR)] = L'\0'; FontGDI->face = Face; /* FIXME: Complete text metrics */ diff --git a/reactos/subsystems/win32/win32k/win32k.rbuild b/reactos/subsystems/win32/win32k/win32k.rbuild index 7063b673f93..7d2ee8bca54 100644 --- a/reactos/subsystems/win32/win32k/win32k.rbuild +++ b/reactos/subsystems/win32/win32k/win32k.rbuild @@ -182,7 +182,7 @@ win32k_base pseh ntoskrnl - ntdll + libcntpr hal freetype dxguid