general bug fix changes
authorRex Jolliff <rex@lvcablemodem.com>
Mon, 5 Oct 1998 03:39:36 +0000 (03:39 +0000)
committerRex Jolliff <rex@lvcablemodem.com>
Mon, 5 Oct 1998 03:39:36 +0000 (03:39 +0000)
svn path=/trunk/; revision=49

reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ldr/loader.c

index 3901a66..1b53e4b 100644 (file)
@@ -132,7 +132,7 @@ asmlinkage void _main(boot_param* _bp)
    DbgPrint("Starting ReactOS "KERNEL_VERSION"\n");
    
    start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
-   if (start <= ((int)&end))
+   if (start < ((int)&end))
      {
        DbgPrint("Kernel booted incorrectly, aborting\n");
        for(;;);
index 56fb2ad..23715c2 100644 (file)
 
 NTSTATUS LdrProcessImage(HANDLE SectionHandle, PVOID BaseAddress)
 {
-   PIMAGE_DOS_HEADER dos_hdr = (PIMAGE_DOS_HEADER)BaseAddress;
-   PIMAGE_NT_HEADERS hdr = (PIMAGE_NT_HEADERS)(BaseAddress
-                                              + dos_hdr->e_lfanew);
-   PIMAGE_SECTION_HEADER sections = (PIMAGE_SECTION_HEADER)(BaseAddress 
-                                           + dos_hdr->e_lfanew
-                                                   + sizeof(IMAGE_NT_HEADERS));
-   
-   
+  PIMAGE_DOS_HEADER dos_hdr = (PIMAGE_DOS_HEADER)BaseAddress;
+  PIMAGE_NT_HEADERS hdr = (PIMAGE_NT_HEADERS)(BaseAddress
+      + dos_hdr->e_lfanew);
+  PIMAGE_SECTION_HEADER sections = (PIMAGE_SECTION_HEADER)(BaseAddress 
+      + dos_hdr->e_lfanew + 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
  */
 {
+  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)
@@ -50,4 +94,51 @@ NTSTATUS LdrLoadImage(PUNICODE_STRING FileName)
  * 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);
 }
+