diff --git a/reactos/ntoskrnl/io/buildirp.c b/reactos/ntoskrnl/io/buildirp.c index 7aecbb897a7..41abe6ab5a9 100644 --- a/reactos/ntoskrnl/io/buildirp.c +++ b/reactos/ntoskrnl/io/buildirp.c @@ -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 * PROJECT: ReactOS kernel @@ -259,6 +259,13 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode, RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, InputBuffer, InputBufferLength); + RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer + InputBufferLength, + BufferLength - InputBufferLength); + } + else + { + RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, + BufferLength); } Irp->UserBuffer = OutputBuffer; break; @@ -273,12 +280,13 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode, ExAllocatePoolWithTag(NonPagedPool,OutputBufferLength, TAG_SYS_BUF); - if (Irp->AssociatedIrp.SystemBuffer == NULL) { IoFreeIrp(Irp); return(NULL); } + + RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, OutputBufferLength); Irp->UserBuffer = OutputBuffer; } diff --git a/reactos/ntoskrnl/io/irp.c b/reactos/ntoskrnl/io/irp.c index ddd1a2a7f90..d720f007cce 100644 --- a/reactos/ntoskrnl/io/irp.c +++ b/reactos/ntoskrnl/io/irp.c @@ -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 * PROJECT: ReactOS kernel @@ -200,6 +200,7 @@ IoAllocateIrp(CCHAR StackSize, return(NULL); } + RtlZeroMemory(Irp, IoSizeOfIrp(StackSize)); IoInitializeIrp(Irp, IoSizeOfIrp(StackSize), StackSize); diff --git a/reactos/ntoskrnl/mm/aspace.c b/reactos/ntoskrnl/mm/aspace.c index 0e599859a1f..c2df1d76790 100644 --- a/reactos/ntoskrnl/mm/aspace.c +++ b/reactos/ntoskrnl/mm/aspace.c @@ -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 * PROJECT: ReactOS kernel @@ -88,6 +88,7 @@ MmInitializeAddressSpace(PEPROCESS Process, AddressSpace->PageTableRefCountTable = ExAllocatePoolWithTag(NonPagedPool, 768 * sizeof(USHORT), TAG_PTRC); + RtlZeroMemory(AddressSpace->PageTableRefCountTable, 768 * sizeof(USHORT)); AddressSpace->PageTableRefCountTableSize = 768; } else diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index d50d805c39e..4e4d651e04e 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -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 * PROJECT: ReactOS kernel @@ -1633,7 +1633,7 @@ ExAllocateNonPagedPoolWithTag(ULONG Type, ULONG Size, ULONG Tag, PVOID Caller) #endif KeReleaseSpinLock(&MmNpoolLock, oldIrql); block = block_to_address(best); - memset(block,0,Size); +/* RtlZeroMemory(block, Size);*/ return(block); #endif /* WHOLE_PAGE_ALLOCATIONS */ } diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 3200ec79631..e205f72c9cb 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * 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 * FILE: ntoskrnl/mm/pagefile.c @@ -453,6 +453,22 @@ MmAllocSwapPage(VOID) 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 MmDumpToPagingFile(ULONG BugCode, ULONG BugCodeParameter1, @@ -716,7 +732,6 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, PPAGINGFILE PagingFile; KIRQL oldIrql; ULONG AllocMapSize; - ULONG Size; FILE_FS_SIZE_INFORMATION FsSizeInformation; PRETRIEVEL_DESCRIPTOR_LIST RetDescList; PRETRIEVEL_DESCRIPTOR_LIST CurrentRetDescList; @@ -726,6 +741,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, ULONG ExtentCount; ULONG MaxVcn; ULONG Count; + ULONG Size; DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n", FileName, InitialSize->QuadPart); @@ -801,8 +817,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, return(Status); } - Size = sizeof(RETRIEVEL_DESCRIPTOR_LIST) + PAIRS_PER_RUN * sizeof(MAPPING_PAIR); - CurrentRetDescList = RetDescList = ExAllocatePool(NonPagedPool, Size); + CurrentRetDescList = RetDescList = MmAllocRetrievelDescriptorList(PAIRS_PER_RUN); if (CurrentRetDescList == NULL) { @@ -845,7 +860,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, ExtentCount += CurrentRetDescList->RetrievalPointers.NumberOfPairs; 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) { while (RetDescList) @@ -881,6 +896,8 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, return(STATUS_NO_MEMORY); } + RtlZeroMemory(PagingFile, sizeof(*PagingFile)); + PagingFile->FileObject = FileObject; PagingFile->MaximumSize.QuadPart = MaximumSize->QuadPart; PagingFile->CurrentSize.QuadPart = InitialSize->QuadPart; @@ -924,6 +941,9 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, return(STATUS_NO_MEMORY); } + RtlZeroMemory(PagingFile->AllocMap, AllocMapSize * sizeof(ULONG)); + RtlZeroMemory(PagingFile->RetrievalPointers, Size); + Count = 0; PagingFile->RetrievalPointers->NumberOfPairs = ExtentCount; PagingFile->RetrievalPointers->StartVcn = RetDescList->RetrievalPointers.StartVcn; diff --git a/reactos/ntoskrnl/mm/ppool.c b/reactos/ntoskrnl/mm/ppool.c index 45ce5492777..137bec2669b 100644 --- a/reactos/ntoskrnl/mm/ppool.c +++ b/reactos/ntoskrnl/mm/ppool.c @@ -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 * PROJECT: ReactOS kernel @@ -406,8 +406,7 @@ ExAllocatePagedPoolWithTag (IN POOL_TYPE PoolType, ExReleaseFastMutex(&MmPagedPoolLock); BlockAddress = block_to_address ( NewBlock ); - - memset(BlockAddress, 0, NumberOfBytes); +/* RtlZeroMemory(BlockAddress, NumberOfBytes);*/ #if MM_PPOOL_REDZONE_BYTES NewBlock->UserSize = NumberOfBytes; diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 98cb0f298e6..d08dbff15ee 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * 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 * FILE: ntoskrnl/mm/section.c @@ -2328,9 +2328,13 @@ MmCreatePageFileSection(PHANDLE SectionHandle, Segment->FileOffset = 0; Segment->Protection = SectionPageProtection; 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->WriteCopy = FALSE; + RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY)); + Segment->VirtualAddress = 0; + Segment->Characteristics = 0; ObDereferenceObject(Section); return(STATUS_SUCCESS); } @@ -2564,6 +2568,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle, Segment->Length = PAGE_ROUND_UP(Segment->RawLength); } Segment->VirtualAddress = NULL; + RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY)); } else { @@ -2888,7 +2893,9 @@ MmCreateImageSection(PHANDLE SectionHandle, SectionSegments[0].ReferenceCount = 1; SectionSegments[0].VirtualAddress = 0; SectionSegments[0].WriteCopy = TRUE; + SectionSegments[0].Attributes = 0; ExInitializeFastMutex(&SectionSegments[0].Lock); + RtlZeroMemory(&SectionSegments[0].PageDirectory, sizeof(SECTION_PAGE_DIRECTORY)); for (i = 1; i < NrSegments; i++) { SectionSegments[i].FileOffset = ImageSections[i-1].PointerToRawData; @@ -2950,6 +2957,7 @@ MmCreateImageSection(PHANDLE SectionHandle, SectionSegments[i].ReferenceCount = 1; SectionSegments[i].VirtualAddress = (PVOID)ImageSections[i-1].VirtualAddress; ExInitializeFastMutex(&SectionSegments[i].Lock); + RtlZeroMemory(&SectionSegments[i].PageDirectory, sizeof(SECTION_PAGE_DIRECTORY)); } if (0 != InterlockedCompareExchange((PLONG)&FileObject->SectionObjectPointer->ImageSectionObject, (LONG)ImageSectionObject, 0)) diff --git a/reactos/ntoskrnl/mm/slab.c b/reactos/ntoskrnl/mm/slab.c index 19f83f7d4ff..e34233df690 100644 --- a/reactos/ntoskrnl/mm/slab.c +++ b/reactos/ntoskrnl/mm/slab.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * 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 * PROJECT: ReactOS kernel @@ -93,6 +93,7 @@ ExCreateSlabCache(PUNICODE_STRING Name, ULONG Size, ULONG Align, Slab->ObjectSize = ObjectSize + AlignSize; Slab->ObjectsPerPage = (PAGE_SIZE - sizeof(SLAB_CACHE_PAGE)) / Slab->ObjectSize; + Slab->FirstFreePage = NULL; InitializeListHead(&Slab->PageListHead); KeInitializeSpinLock(&Slab->SlabLock); diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 6e8b3990eb0..efc49b0751d 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -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 * PROJECT: ReactOS kernel @@ -377,6 +377,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, Type->Tag); if (Header == NULL) return STATUS_INSUFFICIENT_RESOURCES; + RtlZeroMemory(Header, OBJECT_ALLOC_SIZE(ObjectSize)); /* Initialize the object header */ Header->HandleCount = 0; diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index d8c44b7e09b..cf8bcff99de 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * 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 @@ -253,6 +253,7 @@ BOOL FASTCALL InitFontSupport(VOID) PFILE_DIRECTORY_INFORMATION iFileData; PVOID pBuff; BOOLEAN bRestartScan = TRUE; + BOOLEAN Result = FALSE; InitializeListHead(&FontListHead); ExInitializeFastMutex(&FontListLock); @@ -281,13 +282,22 @@ BOOL FASTCALL InitFontSupport(VOID) { while(1) { - iFileData = NULL; + if (bRestartScan) + { pBuff = ExAllocatePool(NonPagedPool,0x4000); + if (pBuff == NULL) + { + break; + } RtlInitUnicodeString(&cchFilename,0); cchFilename.MaximumLength = 0x1000; cchFilename.Buffer = ExAllocatePoolWithTag(PagedPool,cchFilename.MaximumLength, TAG_STRING); - - cchFilename.Length = 0; + if (cchFilename.Buffer == NULL) + { + ExFreePool(pBuff); + break; + } + } Status = NtQueryDirectoryFile( hDirectory, NULL, @@ -297,33 +307,41 @@ BOOL FASTCALL InitFontSupport(VOID) pBuff, 0x4000, FileDirectoryInformation, - TRUE, + FALSE, &cchSearchPattern, 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 ) - break; - - IntGdiAddFontResource(&cchFilename, 0); + { ExFreePool(pBuff); ExFreePool(cchFilename.Buffer); + break; + } 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); - return FALSE; + return Result; } static NTSTATUS STDCALL