Fixed the mapping for low alignment images. Modified: trunk/reactos/ntoskrnl/mm/section.c _____
Modified: trunk/reactos/ntoskrnl/mm/section.c --- trunk/reactos/ntoskrnl/mm/section.c 2005-10-22 15:10:03 UTC (rev 18678) +++ trunk/reactos/ntoskrnl/mm/section.c 2005-10-22 15:11:55 UTC (rev 18679) @@ -1747,7 +1747,7 @@
* memory area was mapped at an offset in the file which is page aligned * then note this is a direct mapped page. */ - if ((Offset + MemoryArea->Data.SectionData.ViewOffset % PAGE_SIZE) == 0 && + if (((Offset + Segment->FileOffset) % PAGE_SIZE) == 0 && (Offset + PAGE_SIZE <= Segment->RawLength || !IsImageSection)) { DirectMapped = TRUE; @@ -2813,6 +2813,7 @@ ULONG i; ULONG LastSegment; BOOLEAN Initialized; + PMM_SECTION_SEGMENT EffectiveSegment;
if (Flags & EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED) { @@ -2822,11 +2823,10 @@
Initialized = FALSE; LastSegment = 0; + EffectiveSegment = &ImageSectionObject->Segments[LastSegment];
for ( i = 0; i < ImageSectionObject->NrSegments; ++ i ) { - PMM_SECTION_SEGMENT EffectiveSegment = &ImageSectionObject->Segments[LastSegment]; - /* * The first segment requires special handling */ @@ -2880,11 +2880,14 @@
EffectiveSegment = &ImageSectionObject->Segments[LastSegment];
- /* - * Copy the current segment. If necessary, the effective segment - * will be expanded later - */ - *EffectiveSegment = *Segment; + if (LastSegment != i) + { + /* + * Copy the current segment. If necessary, the effective segment + * will be expanded later + */ + *EffectiveSegment = *Segment; + }
/* * Page-align the virtual size. We know for sure the virtual address @@ -2937,7 +2940,7 @@ /* * Extend the virtual size */ - ASSERT(PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) > EndOfEffectiveSegment); + ASSERT(PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) >= EndOfEffectiveSegment);
EffectiveSegment->Length = PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) -
EffectiveSegment->VirtualAddress; @@ -2981,6 +2984,7 @@ } } } + ImageSectionObject->NrSegments = LastSegment + 1;
return TRUE; }