Author: hbelusca Date: Thu Jun 8 17:30:23 2017 New Revision: 74964
URL: http://svn.reactos.org/svn/reactos?rev=74964&view=rev Log: [SETUPLIB][USETUP]: Minor code refactoring, consisting in renaming the "ntos boot loader" stuff into "boot store", since this happens to be functionality that is a bit more general than previously thought. - Fix the usage of the BootEntry's "Version" member. - Don't surround with too many quotation marks the "friendly" boot entry name in AddBootStoreEntry().
Modified: branches/setup_improvements/base/setup/lib/bldrsup.c branches/setup_improvements/base/setup/lib/bldrsup.h branches/setup_improvements/base/setup/lib/osdetect.c branches/setup_improvements/base/setup/usetup/bootsup.c
Modified: branches/setup_improvements/base/setup/lib/bldrsup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/li... ============================================================================== --- branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] Thu Jun 8 17:30:23 2017 @@ -2,8 +2,8 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Setup Library * FILE: base/setup/lib/bldrsup.c - * PURPOSE: NT 5.x family (MS Windows <= 2003, and ReactOS) - * boot loaders management. + * PURPOSE: Boot Stores Management functionality, with support for + * NT 5.x family (MS Windows <= 2003, and ReactOS) bootloaders. * PROGRAMMER: Hermes Belusca-Maito (hermes.belusca@sfr.fr) */
@@ -27,7 +27,7 @@ (*POPEN_BOOT_STORE)( OUT PVOID* Handle, IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew);
typedef NTSTATUS @@ -43,7 +43,7 @@
typedef struct _NTOS_BOOT_LOADER_FILES { - NTOS_BOOT_LOADER_TYPE Type; + BOOT_STORE_TYPE Type; PCZZWSTR LoaderExecutables; PCWSTR LoaderConfigurationFile; POPEN_BOOT_STORE OpenBootStore; @@ -57,7 +57,7 @@ */ typedef struct _BOOT_STORE_CONTEXT { - NTOS_BOOT_LOADER_TYPE Type; + BOOT_STORE_TYPE Type; // PNTOS_BOOT_LOADER_FILES ?? /* PVOID PrivateData; @@ -96,7 +96,7 @@ OpenIniBootLoaderStore( OUT PVOID* Handle, IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew);
static NTSTATUS @@ -135,10 +135,10 @@ /* FUNCTIONS ****************************************************************/
NTSTATUS -FindNTOSBootLoader( // By handle +FindBootStore( // By handle IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, - OUT PULONG Version OPTIONAL) + IN BOOT_STORE_TYPE Type, + OUT PULONG VersionNumber OPTIONAL) // OUT PHANDLE ConfigFileHande OPTIONAL ???? { PCWSTR LoaderExecutable; @@ -147,8 +147,8 @@ if (Type >= BldrTypeMax) return STATUS_INVALID_PARAMETER;
- if (Version) - *Version = 0; + if (VersionNumber) + *VersionNumber = 0;
/* Check whether any of the loader executables exist */ LoaderExecutable = NtosBootLoaders[Type].LoaderExecutables; @@ -173,10 +173,10 @@ }
/* Check for loader version if needed */ - if (Version) - { - *Version = 0; - // TODO: Check for BLDR version ONLY if Version != NULL + if (VersionNumber) + { + *VersionNumber = 0; + // TODO: Check for BLDR version! }
/* Check whether the loader configuration file exists */ @@ -340,7 +340,7 @@ OpenIniBootLoaderStore( OUT PVOID* Handle, IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew) { NTSTATUS Status; @@ -733,10 +733,10 @@
NTSTATUS -OpenNTOSBootLoaderStoreByHandle( +OpenBootStoreByHandle( OUT PVOID* Handle, IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew) { /* @@ -760,10 +760,10 @@ }
NTSTATUS -OpenNTOSBootLoaderStore_UStr( +OpenBootStore_UStr( OUT PVOID* Handle, IN PUNICODE_STRING SystemPartitionPath, - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew) { NTSTATUS Status; @@ -803,7 +803,7 @@ return Status; }
- Status = OpenNTOSBootLoaderStoreByHandle(Handle, PartitionDirectoryHandle, Type, CreateNew); + Status = OpenBootStoreByHandle(Handle, PartitionDirectoryHandle, Type, CreateNew);
/* Done! */ NtClose(PartitionDirectoryHandle); @@ -811,19 +811,19 @@ }
NTSTATUS -OpenNTOSBootLoaderStore( +OpenBootStore( OUT PVOID* Handle, IN PCWSTR SystemPartition, - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew) { UNICODE_STRING SystemPartitionPath; RtlInitUnicodeString(&SystemPartitionPath, SystemPartition); - return OpenNTOSBootLoaderStore_UStr(Handle, &SystemPartitionPath, Type, CreateNew); + return OpenBootStore_UStr(Handle, &SystemPartitionPath, Type, CreateNew); }
NTSTATUS -CloseNTOSBootLoaderStore( +CloseBootStore( IN PVOID Handle) { PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle; @@ -855,7 +855,7 @@ CreateNTOSEntry( IN PBOOT_STORE_INI_CONTEXT BootStore, IN ULONG_PTR BootEntryKey, - IN PNTOS_BOOT_ENTRY BootEntry) + IN PBOOT_STORE_ENTRY BootEntry) { PINICACHESECTION IniSection; PWCHAR Section = (PWCHAR)BootEntryKey; @@ -867,7 +867,6 @@ /* Create a new section */ IniSection = IniCacheAppendSection(BootStore->IniCache, Section);
- // if (_wcsicmp(BootEntry->Version, L"Windows2003") == 0) if (BootEntry->OsOptionsLength >= sizeof(NTOS_OPTIONS) && RtlCompareMemory(&BootEntry->OsOptions /* Signature */, NTOS_OPTIONS_SIGNATURE, @@ -889,7 +888,6 @@ L"Options", (PWSTR)Options->OsLoadOptions); } else - // if (_wcsicmp(BootEntry->Version, L"BootSector") == 0) if (BootEntry->OsOptionsLength >= sizeof(BOOT_SECTOR_OPTIONS) && RtlCompareMemory(&BootEntry->OsOptions /* Signature */, BOOT_SECTOR_OPTIONS_SIGNATURE, @@ -916,16 +914,18 @@ } else { - DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version); + // DPRINT1("Unsupported BootType %lu/'%*.s'\n", + // BootEntry->OsOptionsLength, 8, &BootEntry->OsOptions); + DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength); }
return STATUS_SUCCESS; }
NTSTATUS -AddNTOSBootEntry( +AddBootStoreEntry( IN PVOID Handle, - IN PNTOS_BOOT_ENTRY BootEntry, + IN PBOOT_STORE_ENTRY BootEntry, IN ULONG_PTR BootEntryKey) { PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle; @@ -949,6 +949,9 @@
if (BootStore->Type == FreeLdr) { + if (BootEntry->Version != FreeLdr) + return STATUS_INVALID_PARAMETER; + return CreateNTOSEntry((PBOOT_STORE_INI_CONTEXT)BootStore, BootEntryKey, BootEntry); } @@ -960,15 +963,19 @@ ULONG BufferLength; PCWSTR InstallName, OsOptions; // ULONG InstallNameLength, OsOptionsLength; - - // if (_wcsicmp(BootEntry->Version, L"Windows2003") != 0) + BOOLEAN IsNameNotQuoted; + + if (BootEntry->Version != NtLdr) + return STATUS_INVALID_PARAMETER; + if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) || RtlCompareMemory(&BootEntry->OsOptions /* Signature */, NTOS_OPTIONS_SIGNATURE, RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) != RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) { - DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version); + // DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version); + DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength); return STATUS_SUCCESS; // STATUS_NOT_SUPPORTED; }
@@ -978,7 +985,9 @@ // if (InstallNameLength == 0) InstallName = NULL; // if (OsOptionsLength == 0) OsOptions = NULL;
- BufferLength = 2 /* Quotes for FriendlyName*/ + wcslen(InstallName); + IsNameNotQuoted = (InstallName[0] != L'"' || InstallName[wcslen(InstallName)-1] != L'"'); + + BufferLength = (IsNameNotQuoted ? 2 /* Quotes for FriendlyName*/ : 0) + wcslen(InstallName); if (OsOptions) BufferLength += 1 /* Space between FriendlyName and options */ + wcslen(OsOptions); BufferLength++; /* NULL-termination */ @@ -987,9 +996,10 @@ if (!Buffer) return STATUS_INSUFFICIENT_RESOURCES;
- wcscpy(Buffer, L"""); + *Buffer = UNICODE_NULL; + if (IsNameNotQuoted) wcscat(Buffer, L"""); wcscat(Buffer, InstallName); - wcscat(Buffer, L"""); + if (IsNameNotQuoted) wcscat(Buffer, L"""); if (OsOptions) { wcscat(Buffer, L" "); @@ -1011,7 +1021,7 @@ }
NTSTATUS -DeleteNTOSBootEntry( +DeleteBootStoreEntry( IN PVOID Handle, IN ULONG_PTR BootEntryKey) { @@ -1045,9 +1055,9 @@ }
NTSTATUS -ModifyNTOSBootEntry( +ModifyBootStoreEntry( IN PVOID Handle, - IN PNTOS_BOOT_ENTRY BootEntry) + IN PBOOT_STORE_ENTRY BootEntry) { PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
@@ -1079,10 +1089,10 @@ }
NTSTATUS -QueryNTOSBootEntry( +QueryBootStoreEntry( IN PVOID Handle, IN ULONG_PTR BootEntryKey, - OUT PNTOS_BOOT_ENTRY BootEntry) // Technically this should be PNTOS_BOOT_ENTRY* + OUT PBOOT_STORE_ENTRY BootEntry) // Technically this should be PBOOT_STORE_ENTRY* { PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
@@ -1114,9 +1124,9 @@ }
NTSTATUS -QueryNTOSBootOptions( +QueryBootStoreOptions( IN PVOID Handle, - IN OUT PNTOS_BOOT_OPTIONS BootOptions + IN OUT PBOOT_STORE_OPTIONS BootOptions /* , IN PULONG BootOptionsLength */ ) { NTSTATUS Status = STATUS_SUCCESS; @@ -1147,6 +1157,8 @@
if (BootStore->Type == FreeLdr) { + BootOptions->Version = FreeLdr; + Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection, L"DefaultOS", (PWCHAR*)&BootOptions->CurrentBootEntryKey); if (!NT_SUCCESS(Status)) @@ -1161,6 +1173,8 @@ } else if (BootStore->Type == NtLdr) { + BootOptions->Version = NtLdr; + Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection, L"default", (PWCHAR*)&BootOptions->CurrentBootEntryKey); if (!NT_SUCCESS(Status)) @@ -1178,9 +1192,9 @@ }
NTSTATUS -SetNTOSBootOptions( +SetBootStoreOptions( IN PVOID Handle, - IN PNTOS_BOOT_OPTIONS BootOptions, + IN PBOOT_STORE_OPTIONS BootOptions, IN ULONG FieldsToChange) { PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle; @@ -1208,6 +1222,9 @@ return STATUS_NOT_SUPPORTED; }
+ if (BootOptions->Version != FreeLdr) + return STATUS_INVALID_PARAMETER; + // // TODO: Depending on the flags set in 'FieldsToChange', // change either one or both these bootloader options. @@ -1237,9 +1254,9 @@ PINICACHEITERATOR Iterator; PINICACHESECTION OsIniSection; PWCHAR SectionName, KeyData; - UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + + UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + max(sizeof(NTOS_OPTIONS), sizeof(BOOT_SECTOR_OPTIONS))]; - PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry; PWCHAR Buffer;
/* Enumerate all the valid installations listed in the "Operating Systems" section */ @@ -1291,7 +1308,7 @@
DPRINT1("Boot entry '%S' in OS section '%S'\n", InstallName, SectionName);
- BootEntry->Version = NULL; + BootEntry->Version = FreeLdr; BootEntry->BootEntryKey = MAKESTRKEY(SectionName); BootEntry->FriendlyName = InstallName; BootEntry->BootFilePath = NULL; @@ -1318,8 +1335,7 @@ /* BootType is Windows2003 */ PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
- BootEntry->Version = L"Windows2003"; - DPRINT1("This is a '%S' boot entry\n", BootEntry->Version); + DPRINT1("This is a '%S' boot entry\n", KeyData);
BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); RtlCopyMemory(Options->Signature, @@ -1350,8 +1366,7 @@ /* BootType is BootSector */ PBOOT_SECTOR_OPTIONS Options = (PBOOT_SECTOR_OPTIONS)&BootEntry->OsOptions;
- BootEntry->Version = L"BootSector"; - DPRINT1("This is a '%S' boot entry\n", BootEntry->Version); + DPRINT1("This is a '%S' boot entry\n", KeyData);
BootEntry->OsOptionsLength = sizeof(BOOT_SECTOR_OPTIONS); RtlCopyMemory(Options->Signature, @@ -1384,7 +1399,6 @@ else { DPRINT1("Unrecognized BootType value '%S'\n", KeyData); - // BootEntry->Version = KeyData; // goto DoEnum; }
@@ -1416,8 +1430,8 @@ NTSTATUS Status = STATUS_SUCCESS; PINICACHEITERATOR Iterator; PWCHAR SectionName, KeyData; - UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; - PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry; PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; PWCHAR Buffer; ULONG BufferLength; @@ -1510,7 +1524,7 @@ DPRINT1("Boot entry '%S' in OS section (path) '%S'\n", InstallName, SectionName); // SectionName == SystemRoot;
- BootEntry->Version = L"Windows2003"; + BootEntry->Version = NtLdr; BootEntry->BootEntryKey = 0; // FIXME?? BootEntry->FriendlyName = InstallName; BootEntry->BootFilePath = NULL; @@ -1541,7 +1555,7 @@ }
NTSTATUS -EnumerateNTOSBootEntries( +EnumerateBootStoreEntries( IN PVOID Handle, // IN ULONG Flags, // Determine which data to retrieve IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
Modified: branches/setup_improvements/base/setup/lib/bldrsup.h URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/li... ============================================================================== --- branches/setup_improvements/base/setup/lib/bldrsup.h [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/bldrsup.h [iso-8859-1] Thu Jun 8 17:30:23 2017 @@ -2,8 +2,8 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Setup Library * FILE: base/setup/lib/bldrsup.h - * PURPOSE: NT 5.x family (MS Windows <= 2003, and ReactOS) - * boot loaders management. + * PURPOSE: Boot Stores Management functionality, with support for + * NT 5.x family (MS Windows <= 2003, and ReactOS) bootloaders. * PROGRAMMER: Hermes Belusca-Maito (hermes.belusca@sfr.fr) */
@@ -11,13 +11,13 @@
#pragma once
-typedef enum _NTOS_BOOT_LOADER_TYPE // _BOOT_STORE_TYPE +typedef enum _BOOT_STORE_TYPE { FreeLdr, // ReactOS' FreeLoader NtLdr, // Windows <= 2k3 NT "FlexBoot" OS Loader NTLDR // BootMgr, // Vista+ BCD-oriented BOOTMGR BldrTypeMax -} NTOS_BOOT_LOADER_TYPE; +} BOOT_STORE_TYPE;
/* * Some references about EFI boot entries: @@ -29,25 +29,25 @@ * This structure is inspired from the EFI boot entry structure * BOOT_OPTIONS that is defined in ndk/iotypes.h . */ -typedef struct _NTOS_BOOT_OPTIONS // _BOOT_STORE_OPTIONS +typedef struct _BOOT_STORE_OPTIONS { - // ULONG Version; + ULONG Version; // BOOT_STORE_TYPE value // ULONG Length; ULONG Timeout; ULONG_PTR CurrentBootEntryKey; // ULONG_PTR NextBootEntryKey; // WCHAR HeadlessRedirection[1]; -} NTOS_BOOT_OPTIONS, *PNTOS_BOOT_OPTIONS; +} BOOT_STORE_OPTIONS, *PBOOT_STORE_OPTIONS;
/* * These macros are used to set a value for the BootEntryKey member of a - * NTOS_BOOT_ENTRY structure, much in the same idea as MAKEINTRESOURCE and + * BOOT_STORE_ENTRY structure, much in the same idea as MAKEINTRESOURCE and * IS_INTRESOURCE macros for Win32 resources. * - * A key consists of either a boot ID number, - * comprised between 0 and MAX_USHORT == 0xFFFF == 65535, or can be a pointer - * to a human-readable string (section name), as in the case of FreeLDR, or - * to a GUID, as in the case of BOOTMGR. + * A key consists of either a boot ID number, comprised between 0 and + * MAX_USHORT == 0xFFFF == 65535, or can be a pointer to a human-readable + * string (section name), as in the case of FreeLDR, or to a GUID, as in the + * case of BOOTMGR. * * If IS_INTKEY(BootEntryKey) == TRUE, i.e. the key is <= 65535, this means * the key is a boot ID number, otherwise it is typically a pointer to a string. @@ -60,10 +60,9 @@ * This structure is inspired from the EFI boot entry structures * BOOT_ENTRY and FILE_PATH that are defined in ndk/iotypes.h . */ -typedef struct _NTOS_BOOT_ENTRY // _BOOT_STORE_ENTRY +typedef struct _BOOT_STORE_ENTRY { - // ULONG Version; // Equivalent of the "BootType" in FreeLdr - PWCHAR Version; // HACK!!! + ULONG Version; // BOOT_STORE_TYPE value // ULONG Length; ULONG_PTR BootEntryKey; // Boot entry "key" PCWSTR FriendlyName; // Human-readable boot entry description // LoadIdentifier @@ -78,7 +77,7 @@ * WCHAR FriendlyName[ANYSIZE_ARRAY]; * FILE_PATH BootFilePath; */ -} NTOS_BOOT_ENTRY, *PNTOS_BOOT_ENTRY; +} BOOT_STORE_ENTRY, *PBOOT_STORE_ENTRY;
/* "NTOS" (aka. ReactOS or MS Windows NT) <= 5.x options */ typedef struct _NTOS_OPTIONS @@ -86,8 +85,8 @@ UCHAR Signature[8]; // "NTOS_5\0\0" // ULONG Version; // ULONG Length; - PCWSTR OsLoadPath; // The OS SystemRoot path // OsLoaderFilePath // OsFilePath - PCWSTR OsLoadOptions; // OsLoadOptions + PCWSTR OsLoadPath; // The OS SystemRoot path // OsLoaderFilePath // OsFilePath + PCWSTR OsLoadOptions; // OsLoadOptions /* * In packed form, this structure would contain an offset to the 'OsLoadPath' * string, and the 'OsLoadOptions' member would be: @@ -115,79 +114,79 @@
typedef NTSTATUS (NTAPI *PENUM_BOOT_ENTRIES_ROUTINE)( - IN NTOS_BOOT_LOADER_TYPE Type, - IN PNTOS_BOOT_ENTRY BootEntry, + IN BOOT_STORE_TYPE Type, + IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL);
NTSTATUS -FindNTOSBootLoader( // By handle +FindBootStore( // By handle IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, - OUT PULONG Version); + IN BOOT_STORE_TYPE Type, + OUT PULONG VersionNumber OPTIONAL);
NTSTATUS -OpenNTOSBootLoaderStoreByHandle( +OpenBootStoreByHandle( OUT PVOID* Handle, IN HANDLE PartitionDirectoryHandle, // OPTIONAL - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew);
NTSTATUS -OpenNTOSBootLoaderStore_UStr( +OpenBootStore_UStr( OUT PVOID* Handle, IN PUNICODE_STRING SystemPartitionPath, - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew);
NTSTATUS -OpenNTOSBootLoaderStore( +OpenBootStore( OUT PVOID* Handle, IN PCWSTR SystemPartition, - IN NTOS_BOOT_LOADER_TYPE Type, + IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew);
NTSTATUS -CloseNTOSBootLoaderStore( +CloseBootStore( IN PVOID Handle);
NTSTATUS -AddNTOSBootEntry( +AddBootStoreEntry( IN PVOID Handle, - IN PNTOS_BOOT_ENTRY BootEntry, + IN PBOOT_STORE_ENTRY BootEntry, IN ULONG_PTR BootEntryKey);
NTSTATUS -DeleteNTOSBootEntry( +DeleteBootStoreEntry( IN PVOID Handle, IN ULONG_PTR BootEntryKey);
NTSTATUS -ModifyNTOSBootEntry( +ModifyBootStoreEntry( IN PVOID Handle, - IN PNTOS_BOOT_ENTRY BootEntry); + IN PBOOT_STORE_ENTRY BootEntry);
NTSTATUS -QueryNTOSBootEntry( +QueryBootStoreEntry( IN PVOID Handle, IN ULONG_PTR BootEntryKey, - OUT PNTOS_BOOT_ENTRY BootEntry); // Technically this should be PNTOS_BOOT_ENTRY* + OUT PBOOT_STORE_ENTRY BootEntry); // Technically this should be PBOOT_STORE_ENTRY*
NTSTATUS -QueryNTOSBootOptions( +QueryBootStoreOptions( IN PVOID Handle, - IN OUT PNTOS_BOOT_OPTIONS BootOptions + IN OUT PBOOT_STORE_OPTIONS BootOptions /* , IN PULONG BootOptionsLength */ );
NTSTATUS -SetNTOSBootOptions( +SetBootStoreOptions( IN PVOID Handle, - IN PNTOS_BOOT_OPTIONS BootOptions, + IN PBOOT_STORE_OPTIONS BootOptions, IN ULONG FieldsToChange);
NTSTATUS -EnumerateNTOSBootEntries( +EnumerateBootStoreEntries( IN PVOID Handle, // IN ULONG Flags, // Determine which data to retrieve IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
Modified: branches/setup_improvements/base/setup/lib/osdetect.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/li... ============================================================================== --- branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] Thu Jun 8 17:30:23 2017 @@ -69,8 +69,8 @@ static NTSTATUS NTAPI EnumerateInstallations( - IN NTOS_BOOT_LOADER_TYPE Type, - IN PNTOS_BOOT_ENTRY BootEntry, + IN BOOT_STORE_TYPE Type, + IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL) { PENUM_INSTALLS_DATA Data = (PENUM_INSTALLS_DATA)Parameter; @@ -96,8 +96,10 @@ RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) { /* This is not a ReactOS entry */ - DPRINT1(" An installation '%S' of unsupported type '%S'\n", - BootEntry->FriendlyName, BootEntry->Version ? BootEntry->Version : L"n/a"); + // DPRINT1(" An installation '%S' of unsupported type '%S'\n", + // BootEntry->FriendlyName, BootEntry->Version ? BootEntry->Version : L"n/a"); + DPRINT1(" An installation '%S' of unsupported type %lu\n", + BootEntry->FriendlyName, BootEntry->OsOptionsLength); /* Continue the enumeration */ return STATUS_SUCCESS; } @@ -635,7 +637,7 @@ OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; UNICODE_STRING PartitionRootPath; - NTOS_BOOT_LOADER_TYPE Type; + BOOT_STORE_TYPE Type; PVOID BootStoreHandle; ENUM_INSTALLS_DATA Data; ULONG Version; @@ -672,7 +674,7 @@ /* Try to see whether we recognize some NT boot loaders */ for (Type = FreeLdr; Type < BldrTypeMax; ++Type) { - Status = FindNTOSBootLoader(PartitionDirectoryHandle, Type, &Version); + Status = FindBootStore(PartitionDirectoryHandle, Type, &Version); if (!NT_SUCCESS(Status)) { /* The loader does not exist, continue with another one */ @@ -685,15 +687,15 @@ DPRINT1("Analyse the OS installations for loader type '%d' in disk #%d, partition #%d\n", Type, DiskNumber, PartitionNumber);
- Status = OpenNTOSBootLoaderStoreByHandle(&BootStoreHandle, PartitionDirectoryHandle, Type, FALSE); + Status = OpenBootStoreByHandle(&BootStoreHandle, PartitionDirectoryHandle, Type, FALSE); if (!NT_SUCCESS(Status)) { DPRINT1("Could not open the NTOS boot store of type '%d' (Status 0x%08lx), continue with another one...\n", Type, Status); continue; } - EnumerateNTOSBootEntries(BootStoreHandle, EnumerateInstallations, &Data); - CloseNTOSBootLoaderStore(BootStoreHandle); + EnumerateBootStoreEntries(BootStoreHandle, EnumerateInstallations, &Data); + CloseBootStore(BootStoreHandle); }
/* Close the partition */
Modified: branches/setup_improvements/base/setup/usetup/bootsup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] Thu Jun 8 17:30:23 2017 @@ -127,12 +127,12 @@ IN PVOID BootStoreHandle, IN PCWSTR ArcPath) { - UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; - PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry; PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; - NTOS_BOOT_OPTIONS BootOptions; - - BootEntry->Version = L"Windows2003"; + BOOT_STORE_OPTIONS BootOptions; + + BootEntry->Version = FreeLdr; BootEntry->BootFilePath = NULL;
BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); @@ -146,20 +146,20 @@ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS"); BootEntry->FriendlyName = L""ReactOS""; Options->OsLoadOptions = NULL; // L""; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS"));
/* ReactOS_Debug */ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_Debug"); BootEntry->FriendlyName = L""ReactOS (Debug)""; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Debug")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Debug"));
#ifdef _WINKD_ /* ReactOS_VBoxDebug */ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_VBoxDebug"); BootEntry->FriendlyName = L""ReactOS (VBoxDebug)""; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=VBOX /SOS"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_VBoxDebug")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_VBoxDebug")); #endif #if DBG #ifndef _WINKD_ @@ -167,34 +167,34 @@ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_KdSerial"); BootEntry->FriendlyName = L""ReactOS (RosDbg)""; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /KDSERIAL"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_KdSerial")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_KdSerial")); #endif
/* ReactOS_Screen */ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_Screen"); BootEntry->FriendlyName = L""ReactOS (Screen)""; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=SCREEN /SOS"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Screen")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Screen"));
/* ReactOS_LogFile */ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_LogFile"); BootEntry->FriendlyName = L""ReactOS (Log file)""; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=FILE /SOS"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_LogFile")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_LogFile"));
/* ReactOS_Ram */ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_Ram"); BootEntry->FriendlyName = L""ReactOS (RAM Disk)""; Options->OsLoadPath = L"ramdisk(0)\ReactOS"; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /RDPATH=reactos.img /RDIMAGEOFFSET=32256"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Ram")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Ram"));
/* ReactOS_EMS */ // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_EMS"); BootEntry->FriendlyName = L""ReactOS (Emergency Management Services)""; Options->OsLoadPath = ArcPath; Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /redirect=com2 /redirectbaudrate=115200"; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_EMS")); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_EMS")); #endif
@@ -230,7 +230,8 @@ } #endif
- SetNTOSBootOptions(BootStoreHandle, &BootOptions, 2 | 1); + BootOptions.Version = FreeLdr; + SetBootStoreOptions(BootStoreHandle, &BootOptions, 2 | 1); }
static NTSTATUS @@ -242,7 +243,7 @@ PVOID BootStoreHandle;
/* Initialize the INI file and create the common FreeLdr sections */ - Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, FreeLdr, TRUE); + Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr, TRUE); if (!NT_SUCCESS(Status)) return Status;
@@ -250,7 +251,7 @@ CreateFreeLoaderReactOSEntries(BootStoreHandle, ArcPath);
/* Close the INI file */ - CloseNTOSBootLoaderStore(BootStoreHandle); + CloseBootStore(BootStoreHandle); return STATUS_SUCCESS; }
@@ -266,19 +267,19 @@ { NTSTATUS Status; PVOID BootStoreHandle; - UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(BOOT_SECTOR_OPTIONS)]; - PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + sizeof(BOOT_SECTOR_OPTIONS)]; + PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry; PBOOT_SECTOR_OPTIONS Options = (PBOOT_SECTOR_OPTIONS)&BootEntry->OsOptions;
/* Initialize the INI file and create the common FreeLdr sections */ - Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, FreeLdr, TRUE); + Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr, TRUE); if (!NT_SUCCESS(Status)) return Status;
/* Add the ReactOS entries */ CreateFreeLoaderReactOSEntries(BootStoreHandle, ArcPath);
- /**/BootEntry->Version = L"BootSector";/**/ + BootEntry->Version = FreeLdr; BootEntry->BootFilePath = NULL;
BootEntry->OsOptionsLength = sizeof(BOOT_SECTOR_OPTIONS); @@ -292,10 +293,10 @@
// BootEntry->BootEntryKey = MAKESTRKEY(Section); BootEntry->FriendlyName = Description; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(Section)); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(Section));
/* Close the INI file */ - CloseNTOSBootLoaderStore(BootStoreHandle); + CloseBootStore(BootStoreHandle); return STATUS_SUCCESS; }
@@ -318,8 +319,8 @@ static NTSTATUS NTAPI EnumerateReactOSEntries( - IN NTOS_BOOT_LOADER_TYPE Type, - IN PNTOS_BOOT_ENTRY BootEntry, + IN BOOT_STORE_TYPE Type, + IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL) { PENUM_REACTOS_ENTRIES_DATA Data = (PENUM_REACTOS_ENTRIES_DATA)Parameter; @@ -336,9 +337,10 @@ RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) { /* This is not a ReactOS entry */ - DPRINT1(" An installation '%S' of unsupported type '%S'\n", - BootEntry->FriendlyName, - BootEntry->Version ? BootEntry->Version : L"n/a"); + // DPRINT1(" An installation '%S' of unsupported type '%S'\n", + // BootEntry->FriendlyName, BootEntry->Version ? BootEntry->Version : L"n/a"); + DPRINT1(" An installation '%S' of unsupported type %lu\n", + BootEntry->FriendlyName, BootEntry->OsOptionsLength); /* Continue the enumeration */ goto SkipThisEntry; } @@ -397,12 +399,12 @@ NTSTATUS Status; PVOID BootStoreHandle; ENUM_REACTOS_ENTRIES_DATA Data; - UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; - PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry; PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
/* Open the INI file */ - Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, FreeLdr, /*TRUE*/ FALSE); + Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr, /*TRUE*/ FALSE); if (!NT_SUCCESS(Status)) return Status;
@@ -414,10 +416,10 @@ StringCchCopyW(Data.OsName, ARRAYSIZE(Data.OsName), L""ReactOS"");
// - // FIXME: We temporarily use EnumerateNTOSBootEntries, until - // both QueryNTOSBootEntry and ModifyNTOSBootEntry get implemented. + // FIXME: We temporarily use EnumerateBootStoreEntries, until + // both QueryBootStoreEntry and ModifyBootStoreEntry get implemented. // - Status = EnumerateNTOSBootEntries(BootStoreHandle, EnumerateReactOSEntries, &Data); + Status = EnumerateBootStoreEntries(BootStoreHandle, EnumerateReactOSEntries, &Data);
/* Create a new "ReactOS" entry if there is none already existing that suits us */ if (!Data.UseExistingEntry) @@ -425,7 +427,7 @@ // StringCchPrintfW(Data.SectionName, ARRAYSIZE(Data.SectionName), L"ReactOS_%lu", Data.i); // StringCchPrintfW(Data.OsName, ARRAYSIZE(Data.OsName), L""ReactOS %lu"", Data.i);
- BootEntry->Version = L"Windows2003"; + BootEntry->Version = FreeLdr; BootEntry->BootFilePath = NULL;
BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); @@ -438,11 +440,11 @@ // BootEntry->BootEntryKey = MAKESTRKEY(Data.SectionName); BootEntry->FriendlyName = Data.OsName; Options->OsLoadOptions = NULL; // L""; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(Data.SectionName)); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(Data.SectionName)); }
/* Close the INI file */ - CloseNTOSBootLoaderStore(BootStoreHandle); + CloseBootStore(BootStoreHandle); return STATUS_SUCCESS; }
@@ -458,12 +460,12 @@ ENUM_REACTOS_ENTRIES_DATA Data;
// NOTE: Technically it would be "BootSector"... - UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; - PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry; PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
/* Open the INI file */ - Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, NtLdr, FALSE); + Status = OpenBootStore(&BootStoreHandle, IniPath, NtLdr, FALSE); if (!NT_SUCCESS(Status)) return Status;
@@ -475,16 +477,16 @@ StringCchCopyW(Data.OsName, ARRAYSIZE(Data.OsName), L""ReactOS"");
// - // FIXME: We temporarily use EnumerateNTOSBootEntries, until - // both QueryNTOSBootEntry and ModifyNTOSBootEntry get implemented. + // FIXME: We temporarily use EnumerateBootStoreEntries, until + // both QueryBootStoreEntry and ModifyBootStoreEntry get implemented. // - Status = EnumerateNTOSBootEntries(BootStoreHandle, EnumerateReactOSEntries, &Data); + Status = EnumerateBootStoreEntries(BootStoreHandle, EnumerateReactOSEntries, &Data);
/* If either the key was not found, or contains something else, add a new one */ if (!Data.UseExistingEntry /* || ( (Status == STATUS_NO_MORE_ENTRIES) && wcscmp(Data.OsName, EntryValue) ) */) { - BootEntry->Version = L"Windows2003"; // NOTE: See remark above + BootEntry->Version = NtLdr; BootEntry->BootFilePath = NULL;
BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); @@ -498,11 +500,11 @@ // BootEntry->FriendlyName = Data.OsName; BootEntry->FriendlyName = EntryValue; Options->OsLoadOptions = NULL; // L""; - AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(0 /*Data.SectionName*/)); + AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(0 /*Data.SectionName*/)); }
/* Close the INI file */ - CloseNTOSBootLoaderStore(BootStoreHandle); + CloseBootStore(BootStoreHandle); return STATUS_SUCCESS; // Status; }
@@ -1777,8 +1779,8 @@ /* Check for NT and other bootloaders */
// FIXME: Check for Vista+ bootloader! - /*** Status = FindNTOSBootLoader(PartitionHandle, NtLdr, &Version); ***/ - /*** Status = FindNTOSBootLoader(PartitionHandle, BootMgr, &Version); ***/ + /*** Status = FindBootStore(PartitionHandle, NtLdr, &Version); ***/ + /*** Status = FindBootStore(PartitionHandle, BootMgr, &Version); ***/ if (DoesFileExist_2(SystemRootPath->Buffer, L"NTLDR") == TRUE || DoesFileExist_2(SystemRootPath->Buffer, L"BOOT.INI") == TRUE) {