mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 12:17:30 +00:00
Zero-fill initialized data not contained in image file
svn path=/trunk/; revision=4496
This commit is contained in:
parent
2aab2423c2
commit
4f133928b7
1 changed files with 27 additions and 4 deletions
|
@ -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.104 2003/02/13 22:24:18 hbirr Exp $
|
/* $Id: section.c,v 1.105 2003/04/05 13:19:05 gvg Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/section.c
|
* FILE: ntoskrnl/mm/section.c
|
||||||
|
@ -3374,7 +3374,6 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
Section = (PSECTION_OBJECT)SectionObject;
|
Section = (PSECTION_OBJECT)SectionObject;
|
||||||
AddressSpace = &Process->AddressSpace;
|
AddressSpace = &Process->AddressSpace;
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
|
||||||
MmLockSection(SectionObject);
|
MmLockSection(SectionObject);
|
||||||
|
|
||||||
if (Section->AllocationAttributes & SEC_IMAGE)
|
if (Section->AllocationAttributes & SEC_IMAGE)
|
||||||
|
@ -3383,6 +3382,8 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
PVOID ImageBase;
|
PVOID ImageBase;
|
||||||
ULONG ImageSize;
|
ULONG ImageSize;
|
||||||
|
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
ImageBase = *BaseAddress;
|
ImageBase = *BaseAddress;
|
||||||
if (ImageBase == NULL)
|
if (ImageBase == NULL)
|
||||||
{
|
{
|
||||||
|
@ -3449,10 +3450,32 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*BaseAddress = ImageBase;
|
*BaseAddress = ImageBase;
|
||||||
|
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Zero-fill the end of initialized data segments which are not completely
|
||||||
|
* present in the file
|
||||||
|
*/
|
||||||
|
for (i = 0; i < Section->NrSegments; i++)
|
||||||
|
{
|
||||||
|
if (IMAGE_SECTION_INITIALIZED_DATA ==
|
||||||
|
(Section->Segments[i].Characteristics &
|
||||||
|
(IMAGE_SECTION_NOLOAD | IMAGE_SECTION_INITIALIZED_DATA)) &&
|
||||||
|
Section->Segments[i].RawLength < Section->Segments[i].Length)
|
||||||
|
{
|
||||||
|
RtlZeroMemory((PVOID) (ImageBase + (ULONG_PTR) Section->Segments[i].VirtualAddress) +
|
||||||
|
Section->Segments[i].RawLength,
|
||||||
|
Section->Segments[i].Length - Section->Segments[i].RawLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
if (SectionOffset == NULL)
|
if (SectionOffset == NULL)
|
||||||
{
|
{
|
||||||
ViewOffset = 0;
|
ViewOffset = 0;
|
||||||
|
@ -3488,16 +3511,16 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
Protect,
|
Protect,
|
||||||
ViewOffset);
|
ViewOffset);
|
||||||
MmUnlockSectionSegment(Section->Segments);
|
MmUnlockSectionSegment(Section->Segments);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue