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,22 +534,38 @@ 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 )
Status = ZwMapViewOfSection(SectionHandle, { // only map section if it is initialized
ProcessHandle, Status = ZwMapViewOfSection(SectionHandle,
(PVOID*)&Base, ProcessHandle,
0, (PVOID*)&Base,
Size, 0,
&Offset, Size,
(PULONG)&Size, &Offset,
0, (PULONG)&Size,
MEM_COMMIT, 0,
PAGE_READWRITE); MEM_COMMIT,
if (!NT_SUCCESS(Status)) PAGE_READWRITE);
{ if (!NT_SUCCESS(Status))
DPRINT("Failed to map section"); {
return(Status); DPRINT1("Failed to map section");
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;
} }