From f1d365f7671b22b2bc7e89090efa68a5ecb95e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 24 Sep 2006 13:42:24 +0000 Subject: [PATCH] Don't hardcode the list of available filesystems in fmifs.dll, but store it in the registry. Adding a filesystem is now only a matter of creating a u{FS}.dll + one registry entry to be able to use normal format.exe/chkdsk.exe/... svn path=/trunk/; revision=24254 --- reactos/boot/bootdata/hivesft.inf | 4 ++ reactos/dll/win32/fmifs/init.c | 68 +++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/reactos/boot/bootdata/hivesft.inf b/reactos/boot/bootdata/hivesft.inf index 2d09fa12917..dcbe055c595 100644 --- a/reactos/boot/bootdata/hivesft.inf +++ b/reactos/boot/bootdata/hivesft.inf @@ -734,6 +734,10 @@ HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Tonga Standard Tim 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +; Available file systems +HKLM,"SOFTWARE\ReactOS\ReactOS\CurrentVersion\IFS","FAT",0x00000000,"ufat.dll" +HKLM,"SOFTWARE\ReactOS\ReactOS\CurrentVersion\IFS","FAT32",0x00000000,"ufat.dll" + HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","ConsoleShell",0x00020000,"%SystemRoot%\system32\cmd.exe" HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\explorer.exe" HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartServices",0x00010001,0x00000001 diff --git a/reactos/dll/win32/fmifs/init.c b/reactos/dll/win32/fmifs/init.c index b6a0c15c478..0b3489d4ba8 100644 --- a/reactos/dll/win32/fmifs/init.c +++ b/reactos/dll/win32/fmifs/init.c @@ -35,7 +35,7 @@ GetProvider( static BOOLEAN AddProvider( - IN PWCHAR FileSystem, + IN PCUNICODE_STRING FileSystem, IN PWCHAR DllFile) { PIFS_PROVIDER Provider = NULL; @@ -48,7 +48,7 @@ AddProvider( goto cleanup; RequiredSize = FIELD_OFFSET(IFS_PROVIDER, Name) - + wcslen(FileSystem) * sizeof(WCHAR) + sizeof(UNICODE_NULL); + + FileSystem->Length + sizeof(UNICODE_NULL); Provider = (PIFS_PROVIDER)RtlAllocateHeap( RtlGetProcessHeap(), 0, @@ -62,7 +62,7 @@ AddProvider( //Provider->Extend = (EXTEND)GetProcAddress(hMod, "Extend"); Provider->FormatEx = (FORMATEX)GetProcAddress(hMod, "FormatEx"); - wcscpy(Provider->Name, FileSystem); + RtlCopyMemory(Provider->Name, FileSystem->Buffer, FileSystem->Length); InsertTailList(&ProviderListHead, &Provider->ListEntry); ret = TRUE; @@ -81,14 +81,66 @@ cleanup: static BOOLEAN InitializeFmIfsOnce(void) { + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING RegistryPath + = RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\SOFTWARE\\ReactOS\\ReactOS\\CurrentVersion\\IFS"); + HANDLE hKey = NULL; + PKEY_VALUE_FULL_INFORMATION Buffer; + ULONG BufferSize = sizeof(KEY_VALUE_FULL_INFORMATION) + MAX_PATH; + ULONG RequiredSize; + ULONG i = 0; + UNICODE_STRING Name; + UNICODE_STRING Data; + NTSTATUS Status; + InitializeListHead(&ProviderListHead); - /* Add default providers */ - AddProvider(L"FAT", L"ufat"); - AddProvider(L"FAT32", L"ufat"); + /* Read IFS providers from HKLM\SOFTWARE\ReactOS\ReactOS\CurrentVersion\IFS */ + InitializeObjectAttributes(&ObjectAttributes, &RegistryPath, 0, NULL, NULL); + Status = NtOpenKey(&hKey, KEY_QUERY_VALUE, &ObjectAttributes); + if (Status == STATUS_OBJECT_NAME_NOT_FOUND) + return TRUE; + else if (!NT_SUCCESS(Status)) + return FALSE; - /* TODO: Check how many IFS are installed in the system */ - /* TODO: and register a descriptor for each one */ + Buffer = (PKEY_VALUE_FULL_INFORMATION)RtlAllocateHeap( + RtlGetProcessHeap(), + 0, + BufferSize); + if (!Buffer) + { + NtClose(hKey); + return FALSE; + } + + while (TRUE) + { + Status = NtEnumerateValueKey( + hKey, + i++, + KeyValueFullInformation, + Buffer, + BufferSize, + &RequiredSize); + if (Status == STATUS_BUFFER_OVERFLOW) + continue; + else if (!NT_SUCCESS(Status)) + break; + else if (Buffer->Type != REG_SZ) + continue; + + Name.Length = Name.MaximumLength = Buffer->NameLength; + Name.Buffer = Buffer->Name; + Data.Length = Data.MaximumLength = Buffer->DataLength; + Data.Buffer = (PWCHAR)((ULONG_PTR)Buffer + Buffer->DataOffset); + if (Data.Length > sizeof(WCHAR) && Data.Buffer[Data.Length / sizeof(WCHAR) - 1] == UNICODE_NULL) + Data.Length -= sizeof(WCHAR); + + AddProvider(&Name, Data.Buffer); + } + + NtClose(hKey); + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); return TRUE; }