Index: section.c =================================================================== --- ntoskrnl/mm/section.c (revision 68673) +++ ntoskrnl/mm/section.c (working copy) @@ -3236,6 +3236,11 @@ BufferSize = Length + OffsetAdjustment; BufferSize = PAGE_ROUND_UP(BufferSize); + CcFlushCache(FileObject->SectionObjectPointer, + &FileOffset, + BufferSize, + &Iosb); + /* * It's ok to use paged pool, because this is a temporary buffer only used in * the loading of executables. The assumption is that MmCreateSection is @@ -4210,13 +4215,10 @@ * and calculate the image base address */ for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Image.Characteristics & IMAGE_SCN_TYPE_NOLOAD)) + if (Segment == &SectionSegments[i]) { - if (Segment == &SectionSegments[i]) - { - ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].Image.VirtualAddress; - break; - } + ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].Image.VirtualAddress; + break; } } if (i >= NrSegments) @@ -4226,18 +4228,15 @@ for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Image.Characteristics & IMAGE_SCN_TYPE_NOLOAD)) + PVOID SBaseAddress = (PVOID) + ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress); + + Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress); + if (!NT_SUCCESS(Status)) { - PVOID SBaseAddress = (PVOID) - ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress); - - Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmUnmapViewOfSegment failed for %p (Process %p) with %lx\n", - SBaseAddress, Process, Status); - NT_ASSERT(NT_SUCCESS(Status)); - } + DPRINT1("MmUnmapViewOfSegment failed for %p (Process %p) with %lx\n", + SBaseAddress, Process, Status); + NT_ASSERT(NT_SUCCESS(Status)); } } } @@ -4514,13 +4513,10 @@ ImageSize = 0; for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Image.Characteristics & IMAGE_SCN_TYPE_NOLOAD)) - { - ULONG_PTR MaxExtent; - MaxExtent = (ULONG_PTR)(SectionSegments[i].Image.VirtualAddress + - SectionSegments[i].Length.QuadPart); - ImageSize = max(ImageSize, MaxExtent); - } + ULONG_PTR MaxExtent; + MaxExtent = (ULONG_PTR)(SectionSegments[i].Image.VirtualAddress + + SectionSegments[i].Length.QuadPart); + ImageSize = max(ImageSize, MaxExtent); } ImageSectionObject->ImageInformation.ImageFileSize = (ULONG)ImageSize; @@ -4564,25 +4560,22 @@ for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Image.Characteristics & IMAGE_SCN_TYPE_NOLOAD)) + PVOID SBaseAddress = (PVOID) + ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress); + MmLockSectionSegment(&SectionSegments[i]); + Status = MmMapViewOfSegment(AddressSpace, + Section, + &SectionSegments[i], + &SBaseAddress, + SectionSegments[i].Length.LowPart, + SectionSegments[i].Protection, + 0, + 0); + MmUnlockSectionSegment(&SectionSegments[i]); + if (!NT_SUCCESS(Status)) { - PVOID SBaseAddress = (PVOID) - ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress); - MmLockSectionSegment(&SectionSegments[i]); - Status = MmMapViewOfSegment(AddressSpace, - Section, - &SectionSegments[i], - &SBaseAddress, - SectionSegments[i].Length.LowPart, - SectionSegments[i].Protection, - 0, - 0); - MmUnlockSectionSegment(&SectionSegments[i]); - if (!NT_SUCCESS(Status)) - { - MmUnlockAddressSpace(AddressSpace); - return(Status); - } + MmUnlockAddressSpace(AddressSpace); + return(Status); } }