Fixed kernel loader code also to handle uninitialized sections

svn path=/trunk/; revision=1561
This commit is contained in:
Phillip Susi 2001-01-24 04:43:54 +00:00
parent 207393f045
commit 89e2e7a616

View file

@ -187,21 +187,38 @@ NTSTATUS LdrpMapImage(HANDLE ProcessHandle,
Size = Sections[i].Misc.VirtualSize; Size = Sections[i].Misc.VirtualSize;
KeDetachProcess(); KeDetachProcess();
Status = ZwMapViewOfSection(SectionHandle, if( Offset.u.LowPart )
ProcessHandle, { // map the section if it is initialized
(PVOID *)&Base, Status = ZwMapViewOfSection(SectionHandle,
0, ProcessHandle,
Size, (PVOID *)&Base,
&Offset, 0,
(PULONG)&Size, Size,
0, &Offset,
MEM_COMMIT, (PULONG)&Size,
PAGE_READWRITE); 0,
if (!NT_SUCCESS(Status)) MEM_COMMIT,
{ PAGE_READWRITE);
DbgPrint("Image map view of secion failed (Status %x)\n", Status); if (!NT_SUCCESS(Status))
return(Status); {
DbgPrint("Image map view of secion failed (Status %x)\n", Status);
return(Status);
}
} }
else {
// allocate the section if it is uninitialized
Status = NtAllocateVirtualMemory( ProcessHandle,
(PVOID *)&Base,
0,
&Size,
MEM_COMMIT,
PAGE_READWRITE );
if( !NT_SUCCESS( Status ) )
{
DPRINT1( "Failed to allocate memory for uninitialized section\n" );
return Status;
}
}
} }
DPRINT("Returning\n"); DPRINT("Returning\n");