mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
changed program loader to map image into section
svn path=/trunk/; revision=192
This commit is contained in:
parent
a3232e28c6
commit
531f88e833
1 changed files with 36 additions and 12 deletions
|
@ -1079,22 +1079,45 @@ LdrProcessPEImage(HANDLE ProcessHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory in process for image */
|
/* Create the section for the code */
|
||||||
Module->Flags = MODULE_FLAG_PE;
|
Status = ZwCreateSection(&SectionHandle,
|
||||||
Module->Base = (PVOID) NTHeaders->OptionalHeader.ImageBase;
|
SECTION_ALL_ACCESS,
|
||||||
Module->Size = NTHeaders->OptionalHeader.SizeOfImage;
|
NULL,
|
||||||
Status = ZwAllocateVirtualMemory(ProcessHandle,
|
NULL,
|
||||||
&Module->Base,
|
PAGE_READWRITE,
|
||||||
0,
|
MEM_COMMIT,
|
||||||
NULL,
|
FileHandle);
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ExFreePool(DosHeader);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Map the Image into the process */
|
||||||
|
Module->Flags = MODULE_FLAG_PE;
|
||||||
|
Module->Base = (PVOID) NTHeaders->OptionalHeader.ImageBase;
|
||||||
|
Module->Size = NTHeaders->OptionalHeader.SizeOfImage;
|
||||||
|
Status = ZwMapViewOfSection(SectionHandle,
|
||||||
|
ProcessHandle,
|
||||||
|
&Module->Base,
|
||||||
|
0,
|
||||||
|
Module->Size,
|
||||||
|
NULL,
|
||||||
|
&Module->Size,
|
||||||
|
0,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* FIXME: destroy the section here */
|
||||||
|
ExFreePool(DosHeader);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: create stack and other BSS sections */
|
||||||
|
/* FIXME: if actual load address is different from ImageBase, then reloc */
|
||||||
|
/* FIXME: do import fixups/load required libraries */
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Load headers into virtual memory */
|
/* Load headers into virtual memory */
|
||||||
Status = ZwReadFile(FileHandle,
|
Status = ZwReadFile(FileHandle,
|
||||||
NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL,
|
||||||
|
@ -1321,7 +1344,8 @@ LdrProcessPEImage(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* FIXME: Create the stack for the process */
|
/* FIXME: Create the stack for the process */
|
||||||
/* FIXME: Setup the context for the initial thread */
|
/* FIXME: Setup the context for the initial thread */
|
||||||
/* FIXME: Create the initial thread */
|
/* FIXME: Create the initial thread */
|
||||||
|
|
Loading…
Reference in a new issue