mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
general bug fix changes
svn path=/trunk/; revision=49
This commit is contained in:
parent
22ebf085eb
commit
5c0fb0f108
2 changed files with 100 additions and 9 deletions
|
@ -132,7 +132,7 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
DbgPrint("Starting ReactOS "KERNEL_VERSION"\n");
|
DbgPrint("Starting ReactOS "KERNEL_VERSION"\n");
|
||||||
|
|
||||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||||
if (start <= ((int)&end))
|
if (start < ((int)&end))
|
||||||
{
|
{
|
||||||
DbgPrint("Kernel booted incorrectly, aborting\n");
|
DbgPrint("Kernel booted incorrectly, aborting\n");
|
||||||
for(;;);
|
for(;;);
|
||||||
|
|
|
@ -21,14 +21,17 @@
|
||||||
|
|
||||||
NTSTATUS LdrProcessImage(HANDLE SectionHandle, PVOID BaseAddress)
|
NTSTATUS LdrProcessImage(HANDLE SectionHandle, PVOID BaseAddress)
|
||||||
{
|
{
|
||||||
PIMAGE_DOS_HEADER dos_hdr = (PIMAGE_DOS_HEADER)BaseAddress;
|
PIMAGE_DOS_HEADER dos_hdr = (PIMAGE_DOS_HEADER)BaseAddress;
|
||||||
PIMAGE_NT_HEADERS hdr = (PIMAGE_NT_HEADERS)(BaseAddress
|
PIMAGE_NT_HEADERS hdr = (PIMAGE_NT_HEADERS)(BaseAddress
|
||||||
+ dos_hdr->e_lfanew);
|
+ dos_hdr->e_lfanew);
|
||||||
PIMAGE_SECTION_HEADER sections = (PIMAGE_SECTION_HEADER)(BaseAddress
|
PIMAGE_SECTION_HEADER sections = (PIMAGE_SECTION_HEADER)(BaseAddress
|
||||||
+ dos_hdr->e_lfanew
|
+ dos_hdr->e_lfanew + sizeof(IMAGE_NT_HEADERS));
|
||||||
+ sizeof(IMAGE_NT_HEADERS));
|
|
||||||
|
// FIXME: Check image signature
|
||||||
|
// FIXME: Check architechture
|
||||||
|
// FIXME: Build/Load image sections
|
||||||
|
// FIXME: resolve imports
|
||||||
|
// FIXME: do fixups
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +43,47 @@ NTSTATUS LdrLoadDriver(PUNICODE_STRING FileName)
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
HANDLE FileHandle;
|
||||||
|
HANDLE SectionHandle;
|
||||||
|
ANSI_STRING AnsiFileName;
|
||||||
|
UNICODE_STRING UnicodeFileName;
|
||||||
|
OBJECT_ATTRIBUTES FileAttributes;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
|
||||||
|
// Open the image file or die
|
||||||
|
RtlInitAnsiString(&AnsiFileName, FileName);
|
||||||
|
RtlAnsiStringToUnicodeString(&UnicodeFileName, &AnsiFileName, TRUE);
|
||||||
|
InitializeObjectAttributes(&FileAttributes,
|
||||||
|
&UnicodeFileName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
FileHandle = ZwFileOpen(&FileHandle, 0, &FileAttributes, NULL, 0, 0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
RtlFreeUnicodeString(&UnicodeFileName);
|
||||||
|
|
||||||
|
// Map the image into a section or die
|
||||||
|
Status = ZwCreateSection(&SectionHandle,
|
||||||
|
SECTION_MAP_READ,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
PAGE_READONLY,
|
||||||
|
SEC_IMAGE,
|
||||||
|
FileHandle);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: get the base address of the section
|
||||||
|
|
||||||
|
ZwCloseFile(FileHandle);
|
||||||
|
|
||||||
|
return LdrProcessImage(SectionHandle, BaseAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS LdrLoadImage(PUNICODE_STRING FileName)
|
NTSTATUS LdrLoadImage(PUNICODE_STRING FileName)
|
||||||
|
@ -50,4 +94,51 @@ NTSTATUS LdrLoadImage(PUNICODE_STRING FileName)
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
HANDLE FileHandle;
|
||||||
|
HANDLE SectionHandle;
|
||||||
|
ANSI_STRING AnsiFileName;
|
||||||
|
UNICODE_STRING UnicodeFileName;
|
||||||
|
OBJECT_ATTRIBUTES FileAttributes;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
|
||||||
|
// Open the image file or die
|
||||||
|
RtlInitAnsiString(&AnsiFileName, FileName);
|
||||||
|
RtlAnsiStringToUnicodeString(&UnicodeFileName, &AnsiFileName, TRUE);
|
||||||
|
InitializeObjectAttributes(&FileAttributes,
|
||||||
|
&UnicodeFileName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
FileHandle = ZwFileOpen(&FileHandle, 0, &FileAttributes, NULL, 0, 0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
RtlFreeUnicodeString(&UnicodeFileName);
|
||||||
|
|
||||||
|
// FIXME: should DLLs be named sections?
|
||||||
|
// FIXME: get current process and associate with section
|
||||||
|
|
||||||
|
// Map the image into a section or die
|
||||||
|
Status = ZwCreateSection(&SectionHandle,
|
||||||
|
SECTION_MAP_READ,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
PAGE_READONLY,
|
||||||
|
SEC_IMAGE,
|
||||||
|
FileHandle);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: get the base address of the section
|
||||||
|
|
||||||
|
ZwCloseFile(FileHandle);
|
||||||
|
|
||||||
|
// FIXME: initialize process context for image
|
||||||
|
|
||||||
|
return LdrProcessImage(SectionHandle, BaseAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue