Author: ion
Date: Mon Mar 12 20:30:57 2007
New Revision: 26067
URL:
http://svn.reactos.org/svn/reactos?rev=26067&view=rev
Log:
- Fix some bugs in the kernel related to driver loading, which were hindering FreeLDR 2.5
support.
- Make FreeLDR relocate and process the import tables of drivers as well. This is almost
FreeLDR 2.5 but is still missing some minor functionality before being completely done.
Modified:
trunk/reactos/base/applications/charmap/ (props changed)
trunk/reactos/base/applications/screensavers/scrnsave/ (props changed)
trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
trunk/reactos/dll/keyboard/kbdit/ (props changed)
trunk/reactos/dll/keyboard/kbdth/ (props changed)
trunk/reactos/dll/win32/usp10/ (props changed)
trunk/reactos/drivers/multimedia/drmk/ (props changed)
trunk/reactos/drivers/multimedia/ks/ (props changed)
trunk/reactos/drivers/wmi/ (props changed)
trunk/reactos/ntoskrnl/io/iomgr/driver.c
trunk/reactos/ntoskrnl/mm/sysldr.c
Propchange: trunk/reactos/base/applications/charmap/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Propchange: trunk/reactos/base/applications/screensavers/scrnsave/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Mon Mar 12 20:30:57 2007
@@ -521,7 +521,6 @@
Status = LdrPEGetOrLoadModule(DllName, ImportedName, &ImportedModule);
if (!NT_SUCCESS(Status)) return Status;
- //DbgPrint("Import Base: %p\n", ImportedModule->ModStart);
Status = LdrPEProcessImportDirectoryEntry(DllBase, ImportedModule,
ImportModuleDirectory);
if (!NT_SUCCESS(Status)) return Status;
@@ -574,7 +573,7 @@
}
else
{
- /* BSS */
+ /* Clear the BSS area */
RtlZeroMemory((PVOID)((ULONG_PTR)LoadBase +
Section[i].VirtualAddress),
Section[i].Misc.VirtualSize);
@@ -595,6 +594,7 @@
PVOID ImageBase, LoadBase, ReadBuffer;
ULONG ImageId = LoaderBlock.ModsCount;
ULONG ImageSize;
+ NTSTATUS Status = STATUS_SUCCESS;
/* Set the virtual (image) and physical (load) addresses */
LoadBase = (PVOID)NextModuleBase;
@@ -619,13 +619,19 @@
MmFreeMemory(ReadBuffer);
/* Calculate Difference between Real Base and Compiled Base*/
- if (ImageType != 2) LdrRelocateImageWithBias(LoadBase,
- (ULONG_PTR)ImageBase -
- (ULONG_PTR)LoadBase,
- "FreeLdr",
- STATUS_SUCCESS,
- STATUS_UNSUCCESSFUL,
- STATUS_UNSUCCESSFUL);
+ Status = LdrRelocateImageWithBias(LoadBase,
+ (ULONG_PTR)ImageBase -
+ (ULONG_PTR)LoadBase,
+ "FreeLdr",
+ STATUS_SUCCESS,
+ STATUS_UNSUCCESSFUL,
+ STATUS_UNSUCCESSFUL);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Fail */
+ DbgPrint("Failed to relocate image: %s\n", Name);
+ return NULL;
+ }
/* Fill out Module Data Structure */
reactos_modules[ImageId].ModStart = (ULONG_PTR)ImageBase;
@@ -637,14 +643,11 @@
/* Increase the next Load Base */
NextModuleBase = ROUND_UP(NextModuleBase + ImageSize, PAGE_SIZE);
- /* Successful load! */
- //DbgPrint("Image: %s loaded at: %p\n", Name, ImageBase);
-
/* Load HAL if this is the kernel */
if (ImageType == 1) FrLdrLoadImage("hal.dll", 10, FALSE);
/* Perform import fixups */
- if (ImageType != 2) LdrPEFixupImports(LoadBase, Name);
+ LdrPEFixupImports(LoadBase, Name);
/* Return the final mapped address */
return LoadBase;
Propchange: trunk/reactos/dll/keyboard/kbdit/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Propchange: trunk/reactos/dll/keyboard/kbdth/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Propchange: trunk/reactos/dll/win32/usp10/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Propchange: trunk/reactos/drivers/multimedia/drmk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Propchange: trunk/reactos/drivers/multimedia/ks/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Propchange: trunk/reactos/drivers/wmi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 12 20:30:57 2007
@@ -1,0 +1,2 @@
+*.vcproj
+*.user
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c Mon Mar 12 20:30:57 2007
@@ -157,7 +157,7 @@
if (ExpInTextModeSetup) return;
if (Unicode)
{
- if (wcsstr(ServiceName, L".sys")) Extra = "";
+ if (wcsstr(_wcsupr(ServiceName), L".SYS")) Extra = "";
sprintf(TextBuffer,
"%s%s%s\\%S%s\n",
KeLoaderBlock->ArcBootDeviceName,
@@ -168,7 +168,7 @@
}
else
{
- if (strstr(ServiceName, ".sys")) Extra = "";
+ if (strstr(_strupr(ServiceName), ".SYS")) Extra = "";
sprintf(TextBuffer,
"%s%s%s\\%s%s\n",
KeLoaderBlock->ArcBootDeviceName,
@@ -733,7 +733,6 @@
PLDR_DATA_TABLE_ENTRY ModuleObject;
#endif
-
/*
* Display 'Loading XXX...' message
*/
@@ -887,7 +886,7 @@
* HACK: Make sure we're loading a driver
* (we should be using BootDriverListHead!)
*/
- if (wcsstr(LdrEntry->BaseDllName.Buffer, L".sys"))
+ if (wcsstr(_wcsupr(LdrEntry->BaseDllName.Buffer), L".SYS"))
{
/* Make sure we didn't load this driver already */
if (!(LdrEntry->Flags & LDRP_ENTRY_INSERTED))
Modified: trunk/reactos/ntoskrnl/mm/sysldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/sysldr.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/sysldr.c (original)
+++ trunk/reactos/ntoskrnl/mm/sysldr.c Mon Mar 12 20:30:57 2007
@@ -1221,7 +1221,9 @@
/* Sanity check */
ASSERT(*(PULONG)NewImageAddress == *(PULONG)DllBase);
- /* Set the image base to the old address */
+ /* Set the image base to the address where the loader put it */
+ NtHeader->OptionalHeader.ImageBase = (ULONG_PTR)DllBase;
+ NtHeader = RtlImageNtHeader(NewImageAddress);
NtHeader->OptionalHeader.ImageBase = (ULONG_PTR)DllBase;
/* Check if we had relocations */