[ros-kernel] ExAllocatePool

Hartmut Birr hartmut.birr at gmx.de
Wed Feb 25 19:33:42 CET 2004



> -----Original Message-----
> From: ros-kernel-bounces at reactos.com 
> [mailto:ros-kernel-bounces at reactos.com] On Behalf Of Filip Navara
> Sent: Tuesday, February 24, 2004 5:03 PM
> To: ReactOS Kernel List
> Subject: Re: [ros-kernel] ExAllocatePool
> 
> 
> >>diff -r -u reactos/subsys/win32k/objects/text.c 
> reactos/subsys/win32k/objects/text.c
> >>--- reactos/subsys/win32k/objects/text.c	Sun Feb 22 08:35:22 2004
> >>+++ reactos/subsys/win32k/objects/text.c	Sun Feb 22 11:06:48 2004
> >>@@ -283,10 +283,11 @@
> >>             {   
> >>                 iFileData = NULL;
> >>                 pBuff = ExAllocatePool(NonPagedPool,0x4000);
> >>+                RtlZeroMemory(pBuff, 0x4000);
> >>                 RtlInitUnicodeString(&cchFilename,0);
> >>                 cchFilename.MaximumLength = 0x1000;
> >>                 cchFilename.Buffer = 
> ExAllocatePoolWithTag(PagedPool,cchFilename.MaximumLength, 
> TAG_STRING);
> >>- 
> >>+                RtlZeroMemory(cchFilename.Buffer, 
> cchFilename.MaximumLength);
> >>                 cchFilename.Length = 0;
> >> 				    
> >> 				Status = NtQueryDirectoryFile( 
> hDirectory,
> >>    
> >>
> >Definitely Ge's thing more than mine.  Looks OK to me though.
> >  
> >
> This change was done in order to prevent reading directory as a font 
> file. Without this zeroing (not sure witch one of these two 
> buffers) the 
> code actually endlessly cycled thru the fonts directory and tried to 
> load "file" "c:\reactos\media\fonts" instead of the actual fonts.
> 

The buffers must not be zero out. The problem is the handling of the
returned data from NtQueryDirectoryFile. They doesn't contain zero
terminated strings. If the buffer wasn't zero out previous,
RtlAppendUnicodeToString will add a little bit more to the resulting
unicode string. NtQueryDirectoryFile can also return multiple directory
entries. This reduces the overhead a little bit. See the attached file.

In win32k the buffers for bitmaps should be also zero out.

- Hartmut 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: text.c.diff
Type: application/octet-stream
Size: 5161 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20040225/44de6f88/text.c.obj


More information about the Ros-kernel mailing list