[ros-diffs] [fireball] 32363: - Load drivers database (AppPatch/drvmain.sdb), so Windows could use it if needed.
fireball at svn.reactos.org
fireball at svn.reactos.org
Thu Feb 14 21:28:00 CET 2008
- Previous message: [ros-diffs] [ros-arm-bringup] 32362: Fix a couple of off-by-one bugs we recently introduced -- PFNs are one of the only indexes which are actually 0-based, so you really want to loop from 0 to the last page, inclusive (unlike most loops where you would stop *before* the last element index).
- Next message: [ros-diffs] [ros-arm-bringup] 32364: One would expect that a function called "MmIsUsablePage" would return whether a not a page is usable. In other words, we are making sure that the page is free/available, so that we may make use of it. Apparently not so -- MmIsUsable page returned if a page was NOT usable, but was instead "already used". The caller's wish was to ensure he was correctly using a used page, not to check if he could start using a usable page. This would just be an annoying gramatical/logic error (but makes "sense" in the way it's used), if it weren't for the fact that MmIsUsablePage also returned TRUE for BIOS pages (which meant, "yes, you are correctly using/overwriting memory we spent time ensuring to mark as reserved/BIOS"). Renamed the function to MmIsPageInUse, and only return TRUE if the page is in use. Like the name says.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: fireball
Date: Thu Feb 14 23:27:59 2008
New Revision: 32363
URL: http://svn.reactos.org/svn/reactos?rev=32363&view=rev
Log:
- Load drivers database (AppPatch/drvmain.sdb), so Windows could use it if needed.
Modified:
trunk/reactos/boot/freeldr/freeldr/include/winldr.h
trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/winldr.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/include/winldr.h?rev=32363&r1=32362&r2=32363&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/winldr.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/winldr.h Thu Feb 14 23:27:59 2008
@@ -68,6 +68,10 @@
IN PCCH DirectoryPath,
IN PLDR_DATA_TABLE_ENTRY ScanDTE);
+// winldr.c
+PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
+ TYPE_OF_MEMORY MemoryType);
+
// wlmemory.c
BOOLEAN
WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windows/winldr.c?rev=32363&r1=32362&r2=32363&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c Thu Feb 14 23:27:59 2008
@@ -76,6 +76,7 @@
WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
PCHAR Options,
PCHAR SystemPath,
+ PCHAR BootPath,
WORD VersionToBoot)
{
/* Examples of correct options and paths */
@@ -87,6 +88,7 @@
CHAR HalPath[] = "\\";
CHAR SystemRoot[256];
CHAR ArcBoot[256];
+ CHAR MiscFiles[256];
ULONG i, PathSeparator;
PLOADER_PARAMETER_EXTENSION Extension;
@@ -192,6 +194,12 @@
Extension->MajorVersion = (VersionToBoot & 0xFF00) >> 8;
Extension->MinorVersion = VersionToBoot & 0xFF;
Extension->Profile.Status = 2;
+
+ /* Load drivers database */
+ strcpy(MiscFiles, BootPath);
+ strcat(MiscFiles, "AppPatch\\drvmain.sdb");
+ Extension->DrvDBImage = PaToVa(WinLdrLoadModule(MiscFiles,
+ &Extension->DrvDBSize, LoaderRegistryData));
LoaderBlock->Extension = PaToVa(Extension);
}
@@ -352,6 +360,61 @@
return TRUE;
}
+
+PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
+ TYPE_OF_MEMORY MemoryType)
+{
+ PFILE FileHandle;
+ PVOID PhysicalBase;
+ ULONG FileSize;
+ BOOLEAN Status;
+
+ //CHAR ProgressString[256];
+
+ /* Inform user we are loading files */
+ //sprintf(ProgressString, "Loading %s...", FileName);
+ //UiDrawProgressBarCenter(1, 100, ProgressString);
+
+ DbgPrint((DPRINT_WINDOWS, "Loading module %s\n", ModuleName));
+ *Size = 0;
+
+ /* Open the image file */
+ FileHandle = FsOpenFile(ModuleName);
+
+ if (FileHandle == NULL)
+ {
+ /* In case of errors, we just return, without complaining to the user */
+ return NULL;
+ }
+
+ /* Get this file's size */
+ FileSize = FsGetFileSize(FileHandle);
+ *Size = FileSize;
+
+ /* Allocate memory */
+ PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
+ if (PhysicalBase == NULL)
+ {
+ FsCloseFile(FileHandle);
+ return NULL;
+ }
+
+ /* Load whole file */
+ Status = FsReadFile(FileHandle, FileSize, NULL, PhysicalBase);
+ if (!Status)
+ {
+ FsCloseFile(FileHandle);
+ return NULL;
+ }
+
+ DbgPrint((DPRINT_WINDOWS, "Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize));
+
+ /* We are done with the file - close it */
+ FsCloseFile(FileHandle);
+
+ return PhysicalBase;
+}
+
VOID
LoadAndBootWindows(PCSTR OperatingSystemName, WORD OperatingSystemVersion)
@@ -487,7 +550,7 @@
WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage);
/* Initialize Phase 1 - no drivers loading anymore */
- WinLdrInitializePhase1(LoaderBlock, BootOptions, SystemPath, OperatingSystemVersion);
+ WinLdrInitializePhase1(LoaderBlock, BootOptions, SystemPath, BootPath, OperatingSystemVersion);
/* Save entry-point pointer and Loader block VAs */
KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint;
- Previous message: [ros-diffs] [ros-arm-bringup] 32362: Fix a couple of off-by-one bugs we recently introduced -- PFNs are one of the only indexes which are actually 0-based, so you really want to loop from 0 to the last page, inclusive (unlike most loops where you would stop *before* the last element index).
- Next message: [ros-diffs] [ros-arm-bringup] 32364: One would expect that a function called "MmIsUsablePage" would return whether a not a page is usable. In other words, we are making sure that the page is free/available, so that we may make use of it. Apparently not so -- MmIsUsable page returned if a page was NOT usable, but was instead "already used". The caller's wish was to ensure he was correctly using a used page, not to check if he could start using a usable page. This would just be an annoying gramatical/logic error (but makes "sense" in the way it's used), if it weren't for the fact that MmIsUsablePage also returned TRUE for BIOS pages (which meant, "yes, you are correctly using/overwriting memory we spent time ensuring to mark as reserved/BIOS"). Renamed the function to MmIsPageInUse, and only return TRUE if the page is in use. Like the name says.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Ros-diffs
mailing list