- Don't zero memory allocated by ExAllocatePool.

- Fix font enumeration algorithm to not depend on zeroed memory. (Harmut Birr)

svn path=/trunk/; revision=8525
This commit is contained in:
Filip Navara 2004-03-04 00:07:03 +00:00
parent 2bb6230071
commit 07892f4f36
10 changed files with 95 additions and 38 deletions

View file

@ -1,4 +1,4 @@
/* $Id: buildirp.c,v 1.38 2003/12/30 18:52:04 fireball Exp $ /* $Id: buildirp.c,v 1.39 2004/03/04 00:07:00 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -259,6 +259,13 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
InputBuffer, InputBuffer,
InputBufferLength); InputBufferLength);
RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer + InputBufferLength,
BufferLength - InputBufferLength);
}
else
{
RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer,
BufferLength);
} }
Irp->UserBuffer = OutputBuffer; Irp->UserBuffer = OutputBuffer;
break; break;
@ -273,12 +280,13 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
ExAllocatePoolWithTag(NonPagedPool,OutputBufferLength, ExAllocatePoolWithTag(NonPagedPool,OutputBufferLength,
TAG_SYS_BUF); TAG_SYS_BUF);
if (Irp->AssociatedIrp.SystemBuffer == NULL) if (Irp->AssociatedIrp.SystemBuffer == NULL)
{ {
IoFreeIrp(Irp); IoFreeIrp(Irp);
return(NULL); return(NULL);
} }
RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, OutputBufferLength);
Irp->UserBuffer = OutputBuffer; Irp->UserBuffer = OutputBuffer;
} }

View file

@ -1,4 +1,4 @@
/* $Id: irp.c,v 1.57 2003/12/31 14:16:18 hbirr Exp $ /* $Id: irp.c,v 1.58 2004/03/04 00:07:00 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -200,6 +200,7 @@ IoAllocateIrp(CCHAR StackSize,
return(NULL); return(NULL);
} }
RtlZeroMemory(Irp, IoSizeOfIrp(StackSize));
IoInitializeIrp(Irp, IoInitializeIrp(Irp,
IoSizeOfIrp(StackSize), IoSizeOfIrp(StackSize),
StackSize); StackSize);

View file

@ -1,4 +1,4 @@
/* $Id: aspace.c,v 1.15 2003/10/12 17:05:48 hbirr Exp $ /* $Id: aspace.c,v 1.16 2004/03/04 00:07:01 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -88,6 +88,7 @@ MmInitializeAddressSpace(PEPROCESS Process,
AddressSpace->PageTableRefCountTable = AddressSpace->PageTableRefCountTable =
ExAllocatePoolWithTag(NonPagedPool, 768 * sizeof(USHORT), ExAllocatePoolWithTag(NonPagedPool, 768 * sizeof(USHORT),
TAG_PTRC); TAG_PTRC);
RtlZeroMemory(AddressSpace->PageTableRefCountTable, 768 * sizeof(USHORT));
AddressSpace->PageTableRefCountTableSize = 768; AddressSpace->PageTableRefCountTableSize = 768;
} }
else else

View file

@ -1,4 +1,4 @@
/* $Id: npool.c,v 1.81 2004/02/07 16:37:23 hbirr Exp $ /* $Id: npool.c,v 1.82 2004/03/04 00:07:01 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1633,7 +1633,7 @@ ExAllocateNonPagedPoolWithTag(ULONG Type, ULONG Size, ULONG Tag, PVOID Caller)
#endif #endif
KeReleaseSpinLock(&MmNpoolLock, oldIrql); KeReleaseSpinLock(&MmNpoolLock, oldIrql);
block = block_to_address(best); block = block_to_address(best);
memset(block,0,Size); /* RtlZeroMemory(block, Size);*/
return(block); return(block);
#endif /* WHOLE_PAGE_ALLOCATIONS */ #endif /* WHOLE_PAGE_ALLOCATIONS */
} }

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: pagefile.c,v 1.41 2003/12/30 18:52:05 fireball Exp $ /* $Id: pagefile.c,v 1.42 2004/03/04 00:07:01 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/pagefile.c * FILE: ntoskrnl/mm/pagefile.c
@ -453,6 +453,22 @@ MmAllocSwapPage(VOID)
return(0); return(0);
} }
STATIC PRETRIEVEL_DESCRIPTOR_LIST FASTCALL
MmAllocRetrievelDescriptorList(ULONG Pairs)
{
ULONG Size;
PRETRIEVEL_DESCRIPTOR_LIST RetDescList;
Size = sizeof(RETRIEVEL_DESCRIPTOR_LIST) + Pairs * sizeof(MAPPING_PAIR);
RetDescList = ExAllocatePool(NonPagedPool, Size);
if (RetDescList)
{
RtlZeroMemory(RetDescList, Size);
}
return RetDescList;
}
NTSTATUS STDCALL NTSTATUS STDCALL
MmDumpToPagingFile(ULONG BugCode, MmDumpToPagingFile(ULONG BugCode,
ULONG BugCodeParameter1, ULONG BugCodeParameter1,
@ -716,7 +732,6 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
PPAGINGFILE PagingFile; PPAGINGFILE PagingFile;
KIRQL oldIrql; KIRQL oldIrql;
ULONG AllocMapSize; ULONG AllocMapSize;
ULONG Size;
FILE_FS_SIZE_INFORMATION FsSizeInformation; FILE_FS_SIZE_INFORMATION FsSizeInformation;
PRETRIEVEL_DESCRIPTOR_LIST RetDescList; PRETRIEVEL_DESCRIPTOR_LIST RetDescList;
PRETRIEVEL_DESCRIPTOR_LIST CurrentRetDescList; PRETRIEVEL_DESCRIPTOR_LIST CurrentRetDescList;
@ -726,6 +741,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
ULONG ExtentCount; ULONG ExtentCount;
ULONG MaxVcn; ULONG MaxVcn;
ULONG Count; ULONG Count;
ULONG Size;
DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n", DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n",
FileName, InitialSize->QuadPart); FileName, InitialSize->QuadPart);
@ -801,8 +817,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
return(Status); return(Status);
} }
Size = sizeof(RETRIEVEL_DESCRIPTOR_LIST) + PAIRS_PER_RUN * sizeof(MAPPING_PAIR); CurrentRetDescList = RetDescList = MmAllocRetrievelDescriptorList(PAIRS_PER_RUN);
CurrentRetDescList = RetDescList = ExAllocatePool(NonPagedPool, Size);
if (CurrentRetDescList == NULL) if (CurrentRetDescList == NULL)
{ {
@ -845,7 +860,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
ExtentCount += CurrentRetDescList->RetrievalPointers.NumberOfPairs; ExtentCount += CurrentRetDescList->RetrievalPointers.NumberOfPairs;
if ((ULONG)CurrentRetDescList->RetrievalPointers.Pair[CurrentRetDescList->RetrievalPointers.NumberOfPairs-1].Vcn < MaxVcn) if ((ULONG)CurrentRetDescList->RetrievalPointers.Pair[CurrentRetDescList->RetrievalPointers.NumberOfPairs-1].Vcn < MaxVcn)
{ {
CurrentRetDescList->Next = ExAllocatePool(NonPagedPool, Size); CurrentRetDescList->Next = MmAllocRetrievelDescriptorList(PAIRS_PER_RUN);
if (CurrentRetDescList->Next == NULL) if (CurrentRetDescList->Next == NULL)
{ {
while (RetDescList) while (RetDescList)
@ -881,6 +896,8 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
RtlZeroMemory(PagingFile, sizeof(*PagingFile));
PagingFile->FileObject = FileObject; PagingFile->FileObject = FileObject;
PagingFile->MaximumSize.QuadPart = MaximumSize->QuadPart; PagingFile->MaximumSize.QuadPart = MaximumSize->QuadPart;
PagingFile->CurrentSize.QuadPart = InitialSize->QuadPart; PagingFile->CurrentSize.QuadPart = InitialSize->QuadPart;
@ -924,6 +941,9 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
RtlZeroMemory(PagingFile->AllocMap, AllocMapSize * sizeof(ULONG));
RtlZeroMemory(PagingFile->RetrievalPointers, Size);
Count = 0; Count = 0;
PagingFile->RetrievalPointers->NumberOfPairs = ExtentCount; PagingFile->RetrievalPointers->NumberOfPairs = ExtentCount;
PagingFile->RetrievalPointers->StartVcn = RetDescList->RetrievalPointers.StartVcn; PagingFile->RetrievalPointers->StartVcn = RetDescList->RetrievalPointers.StartVcn;

View file

@ -1,4 +1,4 @@
/* $Id: ppool.c,v 1.25 2004/02/15 19:03:29 hbirr Exp $ /* $Id: ppool.c,v 1.26 2004/03/04 00:07:02 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -406,8 +406,7 @@ ExAllocatePagedPoolWithTag (IN POOL_TYPE PoolType,
ExReleaseFastMutex(&MmPagedPoolLock); ExReleaseFastMutex(&MmPagedPoolLock);
BlockAddress = block_to_address ( NewBlock ); BlockAddress = block_to_address ( NewBlock );
/* RtlZeroMemory(BlockAddress, NumberOfBytes);*/
memset(BlockAddress, 0, NumberOfBytes);
#if MM_PPOOL_REDZONE_BYTES #if MM_PPOOL_REDZONE_BYTES
NewBlock->UserSize = NumberOfBytes; NewBlock->UserSize = NumberOfBytes;

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: section.c,v 1.144 2004/01/31 00:16:55 hbirr Exp $ /* $Id: section.c,v 1.145 2004/03/04 00:07:02 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c * FILE: ntoskrnl/mm/section.c
@ -2328,9 +2328,13 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
Segment->FileOffset = 0; Segment->FileOffset = 0;
Segment->Protection = SectionPageProtection; Segment->Protection = SectionPageProtection;
Segment->Attributes = AllocationAttributes; Segment->Attributes = AllocationAttributes;
Segment->Length = MaximumSize.u.LowPart; Segment->RawLength = MaximumSize.u.LowPart;
Segment->Length = PAGE_ROUND_UP(MaximumSize.u.LowPart);
Segment->Flags = MM_PAGEFILE_SEGMENT; Segment->Flags = MM_PAGEFILE_SEGMENT;
Segment->WriteCopy = FALSE; Segment->WriteCopy = FALSE;
RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
Segment->VirtualAddress = 0;
Segment->Characteristics = 0;
ObDereferenceObject(Section); ObDereferenceObject(Section);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -2564,6 +2568,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
Segment->Length = PAGE_ROUND_UP(Segment->RawLength); Segment->Length = PAGE_ROUND_UP(Segment->RawLength);
} }
Segment->VirtualAddress = NULL; Segment->VirtualAddress = NULL;
RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
} }
else else
{ {
@ -2888,7 +2893,9 @@ MmCreateImageSection(PHANDLE SectionHandle,
SectionSegments[0].ReferenceCount = 1; SectionSegments[0].ReferenceCount = 1;
SectionSegments[0].VirtualAddress = 0; SectionSegments[0].VirtualAddress = 0;
SectionSegments[0].WriteCopy = TRUE; SectionSegments[0].WriteCopy = TRUE;
SectionSegments[0].Attributes = 0;
ExInitializeFastMutex(&SectionSegments[0].Lock); ExInitializeFastMutex(&SectionSegments[0].Lock);
RtlZeroMemory(&SectionSegments[0].PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
for (i = 1; i < NrSegments; i++) for (i = 1; i < NrSegments; i++)
{ {
SectionSegments[i].FileOffset = ImageSections[i-1].PointerToRawData; SectionSegments[i].FileOffset = ImageSections[i-1].PointerToRawData;
@ -2950,6 +2957,7 @@ MmCreateImageSection(PHANDLE SectionHandle,
SectionSegments[i].ReferenceCount = 1; SectionSegments[i].ReferenceCount = 1;
SectionSegments[i].VirtualAddress = (PVOID)ImageSections[i-1].VirtualAddress; SectionSegments[i].VirtualAddress = (PVOID)ImageSections[i-1].VirtualAddress;
ExInitializeFastMutex(&SectionSegments[i].Lock); ExInitializeFastMutex(&SectionSegments[i].Lock);
RtlZeroMemory(&SectionSegments[i].PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
} }
if (0 != InterlockedCompareExchange((PLONG)&FileObject->SectionObjectPointer->ImageSectionObject, if (0 != InterlockedCompareExchange((PLONG)&FileObject->SectionObjectPointer->ImageSectionObject,
(LONG)ImageSectionObject, 0)) (LONG)ImageSectionObject, 0))

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: slab.c,v 1.10 2003/12/30 18:52:05 fireball Exp $ /* $Id: slab.c,v 1.11 2004/03/04 00:07:02 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -93,6 +93,7 @@ ExCreateSlabCache(PUNICODE_STRING Name, ULONG Size, ULONG Align,
Slab->ObjectSize = ObjectSize + AlignSize; Slab->ObjectSize = ObjectSize + AlignSize;
Slab->ObjectsPerPage = Slab->ObjectsPerPage =
(PAGE_SIZE - sizeof(SLAB_CACHE_PAGE)) / Slab->ObjectSize; (PAGE_SIZE - sizeof(SLAB_CACHE_PAGE)) / Slab->ObjectSize;
Slab->FirstFreePage = NULL;
InitializeListHead(&Slab->PageListHead); InitializeListHead(&Slab->PageListHead);
KeInitializeSpinLock(&Slab->SlabLock); KeInitializeSpinLock(&Slab->SlabLock);

View file

@ -1,4 +1,4 @@
/* $Id: object.c,v 1.74 2004/01/31 16:52:47 ekohl Exp $ /* $Id: object.c,v 1.75 2004/03/04 00:07:02 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -377,6 +377,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
Type->Tag); Type->Tag);
if (Header == NULL) if (Header == NULL)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
RtlZeroMemory(Header, OBJECT_ALLOC_SIZE(ObjectSize));
/* Initialize the object header */ /* Initialize the object header */
Header->HandleCount = 0; Header->HandleCount = 0;

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.78 2004/02/24 13:27:03 weiden Exp $ */ /* $Id: text.c,v 1.79 2004/03/04 00:07:03 navaraf Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
@ -253,6 +253,7 @@ BOOL FASTCALL InitFontSupport(VOID)
PFILE_DIRECTORY_INFORMATION iFileData; PFILE_DIRECTORY_INFORMATION iFileData;
PVOID pBuff; PVOID pBuff;
BOOLEAN bRestartScan = TRUE; BOOLEAN bRestartScan = TRUE;
BOOLEAN Result = FALSE;
InitializeListHead(&FontListHead); InitializeListHead(&FontListHead);
ExInitializeFastMutex(&FontListLock); ExInitializeFastMutex(&FontListLock);
@ -281,13 +282,22 @@ BOOL FASTCALL InitFontSupport(VOID)
{ {
while(1) while(1)
{ {
iFileData = NULL; if (bRestartScan)
{
pBuff = ExAllocatePool(NonPagedPool,0x4000); pBuff = ExAllocatePool(NonPagedPool,0x4000);
if (pBuff == NULL)
{
break;
}
RtlInitUnicodeString(&cchFilename,0); RtlInitUnicodeString(&cchFilename,0);
cchFilename.MaximumLength = 0x1000; cchFilename.MaximumLength = 0x1000;
cchFilename.Buffer = ExAllocatePoolWithTag(PagedPool,cchFilename.MaximumLength, TAG_STRING); cchFilename.Buffer = ExAllocatePoolWithTag(PagedPool,cchFilename.MaximumLength, TAG_STRING);
if (cchFilename.Buffer == NULL)
cchFilename.Length = 0; {
ExFreePool(pBuff);
break;
}
}
Status = NtQueryDirectoryFile( hDirectory, Status = NtQueryDirectoryFile( hDirectory,
NULL, NULL,
@ -297,33 +307,41 @@ BOOL FASTCALL InitFontSupport(VOID)
pBuff, pBuff,
0x4000, 0x4000,
FileDirectoryInformation, FileDirectoryInformation,
TRUE, FALSE,
&cchSearchPattern, &cchSearchPattern,
bRestartScan ); bRestartScan );
iFileData = (PFILE_DIRECTORY_INFORMATION)pBuff;
RtlAppendUnicodeToString(&cchFilename, cchDir.Buffer);
RtlAppendUnicodeToString(&cchFilename, iFileData->FileName);
RtlAppendUnicodeToString(&cchFilename, L"\0");
if( !NT_SUCCESS(Status) || Status == STATUS_NO_MORE_FILES ) if( !NT_SUCCESS(Status) || Status == STATUS_NO_MORE_FILES )
break; {
IntGdiAddFontResource(&cchFilename, 0);
ExFreePool(pBuff); ExFreePool(pBuff);
ExFreePool(cchFilename.Buffer); ExFreePool(cchFilename.Buffer);
break;
}
bRestartScan = FALSE; bRestartScan = FALSE;
iFileData = (PFILE_DIRECTORY_INFORMATION)pBuff;
while(1)
{
UNICODE_STRING tmpString;
tmpString.Buffer = iFileData->FileName;
tmpString.Length = tmpString.MaximumLength = iFileData->FileNameLength;
RtlCopyUnicodeString(&cchFilename, &cchDir);
RtlAppendUnicodeStringToString(&cchFilename, &tmpString);
cchFilename.Buffer[cchFilename.Length / sizeof(WCHAR)] = 0;
if (0 != IntGdiAddFontResource(&cchFilename, 0))
{
Result = TRUE;
}
if (iFileData->NextEntryOffset == 0)
{
break;
}
iFileData = (PVOID)iFileData + iFileData->NextEntryOffset;
}
} }
ExFreePool(cchFilename.Buffer);
ExFreePool(pBuff);
ZwClose(hDirectory);
return TRUE;
} }
} }
ZwClose(hDirectory); ZwClose(hDirectory);
return FALSE; return Result;
} }
static NTSTATUS STDCALL static NTSTATUS STDCALL