Author: tfaber Date: Wed Feb 20 21:48:05 2013 New Revision: 58344
URL: http://svn.reactos.org/svn/reactos?rev=58344&view=rev Log: [NTOSKRNL:MM] - Do not assume all zeroes in PE sections that contain uninitialized data. Such sections can have other contents as well, and MiReadPage already provides zeroes for outside-of-file data anyway CORE-6958 #resolve
Modified: trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/mm/section.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=5... ============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Wed Feb 20 21:48:05 2013 @@ -677,6 +677,7 @@ pssSegments[i].Length.QuadPart = pishSectionHeaders[i].Misc.VirtualSize;
pssSegments[i].Length.LowPart = ALIGN_UP_BY(pssSegments[i].Length.LowPart, nSectionAlignment); + /* FIXME: always false */ if (pssSegments[i].Length.QuadPart < pssSegments[i].Length.QuadPart) DIE(("Cannot align the virtual size of section %u\n", i));
@@ -1394,52 +1395,6 @@ }
/* - * Map anonymous memory for BSS sections - */ - if (Segment->Image.Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) - { - /* We'll be unlocking the address space below. Prevent us from being preempted - * in faulting in the page. */ - MmCreatePageFileMapping(Process, Address, MM_WAIT_ENTRY); - MmUnlockSectionSegment(Segment); - MI_SET_USAGE(MI_USAGE_SECTION); - if (Process) MI_SET_PROCESS2(Process->ImageFileName); - if (!Process) MI_SET_PROCESS2("Kernel Section"); - Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page); - if (!NT_SUCCESS(Status)) - { - MmUnlockAddressSpace(AddressSpace); - Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page); - MmLockAddressSpace(AddressSpace); - } - if (!NT_SUCCESS(Status)) - { - KeBugCheck(MEMORY_MANAGEMENT); - } - /* Remove the wait entry we placed, so that we can map the page */ - MmDeletePageFileMapping(Process, PAddress, &SwapEntry); - Status = MmCreateVirtualMapping(Process, - PAddress, - Region->Protect, - &Page, - 1); - if (!NT_SUCCESS(Status)) - { - DPRINT("MmCreateVirtualMapping failed, not out of memory\n"); - KeBugCheck(MEMORY_MANAGEMENT); - return(Status); - } - MmInsertRmap(Page, Process, Address); - - /* - * Cleanup and release locks - */ - MiSetPageEvent(Process, Address); - DPRINT("Address 0x%.8X\n", Address); - return(STATUS_SUCCESS); - } - - /* * Get the entry corresponding to the offset within the section */ Entry = MmGetPageEntrySectionSegment(Segment, &Offset); @@ -1508,7 +1463,7 @@ MmUnlockSectionSegment(Segment);
MmDeletePageFileMapping(Process, PAddress, &FakeSwapEntry); - DPRINT("CreateVirtualMapping Page %x Process %p PAddress %p Attributes %x\n", + DPRINT("CreateVirtualMapping Page %x Process %p PAddress %p Attributes %x\n", Page, Process, PAddress, Attributes); Status = MmCreateVirtualMapping(Process, PAddress, @@ -2058,7 +2013,7 @@ Address); KeBugCheckEx(MEMORY_MANAGEMENT, SwapEntry, Page, (ULONG_PTR)Process, (ULONG_PTR)Address); } - MmReleasePageMemoryConsumer(MC_USER, Page); + MmReleasePageMemoryConsumer(MC_USER, Page); MiSetPageEvent(NULL, NULL); return(STATUS_SUCCESS); }