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,6 +187,8 @@ NTSTATUS LdrpMapImage(HANDLE ProcessHandle,
Size = Sections[i].Misc.VirtualSize; Size = Sections[i].Misc.VirtualSize;
KeDetachProcess(); KeDetachProcess();
if( Offset.u.LowPart )
{ // map the section if it is initialized
Status = ZwMapViewOfSection(SectionHandle, Status = ZwMapViewOfSection(SectionHandle,
ProcessHandle, ProcessHandle,
(PVOID *)&Base, (PVOID *)&Base,
@ -203,6 +205,21 @@ NTSTATUS LdrpMapImage(HANDLE ProcessHandle,
return(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");
*ReturnedImageBase = ImageBase; *ReturnedImageBase = ImageBase;