From 2432b60a2e1c2d8b4f39da1d5f5f4026d50aa669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 24 Sep 2009 08:15:13 +0000 Subject: [PATCH] WINLDR: Don't hardcode filesystem driver name Instead, use the one of the system partition svn path=/trunk/; revision=43126 --- reactos/boot/freeldr/freeldr/fs/ext2.c | 1 + reactos/boot/freeldr/freeldr/fs/fat.c | 1 + reactos/boot/freeldr/freeldr/fs/fs.c | 7 +++++ reactos/boot/freeldr/freeldr/fs/iso.c | 1 + reactos/boot/freeldr/freeldr/fs/ntfs.c | 1 + reactos/boot/freeldr/freeldr/include/fs.h | 2 ++ .../boot/freeldr/freeldr/windows/wlregistry.c | 29 +++++++++++++------ 7 files changed, 33 insertions(+), 9 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/fs/ext2.c b/reactos/boot/freeldr/freeldr/fs/ext2.c index 4ed9802afb5..77e56c007f9 100644 --- a/reactos/boot/freeldr/freeldr/fs/ext2.c +++ b/reactos/boot/freeldr/freeldr/fs/ext2.c @@ -1257,6 +1257,7 @@ const DEVVTBL Ext2FuncTable = Ext2Open, Ext2Read, Ext2Seek, + L"ext2", }; const DEVVTBL* Ext2Mount(ULONG DeviceId) diff --git a/reactos/boot/freeldr/freeldr/fs/fat.c b/reactos/boot/freeldr/freeldr/fs/fat.c index 2acdb98c01c..f905edf4934 100644 --- a/reactos/boot/freeldr/freeldr/fs/fat.c +++ b/reactos/boot/freeldr/freeldr/fs/fat.c @@ -1463,6 +1463,7 @@ const DEVVTBL FatFuncTable = FatOpen, FatRead, FatSeek, + L"fastfat", }; const DEVVTBL* FatMount(ULONG DeviceId) diff --git a/reactos/boot/freeldr/freeldr/fs/fs.c b/reactos/boot/freeldr/freeldr/fs/fs.c index 7026a06e193..a19bdebe7de 100644 --- a/reactos/boot/freeldr/freeldr/fs/fs.c +++ b/reactos/boot/freeldr/freeldr/fs/fs.c @@ -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) diff --git a/reactos/boot/freeldr/freeldr/fs/iso.c b/reactos/boot/freeldr/freeldr/fs/iso.c index bcc2132284e..69cac1e658f 100644 --- a/reactos/boot/freeldr/freeldr/fs/iso.c +++ b/reactos/boot/freeldr/freeldr/fs/iso.c @@ -479,6 +479,7 @@ const DEVVTBL Iso9660FuncTable = IsoOpen, IsoRead, IsoSeek, + L"cdfs", }; const DEVVTBL* IsoMount(ULONG DeviceId) diff --git a/reactos/boot/freeldr/freeldr/fs/ntfs.c b/reactos/boot/freeldr/freeldr/fs/ntfs.c index b911d23ac95..b9617942f5e 100644 --- a/reactos/boot/freeldr/freeldr/fs/ntfs.c +++ b/reactos/boot/freeldr/freeldr/fs/ntfs.c @@ -836,6 +836,7 @@ const DEVVTBL NtfsFuncTable = NtfsOpen, NtfsRead, NtfsSeek, + L"ntfs", }; const DEVVTBL* NtfsMount(ULONG DeviceId) diff --git a/reactos/boot/freeldr/freeldr/include/fs.h b/reactos/boot/freeldr/freeldr/include/fs.h index 88da935bc6b..99614e9e7ca 100644 --- a/reactos/boot/freeldr/freeldr/include/fs.h +++ b/reactos/boot/freeldr/freeldr/include/fs.h @@ -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); diff --git a/reactos/boot/freeldr/freeldr/windows/wlregistry.c b/reactos/boot/freeldr/freeldr/windows/wlregistry.c index 4f8ab2eb1aa..d64f76ddda3 100644 --- a/reactos/boot/freeldr/freeldr/windows/wlregistry.c +++ b/reactos/boot/freeldr/freeldr/windows/wlregistry.c @@ -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)