WINLDR: Don't hardcode filesystem driver name
authorHervé Poussineau <hpoussin@reactos.org>
Thu, 24 Sep 2009 08:15:13 +0000 (08:15 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Thu, 24 Sep 2009 08:15:13 +0000 (08:15 +0000)
Instead, use the one of the system partition

svn path=/trunk/; revision=43126

reactos/boot/freeldr/freeldr/fs/ext2.c
reactos/boot/freeldr/freeldr/fs/fat.c
reactos/boot/freeldr/freeldr/fs/fs.c
reactos/boot/freeldr/freeldr/fs/iso.c
reactos/boot/freeldr/freeldr/fs/ntfs.c
reactos/boot/freeldr/freeldr/include/fs.h
reactos/boot/freeldr/freeldr/windows/wlregistry.c

index 4ed9802..77e56c0 100644 (file)
@@ -1257,6 +1257,7 @@ const DEVVTBL Ext2FuncTable =
        Ext2Open,
        Ext2Read,
        Ext2Seek,
+       L"ext2",
 };
 
 const DEVVTBL* Ext2Mount(ULONG DeviceId)
index 2acdb98..f905edf 100644 (file)
@@ -1463,6 +1463,7 @@ const DEVVTBL FatFuncTable =
        FatOpen,
        FatRead,
        FatSeek,
+       L"fastfat",
 };
 
 const DEVVTBL* FatMount(ULONG DeviceId)
index 7026a06..a19bdeb 100644 (file)
@@ -411,6 +411,13 @@ VOID FsRegisterDevice(CHAR* Prefix, const DEVVTBL* FuncTable)
     InsertHeadList(&DeviceListHead, &pNewEntry->ListEntry);
 }
 
+LPCWSTR FsGetServiceName(ULONG FileId)
+{
+    if (FileId >= MAX_FDS || !FileData[FileId].FuncTable)
+        return NULL;
+    return FileData[FileId].FuncTable->ServiceName;
+}
+
 VOID FsSetDeviceSpecific(ULONG FileId, VOID* Specific)
 {
     if (FileId >= MAX_FDS || !FileData[FileId].FuncTable)
index bcc2132..69cac1e 100644 (file)
@@ -479,6 +479,7 @@ const DEVVTBL Iso9660FuncTable =
        IsoOpen,
        IsoRead,
        IsoSeek,
+       L"cdfs",
 };
 
 const DEVVTBL* IsoMount(ULONG DeviceId)
index b911d23..b961794 100644 (file)
@@ -836,6 +836,7 @@ const DEVVTBL NtfsFuncTable =
     NtfsOpen,
     NtfsRead,
     NtfsSeek,
+    L"ntfs",
 };
 
 const DEVVTBL* NtfsMount(ULONG DeviceId)
index 88da935..99614e9 100644 (file)
@@ -27,6 +27,7 @@ typedef struct tagDEVVTBL
   ARC_OPEN Open;
   ARC_READ Read;
   ARC_SEEK Seek;
+  LPCWSTR ServiceName;
 } DEVVTBL;
 
 #define        FS_FAT                  1
@@ -37,6 +38,7 @@ typedef struct tagDEVVTBL
 #define PFILE                  ULONG
 
 VOID FsRegisterDevice(CHAR* Prefix, const DEVVTBL* FuncTable);
+LPCWSTR FsGetServiceName(ULONG FileId);
 VOID FsSetDeviceSpecific(ULONG FileId, VOID* Specific);
 VOID* FsGetDeviceSpecific(ULONG FileId);
 ULONG FsGetDeviceId(ULONG FileId);
index 4f8ab2e..d64f76d 100644 (file)
@@ -50,6 +50,7 @@ WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
        ULONG_PTR HiveDataPhysical;
        PVOID HiveDataVirtual;
        ULONG BytesRead;
+       LPCWSTR FsService;
 
        /* Concatenate path and filename to get the full name */
        strcpy(FullHiveName, DirectoryPath);
@@ -95,13 +96,31 @@ WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
 
        /* Finally read from file to the memory */
        Status = ArcRead(FileId, (PVOID)HiveDataPhysical, HiveFileSize, &BytesRead);
-       ArcClose(FileId);
        if (Status != ESUCCESS)
        {
+               ArcClose(FileId);
                UiMessageBox("Unable to read from hive file!");
                return FALSE;
        }
 
+       // Add boot filesystem driver to the list
+       FsService = FsGetServiceName(FileId);
+       if (FsService)
+       {
+               DPRINTM(DPRINT_WINDOWS, "  Adding filesystem service %S\n", FsService);
+               Status = WinLdrAddDriverToList(&LoaderBlock->BootDriverListHead,
+                       L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\",
+                       NULL,
+                       (LPWSTR)FsService);
+               if (!Status)
+                       DPRINTM(DPRINT_WINDOWS, " Failed to add filesystem service\n");
+       }
+       else
+       {
+               DPRINTM(DPRINT_WINDOWS, "  No required filesystem service\n");
+       }
+
+       ArcClose(FileId);
        return TRUE;
 }
 
@@ -145,14 +164,6 @@ BOOLEAN WinLdrLoadAndScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
        // Scan registry and prepare boot drivers list
        WinLdrScanRegistry(LoaderBlock, DirectoryPath);
 
-       // Add boot filesystem driver to the list
-       //FIXME: Use corresponding driver instead of hardcoding
-       Status = WinLdrAddDriverToList(&LoaderBlock->BootDriverListHead,
-               L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\",
-               NULL,
-               L"fastfat");
-
-
        // Get names of NLS files
        Status = WinLdrGetNLSNames(AnsiName, OemName, LangName);
        if (!Status)