Fixed loader bug with uninitialized sections

svn path=/trunk/; revision=1557
This commit is contained in:
Phillip Susi 2001-01-23 04:37:13 +00:00
parent e6c8459347
commit b6593ffc1b

View file

@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.35 2000/12/07 17:00:12 jean Exp $ /* $Id: utils.c,v 1.36 2001/01/23 04:37:13 phreak Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -534,7 +534,8 @@ NTSTATUS LdrMapSections(HANDLE ProcessHandle,
DPRINT("Mapping section %d offset %x base %x size %x\n", DPRINT("Mapping section %d offset %x base %x size %x\n",
i, Offset.u.LowPart, Base, Sections[i].Misc.VirtualSize); i, Offset.u.LowPart, Base, Sections[i].Misc.VirtualSize);
DPRINT("Size %x\n", Sections[i].SizeOfRawData); DPRINT("Size %x\n", Sections[i].SizeOfRawData);
if( Offset.u.LowPart )
{ // only map section if it is initialized
Status = ZwMapViewOfSection(SectionHandle, Status = ZwMapViewOfSection(SectionHandle,
ProcessHandle, ProcessHandle,
(PVOID*)&Base, (PVOID*)&Base,
@ -547,10 +548,25 @@ NTSTATUS LdrMapSections(HANDLE ProcessHandle,
PAGE_READWRITE); PAGE_READWRITE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Failed to map section"); DPRINT1("Failed to map section");
return(Status); return(Status);
} }
} }
else {
// allocate pure memory for uninitialized section
Status = NtAllocateVirtualMemory( NtCurrentProcess(),
(PVOID *)&Base,
0,
&Size,
MEM_COMMIT,
PAGE_READWRITE );
if( !NT_SUCCESS( Status ) )
{
DPRINT1( "Failed to allocate memory for uninitialized section\n" );
return Status;
}
}
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }