2017-05-25 23:52:50 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Setup Library
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
2017-06-08 17:30:23 +00:00
|
|
|
* PURPOSE: Boot Stores Management functionality, with support for
|
|
|
|
* NT 5.x family (MS Windows <= 2003, and ReactOS) bootloaders.
|
2017-05-25 23:52:50 +00:00
|
|
|
* COPYRIGHT: Copyright 2017-2018 Hermes Belusca-Maito
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TODO: Add support for NT 6.x family! (detection + BCD manipulation).
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
#include "bldrsup.h"
|
|
|
|
#include "filesup.h"
|
|
|
|
#include "inicache.h"
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
|
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
typedef NTSTATUS
|
|
|
|
(*POPEN_BOOT_STORE)(
|
2024-05-04 10:38:07 +00:00
|
|
|
_Out_ PVOID* Handle,
|
|
|
|
_In_ HANDLE PartitionDirectoryHandle, // _In_opt_
|
|
|
|
_In_ BOOT_STORE_TYPE Type,
|
|
|
|
_In_ BOOT_STORE_OPENMODE OpenMode,
|
|
|
|
_In_ BOOT_STORE_ACCESS Access);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
typedef NTSTATUS
|
|
|
|
(*PCLOSE_BOOT_STORE)(
|
2024-05-04 10:38:07 +00:00
|
|
|
_In_ PVOID Handle);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
typedef NTSTATUS
|
|
|
|
(*PENUM_BOOT_STORE_ENTRIES)(
|
|
|
|
IN PVOID Handle,
|
|
|
|
// IN ULONG Flags, // Determine which data to retrieve
|
|
|
|
IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
|
|
|
|
IN PVOID Parameter OPTIONAL);
|
|
|
|
|
2017-05-25 23:52:50 +00:00
|
|
|
typedef struct _NTOS_BOOT_LOADER_FILES
|
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
BOOT_STORE_TYPE Type;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
PCZZWSTR LoaderExecutables;
|
2017-05-25 23:52:50 +00:00
|
|
|
PCWSTR LoaderConfigurationFile;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
POPEN_BOOT_STORE OpenBootStore;
|
|
|
|
PCLOSE_BOOT_STORE CloseBootStore;
|
|
|
|
PENUM_BOOT_STORE_ENTRIES EnumBootStoreEntries;
|
2017-05-25 23:52:50 +00:00
|
|
|
} NTOS_BOOT_LOADER_FILES, *PNTOS_BOOT_LOADER_FILES;
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Header for particular store contexts
|
|
|
|
*/
|
|
|
|
typedef struct _BOOT_STORE_CONTEXT
|
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
BOOT_STORE_TYPE Type;
|
2024-05-04 10:38:07 +00:00
|
|
|
BOOLEAN ReadOnly;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
// PNTOS_BOOT_LOADER_FILES ??
|
|
|
|
/*
|
|
|
|
PVOID PrivateData;
|
|
|
|
*/
|
|
|
|
} BOOT_STORE_CONTEXT, *PBOOT_STORE_CONTEXT;
|
|
|
|
|
|
|
|
typedef struct _BOOT_STORE_INI_CONTEXT
|
|
|
|
{
|
|
|
|
BOOT_STORE_CONTEXT Header;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If all these members are NULL, we know that the store is freshly created
|
|
|
|
* and is cached in memory only. At file closure we will therefore need to
|
|
|
|
* create the file proper and save its contents.
|
|
|
|
*/
|
|
|
|
HANDLE FileHandle;
|
|
|
|
HANDLE SectionHandle;
|
|
|
|
// SIZE_T ViewSize;
|
|
|
|
ULONG FileSize;
|
|
|
|
PVOID ViewBase;
|
|
|
|
|
|
|
|
PINICACHE IniCache;
|
2024-04-23 19:09:36 +00:00
|
|
|
PINI_SECTION OptionsIniSection;
|
|
|
|
PINI_SECTION OsIniSection;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
} BOOT_STORE_INI_CONTEXT, *PBOOT_STORE_INI_CONTEXT;
|
|
|
|
|
|
|
|
// TODO!
|
|
|
|
typedef struct _BOOT_STORE_BCDREG_CONTEXT
|
|
|
|
{
|
|
|
|
BOOT_STORE_CONTEXT Header;
|
|
|
|
ULONG PlaceHolder;
|
|
|
|
} BOOT_STORE_BCDREG_CONTEXT, *PBOOT_STORE_BCDREG_CONTEXT;
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
OpenIniBootLoaderStore(
|
2024-05-04 10:38:07 +00:00
|
|
|
_Out_ PVOID* Handle,
|
|
|
|
_In_ HANDLE PartitionDirectoryHandle, // _In_opt_
|
|
|
|
_In_ BOOT_STORE_TYPE Type,
|
|
|
|
_In_ BOOT_STORE_OPENMODE OpenMode,
|
|
|
|
_In_ BOOT_STORE_ACCESS Access);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
CloseIniBootLoaderStore(
|
2024-05-04 10:38:07 +00:00
|
|
|
_In_ PVOID Handle);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
FreeLdrEnumerateBootEntries(
|
|
|
|
IN PBOOT_STORE_INI_CONTEXT BootStore,
|
|
|
|
// IN ULONG Flags, // Determine which data to retrieve
|
|
|
|
IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
|
|
|
|
IN PVOID Parameter OPTIONAL);
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
NtLdrEnumerateBootEntries(
|
|
|
|
IN PBOOT_STORE_INI_CONTEXT BootStore,
|
|
|
|
// IN ULONG Flags, // Determine which data to retrieve
|
|
|
|
IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
|
|
|
|
IN PVOID Parameter OPTIONAL);
|
|
|
|
|
|
|
|
|
2017-05-25 23:52:50 +00:00
|
|
|
// Question 1: What if config file is optional?
|
|
|
|
// Question 2: What if many config files are possible?
|
|
|
|
NTOS_BOOT_LOADER_FILES NtosBootLoaders[] =
|
|
|
|
{
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{FreeLdr, L"freeldr.sys\0", L"freeldr.ini",
|
|
|
|
OpenIniBootLoaderStore, CloseIniBootLoaderStore, (PENUM_BOOT_STORE_ENTRIES)FreeLdrEnumerateBootEntries},
|
|
|
|
{NtLdr , L"ntldr\0" L"osloader.exe\0", L"boot.ini",
|
|
|
|
OpenIniBootLoaderStore, CloseIniBootLoaderStore, (PENUM_BOOT_STORE_ENTRIES)NtLdrEnumerateBootEntries },
|
|
|
|
// {SetupLdr, L"setupldr\0" L"setupldr.bin\0" L"setupldr.exe\0", L"txtsetup.sif", UNIMPLEMENTED, UNIMPLEMENTED, UNIMPLEMENTED}
|
|
|
|
// {BootMgr , L"bootmgr", L"BCD", UNIMPLEMENTED, UNIMPLEMENTED, UNIMPLEMENTED}
|
2017-05-25 23:52:50 +00:00
|
|
|
};
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
C_ASSERT(_countof(NtosBootLoaders) == BldrTypeMax);
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
enum BOOT_OPTION
|
|
|
|
{
|
|
|
|
BO_TimeOut,
|
|
|
|
BO_DefaultOS,
|
|
|
|
};
|
|
|
|
static const PCWSTR BootOptionNames[][2] =
|
|
|
|
{
|
|
|
|
{L"TimeOut", L"DefaultOS"}, // FreeLdr
|
|
|
|
{L"timeout", L"default" } // NtLdr
|
|
|
|
};
|
|
|
|
|
2017-05-25 23:52:50 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
FindBootStore( // By handle
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN HANDLE PartitionDirectoryHandle, // OPTIONAL
|
2017-06-08 17:30:23 +00:00
|
|
|
IN BOOT_STORE_TYPE Type,
|
|
|
|
OUT PULONG VersionNumber OPTIONAL)
|
2017-05-25 23:52:50 +00:00
|
|
|
// OUT PHANDLE ConfigFileHande OPTIONAL ????
|
|
|
|
{
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
PCWSTR LoaderExecutable;
|
2017-05-25 23:52:50 +00:00
|
|
|
// UINT i;
|
|
|
|
|
|
|
|
if (Type >= BldrTypeMax)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
2017-06-08 17:30:23 +00:00
|
|
|
if (VersionNumber)
|
|
|
|
*VersionNumber = 0;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/* Check whether any of the loader executables exist */
|
|
|
|
LoaderExecutable = NtosBootLoaders[Type].LoaderExecutables;
|
|
|
|
while (*LoaderExecutable)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (DoesFileExist(PartitionDirectoryHandle, LoaderExecutable))
|
|
|
|
{
|
|
|
|
/* A loader was found, stop there */
|
2018-10-28 22:33:29 +00:00
|
|
|
DPRINT("Found loader executable '%S'\n", LoaderExecutable);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-05-25 23:52:50 +00:00
|
|
|
/* The loader does not exist, continue with another one */
|
2018-10-28 22:33:29 +00:00
|
|
|
DPRINT("Loader executable '%S' does not exist, continue with another one...\n", LoaderExecutable);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
LoaderExecutable += wcslen(LoaderExecutable) + 1;
|
|
|
|
}
|
|
|
|
if (!*LoaderExecutable)
|
|
|
|
{
|
|
|
|
/* No loader was found */
|
2018-10-28 22:33:29 +00:00
|
|
|
DPRINT("No loader executable was found\n");
|
2017-05-25 23:52:50 +00:00
|
|
|
return STATUS_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/* Check for loader version if needed */
|
2017-06-08 17:30:23 +00:00
|
|
|
if (VersionNumber)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
*VersionNumber = 0;
|
|
|
|
// TODO: Check for BLDR version!
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
2017-05-25 23:52:50 +00:00
|
|
|
/* Check whether the loader configuration file exists */
|
|
|
|
#if 0
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Status = OpenAndMapFile(PartitionDirectoryHandle, NtosBootLoaders[Type].LoaderConfigurationFile,
|
2024-05-04 10:35:24 +00:00
|
|
|
&FileHandle, &FileSize, &SectionHandle, &ViewBase, FALSE);
|
2017-05-25 23:52:50 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2024-05-04 10:38:07 +00:00
|
|
|
#else
|
|
|
|
if (!DoesFileExist(PartitionDirectoryHandle, NtosBootLoaders[Type].LoaderConfigurationFile))
|
|
|
|
#endif
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
|
|
|
/* The loader does not exist, continue with another one */
|
|
|
|
// FIXME: Consider it might be optional??
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
DPRINT1("Loader configuration file '%S' does not exist\n", NtosBootLoaders[Type].LoaderConfigurationFile);
|
2017-05-25 23:52:50 +00:00
|
|
|
return STATUS_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-23 15:02:06 +00:00
|
|
|
//
|
|
|
|
// TEMPORARY functions to migrate the DEPRECATED BootDrive and BootPartition
|
|
|
|
// values of BootSector boot entries in FREELDR.INI to the newer BootPath value.
|
|
|
|
//
|
|
|
|
// REMOVE THEM once they won't be necessary anymore,
|
|
|
|
// after the removal of their support in FreeLoader!
|
|
|
|
//
|
|
|
|
static VOID
|
|
|
|
FreeLdrMigrateBootDrivePartWorker(
|
|
|
|
_In_ PINI_SECTION OsIniSection)
|
|
|
|
{
|
|
|
|
PCWSTR KeyData;
|
|
|
|
PINI_KEYWORD OldKey;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether we have a "BootPath" value (takes precedence
|
|
|
|
* over both "BootDrive" and "BootPartition").
|
|
|
|
*/
|
|
|
|
if (IniGetKey(OsIniSection, L"BootPath", &KeyData) && KeyData && *KeyData)
|
|
|
|
{
|
|
|
|
/* We already have a BootPath value, do nothing more */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We don't have one: retrieve the BIOS drive and
|
|
|
|
* partition and convert them to a valid ARC path */
|
|
|
|
|
|
|
|
/* Retrieve the boot drive */
|
|
|
|
OldKey = IniGetKey(OsIniSection, L"BootDrive", &KeyData);
|
|
|
|
if (OldKey)
|
|
|
|
{
|
|
|
|
PCWSTR OldDrive = KeyData;
|
|
|
|
ULONG DriveNumber = 0;
|
|
|
|
ULONG PartitionNumber = 0;
|
|
|
|
UCHAR DriveType = 0;
|
|
|
|
WCHAR BufferBootPath[80]; // 80 chars is enough for "multi(0)disk(0)rdisk(x)partition(y)", with (x,y) == MAXULONG
|
|
|
|
|
|
|
|
/* If a number string is given, then just
|
|
|
|
* convert it to decimal (BIOS HW only) */
|
|
|
|
PCWCH p = KeyData;
|
|
|
|
if (p[0] >= L'0' && p[0] <= L'9')
|
|
|
|
{
|
|
|
|
DriveNumber = wcstoul(p, (PWCHAR*)&p, 0);
|
|
|
|
if (DriveNumber >= 0x80)
|
|
|
|
{
|
|
|
|
/* It's quite probably a hard disk */
|
|
|
|
DriveNumber -= 0x80;
|
|
|
|
DriveType = L'h';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* It's quite probably a floppy */
|
|
|
|
DriveType = L'f';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (p[0] && towlower(p[1]) == L'd')
|
|
|
|
{
|
|
|
|
/* Convert the drive number string into a number: 'hd1' = 1 */
|
|
|
|
DriveType = tolower(p[0]);
|
|
|
|
DriveNumber = _wtoi(&p[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Retrieve the boot partition (optional, fall back to zero otherwise) */
|
|
|
|
if (IniGetKey(OsIniSection, L"BootPartition", &KeyData))
|
|
|
|
PartitionNumber = _wtoi(KeyData);
|
|
|
|
|
|
|
|
if (DriveType == L'f')
|
|
|
|
{
|
|
|
|
/* Floppy disk path: multi(0)disk(0)fdisk(x) */
|
|
|
|
RtlStringCchPrintfW(BufferBootPath, _countof(BufferBootPath),
|
|
|
|
L"multi(0)disk(0)fdisk(%lu)", DriveNumber);
|
|
|
|
}
|
|
|
|
else if (DriveType == L'h')
|
|
|
|
{
|
|
|
|
/* Hard disk path: multi(0)disk(0)rdisk(x)partition(y) */
|
|
|
|
RtlStringCchPrintfW(BufferBootPath, _countof(BufferBootPath),
|
|
|
|
L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
|
|
|
|
DriveNumber, PartitionNumber);
|
|
|
|
}
|
|
|
|
else if (DriveType == L'c')
|
|
|
|
{
|
|
|
|
/* CD-ROM disk path: multi(0)disk(0)cdrom(x) */
|
|
|
|
RtlStringCchPrintfW(BufferBootPath, _countof(BufferBootPath),
|
|
|
|
L"multi(0)disk(0)cdrom(%lu)", DriveNumber);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This case should rarely happen, if ever */
|
|
|
|
DPRINT1("Unrecognized BootDrive type '%C'\n", DriveType ? DriveType : L'?');
|
|
|
|
|
|
|
|
/* Build the boot path in the form: hdX,Y */
|
|
|
|
RtlStringCchCopyW(BufferBootPath, _countof(BufferBootPath), OldDrive);
|
|
|
|
if (KeyData && *KeyData)
|
|
|
|
{
|
|
|
|
RtlStringCchCatW(BufferBootPath, _countof(BufferBootPath), L",");
|
|
|
|
RtlStringCchCatW(BufferBootPath, _countof(BufferBootPath), KeyData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the new BootPath value */
|
|
|
|
IniInsertKey(OsIniSection, OldKey, INSERT_BEFORE, L"BootPath", BufferBootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete the deprecated BootDrive and BootPartition values */
|
|
|
|
IniRemoveKeyByName(OsIniSection, L"BootDrive");
|
|
|
|
IniRemoveKeyByName(OsIniSection, L"BootPartition");
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
FreeLdrMigrateBootDrivePart(
|
|
|
|
_In_ PBOOT_STORE_INI_CONTEXT BootStore)
|
|
|
|
{
|
|
|
|
PINICACHEITERATOR Iterator;
|
|
|
|
PINI_SECTION OsIniSection;
|
|
|
|
PCWSTR SectionName, KeyData;
|
|
|
|
|
|
|
|
/* Enumerate all the valid entries in the "Operating Systems" section */
|
|
|
|
Iterator = IniFindFirstValue(BootStore->OsIniSection, &SectionName, &KeyData);
|
|
|
|
if (!Iterator) return;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Search for an existing boot entry section */
|
|
|
|
OsIniSection = IniGetSection(BootStore->IniCache, SectionName);
|
|
|
|
if (!OsIniSection)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Check for boot type to migrate */
|
|
|
|
if (!IniGetKey(OsIniSection, L"BootType", &KeyData) || !KeyData)
|
|
|
|
{
|
|
|
|
/* Certainly not a ReactOS installation */
|
|
|
|
DPRINT1("No BootType value present\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((_wcsicmp(KeyData, L"Drive") == 0) ||
|
|
|
|
(_wcsicmp(KeyData, L"\"Drive\"") == 0) ||
|
|
|
|
(_wcsicmp(KeyData, L"Partition") == 0) ||
|
|
|
|
(_wcsicmp(KeyData, L"\"Partition\"") == 0))
|
|
|
|
{
|
|
|
|
/* Modify the BootPath value */
|
|
|
|
IniAddKey(OsIniSection, L"BootType", L"BootSector");
|
|
|
|
goto migrate_drivepart;
|
|
|
|
}
|
|
|
|
if ((_wcsicmp(KeyData, L"BootSector") == 0) ||
|
|
|
|
(_wcsicmp(KeyData, L"\"BootSector\"") == 0))
|
|
|
|
{
|
|
|
|
migrate_drivepart:
|
|
|
|
DPRINT("This is a '%S' boot entry\n", KeyData);
|
|
|
|
FreeLdrMigrateBootDrivePartWorker(OsIniSection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (IniFindNextValue(Iterator, &SectionName, &KeyData));
|
|
|
|
|
|
|
|
IniFindClose(Iterator);
|
|
|
|
}
|
|
|
|
//////////////
|
|
|
|
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
static VOID
|
|
|
|
CreateCommonFreeLdrSections(
|
|
|
|
IN OUT PBOOT_STORE_INI_CONTEXT BootStore)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-04-23 19:09:36 +00:00
|
|
|
PINI_SECTION IniSection;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/*
|
|
|
|
* Cache the "FREELOADER" section for our future usage.
|
|
|
|
*/
|
|
|
|
|
2024-04-23 20:40:31 +00:00
|
|
|
/* Create the "FREELOADER" section */
|
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"FREELOADER");
|
2024-04-23 19:09:36 +00:00
|
|
|
if (!IniSection)
|
|
|
|
DPRINT1("CreateCommonFreeLdrSections: Failed to create 'FREELOADER' section!\n");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
BootStore->OptionsIniSection = IniSection;
|
|
|
|
|
2022-02-15 00:19:42 +00:00
|
|
|
/* TimeOut */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniAddKey(BootStore->OptionsIniSection, L"TimeOut", L"0");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/* Create "Display" section */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"Display");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-04-23 19:09:36 +00:00
|
|
|
/* TitleText and MinimalUI */
|
|
|
|
IniAddKey(IniSection, L"TitleText", L"ReactOS Boot Manager");
|
|
|
|
IniAddKey(IniSection, L"MinimalUI", L"Yes");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cache the "Operating Systems" section for our future usage.
|
|
|
|
*/
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-04-23 20:40:31 +00:00
|
|
|
/* Create the "Operating Systems" section */
|
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"Operating Systems");
|
2024-04-23 19:09:36 +00:00
|
|
|
if (!IniSection)
|
|
|
|
DPRINT1("CreateCommonFreeLdrSections: Failed to create 'Operating Systems' section!\n");
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
BootStore->OsIniSection = IniSection;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
OpenIniBootLoaderStore(
|
2024-05-04 10:38:07 +00:00
|
|
|
_Out_ PVOID* Handle,
|
|
|
|
_In_ HANDLE PartitionDirectoryHandle, // _In_opt_
|
|
|
|
_In_ BOOT_STORE_TYPE Type,
|
|
|
|
_In_ BOOT_STORE_OPENMODE OpenMode,
|
|
|
|
_In_ BOOT_STORE_ACCESS Access)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PBOOT_STORE_INI_CONTEXT BootStore;
|
2024-05-04 10:38:07 +00:00
|
|
|
UNICODE_STRING Name;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
ACCESS_MASK DesiredAccess;
|
|
|
|
ULONG CreateDisposition;
|
|
|
|
|
|
|
|
//
|
|
|
|
// WARNING! We support the INI creation *ONLY* for FreeLdr, and not for NTLDR
|
|
|
|
//
|
|
|
|
if ((Type == NtLdr) && (OpenMode == BS_CreateNew || OpenMode == BS_CreateAlways || OpenMode == BS_RecreateExisting))
|
|
|
|
{
|
|
|
|
DPRINT1("OpenIniBootLoaderStore() unsupported for NTLDR\n");
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/* Create a boot store structure */
|
|
|
|
BootStore = RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, sizeof(*BootStore));
|
|
|
|
if (!BootStore)
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
|
|
|
|
BootStore->Header.Type = Type;
|
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/*
|
|
|
|
* So far, we only use the INI cache. The file itself is not created or
|
|
|
|
* opened yet, therefore FileHandle, SectionHandle, ViewBase and FileSize
|
|
|
|
* are all NULL. We will use this fact to know that the INI file was indeed
|
|
|
|
* created, and not just opened as an existing file.
|
|
|
|
*/
|
|
|
|
// BootStore->FileHandle = NULL;
|
|
|
|
BootStore->SectionHandle = NULL;
|
|
|
|
BootStore->ViewBase = NULL;
|
|
|
|
BootStore->FileSize = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create or open the loader configuration INI file as necessary.
|
|
|
|
*/
|
|
|
|
RtlInitUnicodeString(&Name, NtosBootLoaders[Type].LoaderConfigurationFile);
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&Name,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
PartitionDirectoryHandle,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
DesiredAccess =
|
|
|
|
((Access & BS_ReadAccess ) ? FILE_GENERIC_READ : 0) |
|
|
|
|
((Access & BS_WriteAccess) ? FILE_GENERIC_WRITE : 0);
|
|
|
|
|
|
|
|
CreateDisposition = FILE_OPEN;
|
|
|
|
switch (OpenMode)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
case BS_CreateNew:
|
|
|
|
CreateDisposition = FILE_CREATE;
|
|
|
|
break;
|
|
|
|
case BS_CheckExisting:
|
|
|
|
case BS_OpenExisting:
|
|
|
|
CreateDisposition = FILE_OPEN;
|
|
|
|
break;
|
|
|
|
case BS_OpenAlways:
|
|
|
|
CreateDisposition = FILE_OPEN_IF;
|
|
|
|
break;
|
|
|
|
case BS_RecreateExisting:
|
|
|
|
CreateDisposition = FILE_OVERWRITE;
|
|
|
|
break;
|
|
|
|
case BS_CreateAlways:
|
|
|
|
CreateDisposition = FILE_OVERWRITE_IF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
IoStatusBlock.Information = 0;
|
|
|
|
Status = NtCreateFile(&BootStore->FileHandle,
|
|
|
|
DesiredAccess | SYNCHRONIZE,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&IoStatusBlock,
|
|
|
|
NULL,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
FILE_SHARE_READ,
|
|
|
|
CreateDisposition,
|
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY | FILE_NON_DIRECTORY_FILE,
|
|
|
|
NULL,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (OpenMode == BS_CheckExisting)
|
|
|
|
{
|
|
|
|
/* We just want to check for file existence. If we either succeeded
|
|
|
|
* opening the file, or we failed because it exists but we do not
|
|
|
|
* currently have access to it, return success in either case. */
|
|
|
|
BOOLEAN Success = (NT_SUCCESS(Status) || (Status == STATUS_ACCESS_DENIED));
|
|
|
|
if (!Success)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
DPRINT1("Couldn't find Loader configuration file '%S'\n",
|
|
|
|
NtosBootLoaders[Type].LoaderConfigurationFile);
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
2024-05-04 10:38:07 +00:00
|
|
|
if (BootStore->FileHandle)
|
|
|
|
NtClose(BootStore->FileHandle);
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
|
|
|
return (Success ? STATUS_SUCCESS : Status);
|
|
|
|
}
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/*
|
|
|
|
* If create/open failed because the file is in read-only mode,
|
|
|
|
* change its attributes and re-attempt opening it.
|
|
|
|
*/
|
|
|
|
if (Status == STATUS_ACCESS_DENIED) do
|
|
|
|
{
|
|
|
|
FILE_BASIC_INFORMATION FileInfo = {0};
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Reattempt to open it with limited access */
|
|
|
|
Status = NtCreateFile(&BootStore->FileHandle,
|
|
|
|
FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&IoStatusBlock,
|
|
|
|
NULL,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
FILE_SHARE_READ,
|
|
|
|
FILE_OPEN,
|
|
|
|
FILE_NO_INTERMEDIATE_BUFFERING |
|
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY | FILE_NON_DIRECTORY_FILE,
|
|
|
|
NULL,
|
|
|
|
0);
|
|
|
|
/* Fail for real if we cannot open it that way */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
break;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Reset attributes to normal, no read-only */
|
|
|
|
FileInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/*
|
2024-05-04 10:38:07 +00:00
|
|
|
* We basically don't care about whether it succeeds:
|
|
|
|
* if it didn't, later open will fail.
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
*/
|
2024-05-04 10:38:07 +00:00
|
|
|
NtSetInformationFile(BootStore->FileHandle, &IoStatusBlock,
|
|
|
|
&FileInfo, sizeof(FileInfo),
|
|
|
|
FileBasicInformation);
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Close file */
|
|
|
|
NtClose(BootStore->FileHandle);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* And re-attempt create/open */
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Status = NtCreateFile(&BootStore->FileHandle,
|
2024-05-04 10:38:07 +00:00
|
|
|
DesiredAccess | SYNCHRONIZE,
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
&ObjectAttributes,
|
|
|
|
&IoStatusBlock,
|
|
|
|
NULL,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
2024-05-04 10:38:07 +00:00
|
|
|
FILE_SHARE_READ,
|
|
|
|
CreateDisposition,
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY | FILE_NON_DIRECTORY_FILE,
|
|
|
|
NULL,
|
|
|
|
0);
|
2024-05-04 10:38:07 +00:00
|
|
|
} while (0);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Couldn't open Loader configuration file '%S' (Status 0x%08lx)\n",
|
|
|
|
NtosBootLoaders[Type].LoaderConfigurationFile, Status);
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
BootStore->Header.ReadOnly = !(Access & BS_WriteAccess);
|
|
|
|
|
|
|
|
if (IoStatusBlock.Information == FILE_CREATED || // with: FILE_CREATE, FILE_OVERWRITE_IF, FILE_OPEN_IF, FILE_SUPERSEDE
|
|
|
|
IoStatusBlock.Information == FILE_OVERWRITTEN || // with: FILE_OVERWRITE, FILE_OVERWRITE_IF
|
|
|
|
IoStatusBlock.Information == FILE_SUPERSEDED) // with: FILE_SUPERSEDE
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The loader configuration INI file is (re)created
|
|
|
|
* fresh new, initialize its cache and its contents.
|
|
|
|
*/
|
|
|
|
BootStore->IniCache = IniCacheCreate();
|
|
|
|
if (!BootStore->IniCache)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
DPRINT1("IniCacheCreate() failed\n");
|
|
|
|
NtClose(BootStore->FileHandle);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
2024-05-04 10:38:07 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
if (Type == FreeLdr)
|
|
|
|
CreateCommonFreeLdrSections(BootStore);
|
|
|
|
}
|
2024-05-04 10:38:07 +00:00
|
|
|
else // if (IoStatusBlock.Information == FILE_OPENED) // with: FILE_OPEN, FILE_OPEN_IF
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2024-04-23 19:09:36 +00:00
|
|
|
PINI_SECTION IniSection;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/*
|
2024-05-04 10:38:07 +00:00
|
|
|
* The loader configuration INI file exists and is opened,
|
|
|
|
* map its file contents into memory.
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
*/
|
2024-05-04 10:38:07 +00:00
|
|
|
#if 0
|
|
|
|
// FIXME: &BootStore->FileSize
|
|
|
|
Status = MapFile(BootStore->FileHandle,
|
|
|
|
&BootStore->SectionHandle,
|
|
|
|
&BootStore->ViewBase,
|
|
|
|
(Access & BS_WriteAccess));
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
DPRINT1("Failed to map Loader configuration file '%S' (Status 0x%08lx)\n",
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
NtosBootLoaders[Type].LoaderConfigurationFile, Status);
|
2024-05-04 10:38:07 +00:00
|
|
|
NtClose(BootStore->FileHandle);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
|
|
|
return Status;
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
2024-05-04 10:38:07 +00:00
|
|
|
#else
|
|
|
|
BootStore->SectionHandle = UlongToPtr(1); // Workaround for CloseIniBootLoaderStore
|
|
|
|
#endif
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/* Open an *existing* INI configuration file */
|
2024-05-04 10:38:07 +00:00
|
|
|
#if 0
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Status = IniCacheLoadFromMemory(&BootStore->IniCache,
|
|
|
|
BootStore->ViewBase,
|
|
|
|
BootStore->FileSize,
|
|
|
|
FALSE);
|
2024-05-04 10:38:07 +00:00
|
|
|
#else
|
|
|
|
Status = IniCacheLoadByHandle(&BootStore->IniCache, BootStore->FileHandle, FALSE);
|
|
|
|
#endif
|
2017-05-25 23:52:50 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
DPRINT1("IniCacheLoadFromMemory() failed (Status 0x%08lx)\n", Status);
|
2024-05-04 10:38:07 +00:00
|
|
|
#if 0
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/* Finally, unmap and close the file */
|
2017-08-23 12:20:15 +00:00
|
|
|
UnMapAndCloseFile(BootStore->FileHandle,
|
|
|
|
BootStore->SectionHandle,
|
|
|
|
BootStore->ViewBase);
|
2024-05-04 10:38:07 +00:00
|
|
|
#else
|
|
|
|
NtClose(BootStore->FileHandle);
|
|
|
|
#endif
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
|
|
|
return Status;
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (Type == FreeLdr)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Cache the "FREELOADER" section for our future usage.
|
|
|
|
*/
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-04-23 19:09:36 +00:00
|
|
|
/* Get or create the "FREELOADER" section */
|
2024-05-04 10:38:07 +00:00
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"FREELOADER");
|
2024-04-23 19:09:36 +00:00
|
|
|
if (!IniSection)
|
|
|
|
DPRINT1("OpenIniBootLoaderStore: Failed to retrieve 'FREELOADER' section!\n");
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
BootStore->OptionsIniSection = IniSection;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/*
|
|
|
|
* Cache the "Operating Systems" section for our future usage.
|
|
|
|
*/
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-04-23 19:09:36 +00:00
|
|
|
/* Get or create the "Operating Systems" section */
|
2024-05-04 10:38:07 +00:00
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"Operating Systems");
|
2024-04-23 19:09:36 +00:00
|
|
|
if (!IniSection)
|
|
|
|
DPRINT1("OpenIniBootLoaderStore: Failed to retrieve 'Operating Systems' section!\n");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
BootStore->OsIniSection = IniSection;
|
2024-04-23 15:02:06 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// TEMPORARY: Migrate the DEPRECATED BootDrive and BootPartition
|
|
|
|
// values of BootSector boot entries to the newer BootPath value.
|
|
|
|
//
|
|
|
|
FreeLdrMigrateBootDrivePart(BootStore);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (Type == NtLdr)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Cache the "boot loader" section for our future usage.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* HISTORICAL NOTE:
|
|
|
|
*
|
|
|
|
* While the "operating systems" section acquired its definitive
|
|
|
|
* name already when Windows NT was at its very early beta stage
|
|
|
|
* (NT 3.1 October 1991 Beta, 10-16-1991), this was not the case
|
|
|
|
* for its general settings section "boot loader".
|
|
|
|
*
|
|
|
|
* The following section names were successively introduced:
|
|
|
|
*
|
|
|
|
* - In NT 3.1 October 1991 Beta, 10-16-1991, using OS Loader V1.5,
|
|
|
|
* the section was named "multiboot".
|
|
|
|
*
|
|
|
|
* - In the next public beta version NT 3.10.340 Beta, 10-12-1992,
|
|
|
|
* using OS Loader V2.10, a new name was introduced: "flexboot".
|
|
|
|
* This is around this time that the NT OS Loader was also
|
|
|
|
* introduced as the "Windows NT FlexBoot" loader, as shown by
|
|
|
|
* the Windows NT FAQs that circulated around this time:
|
|
|
|
* http://cd.textfiles.com/cica9308/CIS_LIBS/WINNT/1/NTFAQ.TXT
|
|
|
|
* http://cd.textfiles.com/cica/cica9308/UNZIPPED/NT/NTFAQ/FTP/NEWS/NTFAQ1.TXT
|
|
|
|
* I can only hypothesize that the "FlexBoot" name was chosen
|
|
|
|
* as a marketing coup, possibly to emphasise its "flexibility"
|
|
|
|
* as a simple multiboot-aware boot manager.
|
|
|
|
*
|
|
|
|
* - A bit later, with NT 3.10.404 Beta, 3-7-1993, using an updated
|
|
|
|
* version of OS Loader V2.10, the final section name "boot loader"
|
|
|
|
* was introduced, and was kept since then.
|
|
|
|
*
|
|
|
|
* Due to the necessity to be able to boot and / or upgrade any
|
|
|
|
* Windows NT version at any time, including its NT Loader and the
|
|
|
|
* associated boot.ini file, all versions of NTLDR and the NT installer
|
|
|
|
* understand and parse these three section names, the default one
|
|
|
|
* being "boot loader", and if not present, they successively fall
|
|
|
|
* back to "flexboot" and then to "multiboot".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get the "boot loader" section */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniSection = IniGetSection(BootStore->IniCache, L"boot loader");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (!IniSection)
|
|
|
|
{
|
|
|
|
/* Fall back to "flexboot" */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniSection = IniGetSection(BootStore->IniCache, L"flexboot");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (!IniSection)
|
|
|
|
{
|
|
|
|
/* Fall back to "multiboot" */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniSection = IniGetSection(BootStore->IniCache, L"multiboot");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
if (!IniSection)
|
|
|
|
{
|
|
|
|
/* It does not exist yet, so create it */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"boot loader");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
2024-04-23 19:09:36 +00:00
|
|
|
if (!IniSection)
|
|
|
|
DPRINT1("OpenIniBootLoaderStore: Failed to retrieve 'boot loader' section!\n");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
BootStore->OptionsIniSection = IniSection;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cache the "Operating Systems" section for our future usage.
|
|
|
|
*/
|
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Get or create the "Operating Systems" section */
|
|
|
|
IniSection = IniAddSection(BootStore->IniCache, L"operating systems");
|
2024-04-23 19:09:36 +00:00
|
|
|
if (!IniSection)
|
|
|
|
DPRINT1("OpenIniBootLoaderStore: Failed to retrieve 'operating systems' section!\n");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
BootStore->OsIniSection = IniSection;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*Handle = BootStore;
|
2017-05-25 23:52:50 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* Selectively changes the attributes of a file.
|
|
|
|
*
|
|
|
|
* @param[in] FileHandle
|
|
|
|
* Handle to an opened file for which to change its attributes.
|
|
|
|
*
|
|
|
|
* @param[in] MaskAttributes
|
|
|
|
* A mask specifying which attributes to change; any other attributes
|
|
|
|
* will be maintained as they are. If this parameter is zero, all of
|
|
|
|
* the attributes in *Attributes will be changed.
|
|
|
|
*
|
|
|
|
* @param[in,out] Attributes
|
|
|
|
* In input, specifies the new attributes to set. Attributes that
|
|
|
|
* are not set, but are specified in MaskAttributes, are removed.
|
|
|
|
* In output, receives the original attributes of the file.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* STATUS_SUCCESS if the attributes were successfully changed,
|
|
|
|
* or a failure code if an error happened.
|
|
|
|
**/
|
2017-05-25 23:52:50 +00:00
|
|
|
static NTSTATUS
|
2024-05-04 10:38:07 +00:00
|
|
|
ProtectFile(
|
|
|
|
_In_ HANDLE FileHandle,
|
|
|
|
_In_ ULONG MaskAttributes,
|
|
|
|
_Inout_ PULONG Attributes)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
FILE_BASIC_INFORMATION FileInfo;
|
2024-05-04 10:38:07 +00:00
|
|
|
ULONG OldAttributes;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Retrieve the original file attributes */
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Status = NtQueryInformationFile(FileHandle,
|
|
|
|
&IoStatusBlock,
|
|
|
|
&FileInfo,
|
2024-05-04 10:38:07 +00:00
|
|
|
sizeof(FileInfo),
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
FileBasicInformation);
|
2017-05-25 23:52:50 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
DPRINT1("NtQueryInformationFile() failed (Status 0x%08lx)\n", Status);
|
2017-05-25 23:52:50 +00:00
|
|
|
return Status;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
2024-05-04 10:38:07 +00:00
|
|
|
OldAttributes = FileInfo.FileAttributes;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Modify the attributes and return the old ones */
|
|
|
|
if (MaskAttributes)
|
|
|
|
FileInfo.FileAttributes = (OldAttributes & ~MaskAttributes) | (*Attributes & MaskAttributes);
|
|
|
|
else
|
|
|
|
FileInfo.FileAttributes = *Attributes;
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
*Attributes = OldAttributes;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Set the new file attributes */
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Status = NtSetInformationFile(FileHandle,
|
|
|
|
&IoStatusBlock,
|
|
|
|
&FileInfo,
|
2024-05-04 10:38:07 +00:00
|
|
|
sizeof(FileInfo),
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
FileBasicInformation);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
DPRINT1("NtSetInformationFile() failed (Status 0x%08lx)\n", Status);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
CloseIniBootLoaderStore(
|
2024-05-04 10:38:07 +00:00
|
|
|
_In_ PVOID Handle)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Set or remove SYSTEM, HIDDEN and READONLY attributes */
|
|
|
|
static const ULONG ProtectAttribs =
|
|
|
|
(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY);
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
PBOOT_STORE_INI_CONTEXT BootStore = (PBOOT_STORE_INI_CONTEXT)Handle;
|
2024-05-04 10:38:07 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
ULONG FileAttribs;
|
|
|
|
|
|
|
|
ASSERT(BootStore);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* If the INI file was opened in read-only mode, skip saving */
|
|
|
|
if (BootStore->Header.ReadOnly)
|
|
|
|
goto Quit;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* If the INI file was already opened because it already existed, unprotect it */
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (BootStore->SectionHandle)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
FileAttribs = 0;
|
|
|
|
Status = ProtectFile(BootStore->FileHandle, ProtectAttribs, &FileAttribs);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
DPRINT1("Could not unprotect INI boot store (Status 0x%08lx)\n", Status);
|
|
|
|
goto Quit;
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IniCacheSaveByHandle(BootStore->IniCache, BootStore->FileHandle);
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/* Re-protect the INI file */
|
|
|
|
FileAttribs = ProtectAttribs;
|
2024-05-07 17:26:03 +00:00
|
|
|
if (BootStore->Header.Type == FreeLdr)
|
|
|
|
{
|
|
|
|
// NOTE: CORE-19575: For the time being, don't add READONLY for ease
|
|
|
|
// of testing and modifying files, but it won't always stay this way.
|
|
|
|
FileAttribs &= ~FILE_ATTRIBUTE_READONLY;
|
|
|
|
}
|
|
|
|
/*Status =*/ ProtectFile(BootStore->FileHandle, FileAttribs, &FileAttribs);
|
2024-05-04 10:38:07 +00:00
|
|
|
Status = STATUS_SUCCESS; // Ignore the status and just succeed.
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Quit:
|
|
|
|
IniCacheDestroy(BootStore->IniCache);
|
2017-05-25 23:52:50 +00:00
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
#if 0
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (BootStore->SectionHandle)
|
|
|
|
{
|
|
|
|
/* Finally, unmap and close the file */
|
2017-08-23 12:20:15 +00:00
|
|
|
UnMapAndCloseFile(BootStore->FileHandle,
|
|
|
|
BootStore->SectionHandle,
|
|
|
|
BootStore->ViewBase);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
else // if (BootStore->FileHandle)
|
2024-05-04 10:38:07 +00:00
|
|
|
#endif
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
/* Just close the file we have opened for creation */
|
|
|
|
NtClose(BootStore->FileHandle);
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/* Finally, free the boot store structure */
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
2024-05-04 10:38:07 +00:00
|
|
|
return Status;
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
OpenBootStoreByHandle(
|
2024-05-04 10:38:07 +00:00
|
|
|
_Out_ PVOID* Handle,
|
|
|
|
_In_ HANDLE PartitionDirectoryHandle, // _In_opt_
|
|
|
|
_In_ BOOT_STORE_TYPE Type,
|
|
|
|
_In_ BOOT_STORE_OPENMODE OpenMode,
|
|
|
|
_In_ BOOT_STORE_ACCESS Access)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (Type >= BldrTypeMax || NtosBootLoaders[Type].Type >= BldrTypeMax)
|
2017-05-25 23:52:50 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return STATUS_NOT_SUPPORTED;
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
/*
|
|
|
|
* Verify the access modes to perform the open actions.
|
|
|
|
* The operating system may allow e.g. file creation even with
|
|
|
|
* read-only access, but we do not allow this because we want
|
|
|
|
* to protect any existing boot store file in case the caller
|
|
|
|
* specified such an open mode.
|
|
|
|
*/
|
|
|
|
// if ((OpenMode == BS_CheckExisting) && !(Access & BS_ReadAccess))
|
|
|
|
// return STATUS_ACCESS_DENIED;
|
|
|
|
if ((OpenMode == BS_CreateNew || OpenMode == BS_CreateAlways || OpenMode == BS_RecreateExisting) && !(Access & BS_WriteAccess))
|
|
|
|
return STATUS_ACCESS_DENIED;
|
|
|
|
if ((OpenMode == BS_OpenExisting || OpenMode == BS_OpenAlways) && !(Access & BS_ReadWriteAccess))
|
|
|
|
return STATUS_ACCESS_DENIED;
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return NtosBootLoaders[Type].OpenBootStore(Handle,
|
|
|
|
PartitionDirectoryHandle,
|
|
|
|
Type,
|
2024-05-04 10:38:07 +00:00
|
|
|
OpenMode,
|
|
|
|
Access);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
2017-05-25 23:52:50 +00:00
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
OpenBootStore_UStr(
|
2024-05-04 10:38:07 +00:00
|
|
|
_Out_ PVOID* Handle,
|
|
|
|
_In_ PUNICODE_STRING SystemPartitionPath,
|
|
|
|
_In_ BOOT_STORE_TYPE Type,
|
|
|
|
_In_ BOOT_STORE_OPENMODE OpenMode,
|
|
|
|
_In_ BOOT_STORE_ACCESS Access)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
HANDLE PartitionDirectoryHandle;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (Type >= BldrTypeMax || NtosBootLoaders[Type].Type >= BldrTypeMax)
|
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open SystemPartition */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
SystemPartitionPath,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = NtOpenFile(&PartitionDirectoryHandle,
|
|
|
|
FILE_LIST_DIRECTORY | FILE_ADD_FILE /* | FILE_ADD_SUBDIRECTORY | FILE_TRAVERSE*/ | SYNCHRONIZE,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&IoStatusBlock,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE /* | FILE_OPEN_FOR_BACKUP_INTENT */);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2024-05-04 10:38:07 +00:00
|
|
|
DPRINT1("Failed to open SystemPartition '%wZ' (Status 0x%08lx)\n",
|
|
|
|
SystemPartitionPath, Status);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2024-05-04 10:38:07 +00:00
|
|
|
Status = OpenBootStoreByHandle(Handle,
|
|
|
|
PartitionDirectoryHandle,
|
|
|
|
Type,
|
|
|
|
OpenMode,
|
|
|
|
Access);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/* Done! */
|
|
|
|
NtClose(PartitionDirectoryHandle);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
OpenBootStore(
|
2024-05-04 10:38:07 +00:00
|
|
|
_Out_ PVOID* Handle,
|
|
|
|
_In_ PCWSTR SystemPartition,
|
|
|
|
_In_ BOOT_STORE_TYPE Type,
|
|
|
|
_In_ BOOT_STORE_OPENMODE OpenMode,
|
|
|
|
_In_ BOOT_STORE_ACCESS Access)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
UNICODE_STRING SystemPartitionPath;
|
|
|
|
RtlInitUnicodeString(&SystemPartitionPath, SystemPartition);
|
2024-05-04 10:38:07 +00:00
|
|
|
return OpenBootStore_UStr(Handle,
|
|
|
|
&SystemPartitionPath,
|
|
|
|
Type,
|
|
|
|
OpenMode,
|
|
|
|
Access);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
CloseBootStore(
|
2024-05-04 10:38:07 +00:00
|
|
|
_In_ PVOID Handle)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NtosBootLoaders[BootStore->Type].CloseBootStore(Handle /* BootStore */);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
CreateNTOSEntry(
|
|
|
|
IN PBOOT_STORE_INI_CONTEXT BootStore,
|
|
|
|
IN ULONG_PTR BootEntryKey,
|
2017-06-08 17:30:23 +00:00
|
|
|
IN PBOOT_STORE_ENTRY BootEntry)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2024-04-23 19:09:36 +00:00
|
|
|
PINI_SECTION IniSection;
|
|
|
|
PCWSTR Section = (PCWSTR)BootEntryKey;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/* Insert the entry into the "Operating Systems" section */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniAddKey(BootStore->OsIniSection, Section, BootEntry->FriendlyName);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/* Create a new section */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniSection = IniAddSection(BootStore->IniCache, Section);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
|
|
|
|
|
2024-04-23 19:09:36 +00:00
|
|
|
/* BootType, SystemPath and Options */
|
|
|
|
IniAddKey(IniSection, L"BootType", L"Windows2003");
|
|
|
|
IniAddKey(IniSection, L"SystemPath", Options->OsLoadPath);
|
|
|
|
IniAddKey(IniSection, L"Options", Options->OsLoadOptions);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
else
|
2024-04-23 15:02:06 +00:00
|
|
|
if (BootEntry->OsOptionsLength >= sizeof(BOOTSECTOR_OPTIONS) &&
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
RtlCompareMemory(&BootEntry->OsOptions /* Signature */,
|
2024-04-23 15:02:06 +00:00
|
|
|
BOOTSECTOR_OPTIONS_SIGNATURE,
|
|
|
|
RTL_FIELD_SIZE(BOOTSECTOR_OPTIONS, Signature)) ==
|
|
|
|
RTL_FIELD_SIZE(BOOTSECTOR_OPTIONS, Signature))
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2024-04-23 15:02:06 +00:00
|
|
|
PBOOTSECTOR_OPTIONS Options = (PBOOTSECTOR_OPTIONS)&BootEntry->OsOptions;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-04-23 15:02:06 +00:00
|
|
|
/* BootType, BootPath and BootSector */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniAddKey(IniSection, L"BootType", L"BootSector");
|
2024-04-23 15:02:06 +00:00
|
|
|
IniAddKey(IniSection, L"BootPath", Options->BootPath);
|
|
|
|
IniAddKey(IniSection, L"BootSectorFile", Options->FileName);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
// DPRINT1("Unsupported BootType %lu/'%*.s'\n",
|
|
|
|
// BootEntry->OsOptionsLength, 8, &BootEntry->OsOptions);
|
|
|
|
DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
AddBootStoreEntry(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
2017-06-08 17:30:23 +00:00
|
|
|
IN PBOOT_STORE_ENTRY BootEntry,
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN ULONG_PTR BootEntryKey)
|
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore || !BootEntry)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// FIXME!!
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
|
|
|
|
|
|
|
if (BootStore->Type == FreeLdr)
|
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
if (BootEntry->Version != FreeLdr)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return CreateNTOSEntry((PBOOT_STORE_INI_CONTEXT)BootStore,
|
|
|
|
BootEntryKey, BootEntry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (BootStore->Type == NtLdr)
|
|
|
|
{
|
|
|
|
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
|
|
|
|
PWCHAR Buffer;
|
|
|
|
ULONG BufferLength;
|
|
|
|
PCWSTR InstallName, OsOptions;
|
|
|
|
// ULONG InstallNameLength, OsOptionsLength;
|
2017-06-08 17:30:23 +00:00
|
|
|
BOOLEAN IsNameNotQuoted;
|
|
|
|
|
|
|
|
if (BootEntry->Version != NtLdr)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
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))
|
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
// DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version);
|
|
|
|
DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return STATUS_SUCCESS; // STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
InstallName = BootEntry->FriendlyName;
|
|
|
|
OsOptions = Options->OsLoadOptions;
|
|
|
|
|
|
|
|
// if (InstallNameLength == 0) InstallName = NULL;
|
|
|
|
// if (OsOptionsLength == 0) OsOptions = NULL;
|
|
|
|
|
2017-06-08 17:30:23 +00:00
|
|
|
IsNameNotQuoted = (InstallName[0] != L'\"' || InstallName[wcslen(InstallName)-1] != L'\"');
|
|
|
|
|
|
|
|
BufferLength = (IsNameNotQuoted ? 2 /* Quotes for FriendlyName*/ : 0) + wcslen(InstallName);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (OsOptions)
|
|
|
|
BufferLength += 1 /* Space between FriendlyName and options */ + wcslen(OsOptions);
|
|
|
|
BufferLength++; /* NULL-termination */
|
|
|
|
|
|
|
|
Buffer = RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, BufferLength * sizeof(WCHAR));
|
|
|
|
if (!Buffer)
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
|
2017-06-08 17:30:23 +00:00
|
|
|
*Buffer = UNICODE_NULL;
|
|
|
|
if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
|
|
|
|
RtlStringCchCatW(Buffer, BufferLength, InstallName);
|
|
|
|
if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (OsOptions)
|
|
|
|
{
|
2017-06-08 17:30:23 +00:00
|
|
|
RtlStringCchCatW(Buffer, BufferLength, L" ");
|
|
|
|
RtlStringCchCatW(Buffer, BufferLength, OsOptions);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert the entry into the "Operating Systems" section */
|
2024-04-23 19:09:36 +00:00
|
|
|
IniAddKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OsIniSection,
|
|
|
|
Options->OsLoadPath, Buffer);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, Buffer);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-20 16:49:00 +00:00
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", BootStore->Type);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
DeleteBootStoreEntry(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
|
|
|
IN ULONG_PTR BootEntryKey)
|
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// FIXME!!
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
|
|
|
if (BootStore->Type != FreeLdr)
|
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME! This function needs my INI library rewrite to be implemented!!
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
ModifyBootStoreEntry(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
2017-06-08 17:30:23 +00:00
|
|
|
IN PBOOT_STORE_ENTRY BootEntry)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore || !BootEntry)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// FIXME!!
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
|
|
|
if (BootStore->Type != FreeLdr)
|
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME! This function needs my INI library rewrite to operate properly!!
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
QueryBootStoreEntry(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
|
|
|
IN ULONG_PTR BootEntryKey,
|
2017-06-08 17:30:23 +00:00
|
|
|
OUT PBOOT_STORE_ENTRY BootEntry) // Technically this should be PBOOT_STORE_ENTRY*
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// FIXME!!
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
|
|
|
if (BootStore->Type != FreeLdr)
|
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME! This function needs my INI library rewrite to be implemented!!
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
QueryBootStoreOptions(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
2017-06-08 17:30:23 +00:00
|
|
|
IN OUT PBOOT_STORE_OPTIONS BootOptions
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
/* , IN PULONG BootOptionsLength */ )
|
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
2024-04-24 10:58:09 +00:00
|
|
|
PCWSTR TimeoutStr;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
if (!BootStore || !BootOptions)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// FIXME!!
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
2019-10-23 13:38:39 +00:00
|
|
|
if (BootStore->Type != FreeLdr && BootStore->Type != NtLdr)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2020-01-20 16:49:00 +00:00
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", BootStore->Type);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
BootOptions->Timeout = 0;
|
|
|
|
BootOptions->CurrentBootEntryKey = 0;
|
|
|
|
BootOptions->NextBootEntryKey = 0;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
if (IniGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
|
|
|
|
BootOptionNames[BootStore->Type][BO_TimeOut],
|
|
|
|
&TimeoutStr) && TimeoutStr)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
2024-05-04 10:47:13 +00:00
|
|
|
BootOptions->Timeout = _wtoi(TimeoutStr);
|
|
|
|
}
|
2017-06-08 17:30:23 +00:00
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
IniGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
|
|
|
|
BootOptionNames[BootStore->Type][BO_DefaultOS],
|
|
|
|
(PCWSTR*)&BootOptions->NextBootEntryKey);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
/*
|
|
|
|
* NOTE: BootOptions->CurrentBootEntryKey is an informative field only.
|
|
|
|
* It indicates which boot entry has been selected for starting the
|
|
|
|
* current OS instance. Such information is NOT stored in the INI file,
|
|
|
|
* but has to be determined via other means. On UEFI the 'BootCurrent'
|
|
|
|
* environment variable does that. Otherwise, one could heuristically
|
|
|
|
* determine it by comparing the boot path and options of each entry
|
|
|
|
* with those used by the current OS instance.
|
|
|
|
* Since we currently do not need this information (and it can be costly
|
|
|
|
* to determine), BootOptions->CurrentBootEntryKey is not evaluated.
|
|
|
|
*/
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-04-24 10:58:09 +00:00
|
|
|
return STATUS_SUCCESS;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
SetBootStoreOptions(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
2017-06-08 17:30:23 +00:00
|
|
|
IN PBOOT_STORE_OPTIONS BootOptions,
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN ULONG FieldsToChange)
|
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore || !BootOptions)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Currently we open & map the loader configuration file without
|
|
|
|
* further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
|
|
|
|
* and NTLDR's boot.ini files. But as soon as we'll implement support for
|
|
|
|
* BOOTMGR detection, the "configuration file" will be the BCD registry
|
|
|
|
* hive and then, we'll have instead to mount the hive & open it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// FIXME!!
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
2024-05-04 10:47:13 +00:00
|
|
|
if (BootStore->Type != FreeLdr && BootStore->Type != NtLdr)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
// if (BootOptions->Length < sizeof(*BootOptions))
|
|
|
|
// return STATUS_INVALID_PARAMETER;
|
2017-06-08 17:30:23 +00:00
|
|
|
|
2024-05-04 10:47:13 +00:00
|
|
|
if (FieldsToChange & BOOT_OPTIONS_TIMEOUT)
|
|
|
|
{
|
|
|
|
WCHAR TimeoutStr[15];
|
|
|
|
RtlStringCchPrintfW(TimeoutStr, ARRAYSIZE(TimeoutStr), L"%d", BootOptions->Timeout);
|
|
|
|
IniAddKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
|
|
|
|
BootOptionNames[BootStore->Type][BO_TimeOut],
|
|
|
|
TimeoutStr);
|
|
|
|
}
|
|
|
|
if (FieldsToChange & BOOT_OPTIONS_NEXT_BOOTENTRY_KEY)
|
|
|
|
{
|
|
|
|
IniAddKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
|
|
|
|
BootOptionNames[BootStore->Type][BO_DefaultOS],
|
|
|
|
(PCWSTR)BootOptions->NextBootEntryKey);
|
|
|
|
}
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
FreeLdrEnumerateBootEntries(
|
|
|
|
IN PBOOT_STORE_INI_CONTEXT BootStore,
|
|
|
|
// IN ULONG Flags, // Determine which data to retrieve
|
|
|
|
IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
|
|
|
|
IN PVOID Parameter OPTIONAL)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
PINICACHEITERATOR Iterator;
|
2024-04-23 19:09:36 +00:00
|
|
|
PINI_SECTION OsIniSection;
|
2024-04-24 10:58:09 +00:00
|
|
|
PCWSTR SectionName, KeyData;
|
2017-06-08 17:30:23 +00:00
|
|
|
UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) +
|
2024-04-23 15:02:06 +00:00
|
|
|
max(sizeof(NTOS_OPTIONS), sizeof(BOOTSECTOR_OPTIONS))];
|
2017-06-08 17:30:23 +00:00
|
|
|
PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
PWCHAR Buffer;
|
|
|
|
|
|
|
|
/* Enumerate all the valid installations listed in the "Operating Systems" section */
|
2024-04-23 19:09:36 +00:00
|
|
|
Iterator = IniFindFirstValue(BootStore->OsIniSection, &SectionName, &KeyData);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (!Iterator) return STATUS_SUCCESS;
|
|
|
|
do
|
|
|
|
{
|
2024-04-24 10:58:09 +00:00
|
|
|
PCWSTR InstallName;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
ULONG InstallNameLength;
|
|
|
|
|
|
|
|
/* Poor-man quotes removal (improvement over bootsup.c:UpdateFreeLoaderIni) */
|
|
|
|
if (*KeyData == L'"')
|
|
|
|
{
|
|
|
|
/* Quoted name, copy up to the closing quote */
|
|
|
|
PWCHAR End = wcschr(KeyData + 1, L'"');
|
|
|
|
|
|
|
|
if (End)
|
|
|
|
{
|
|
|
|
/* Skip the first quote */
|
|
|
|
InstallName = KeyData + 1;
|
|
|
|
InstallNameLength = End - InstallName;
|
|
|
|
}
|
|
|
|
else // if (!End)
|
|
|
|
{
|
|
|
|
/* No corresponding closing quote, so we include the first one in the InstallName */
|
|
|
|
InstallName = KeyData;
|
|
|
|
InstallNameLength = wcslen(InstallName);
|
|
|
|
}
|
|
|
|
if (InstallNameLength == 0) InstallName = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Non-quoted name, copy everything */
|
|
|
|
InstallName = KeyData;
|
|
|
|
InstallNameLength = wcslen(InstallName);
|
|
|
|
if (InstallNameLength == 0) InstallName = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the temporary buffer */
|
|
|
|
Buffer = NULL;
|
|
|
|
if (InstallNameLength)
|
|
|
|
Buffer = RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, (InstallNameLength + 1) * sizeof(WCHAR));
|
|
|
|
if (Buffer)
|
|
|
|
{
|
|
|
|
RtlCopyMemory(Buffer, InstallName, InstallNameLength * sizeof(WCHAR));
|
|
|
|
Buffer[InstallNameLength] = UNICODE_NULL;
|
|
|
|
InstallName = Buffer;
|
|
|
|
}
|
|
|
|
|
2018-10-28 22:33:29 +00:00
|
|
|
DPRINT("Boot entry '%S' in OS section '%S'\n", InstallName, SectionName);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2017-06-08 17:30:23 +00:00
|
|
|
BootEntry->Version = FreeLdr;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
BootEntry->BootEntryKey = MAKESTRKEY(SectionName);
|
|
|
|
BootEntry->FriendlyName = InstallName;
|
|
|
|
BootEntry->BootFilePath = NULL;
|
|
|
|
BootEntry->OsOptionsLength = 0;
|
|
|
|
|
|
|
|
/* Search for an existing boot entry section */
|
2024-04-23 19:09:36 +00:00
|
|
|
OsIniSection = IniGetSection(BootStore->IniCache, SectionName);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (!OsIniSection)
|
|
|
|
goto DoEnum;
|
|
|
|
|
2024-04-24 10:58:09 +00:00
|
|
|
/* Check for supported boot type */
|
|
|
|
if (!IniGetKey(OsIniSection, L"BootType", &KeyData) || !KeyData)
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
{
|
|
|
|
/* Certainly not a ReactOS installation */
|
2024-04-23 15:02:06 +00:00
|
|
|
DPRINT1("No BootType value present\n");
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
goto DoEnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: What to do with "Windows" ; "WindowsNT40" ; "ReactOSSetup" ?
|
|
|
|
if ((_wcsicmp(KeyData, L"Windows2003") == 0) ||
|
|
|
|
(_wcsicmp(KeyData, L"\"Windows2003\"") == 0))
|
|
|
|
{
|
|
|
|
/* BootType is Windows2003 */
|
|
|
|
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
|
|
|
|
|
2018-10-28 22:33:29 +00:00
|
|
|
DPRINT("This is a '%S' boot entry\n", KeyData);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS);
|
|
|
|
RtlCopyMemory(Options->Signature,
|
|
|
|
NTOS_OPTIONS_SIGNATURE,
|
|
|
|
RTL_FIELD_SIZE(NTOS_OPTIONS, Signature));
|
|
|
|
|
|
|
|
// BootEntry->BootFilePath = NULL;
|
|
|
|
|
|
|
|
/* Check its SystemPath */
|
2024-04-23 19:09:36 +00:00
|
|
|
Options->OsLoadPath = NULL;
|
2024-04-24 10:58:09 +00:00
|
|
|
if (IniGetKey(OsIniSection, L"SystemPath", &KeyData))
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Options->OsLoadPath = KeyData;
|
|
|
|
// KeyData == SystemRoot;
|
|
|
|
|
|
|
|
/* Check the optional Options */
|
2024-04-23 19:09:36 +00:00
|
|
|
Options->OsLoadOptions = NULL;
|
2024-04-24 10:58:09 +00:00
|
|
|
if (IniGetKey(OsIniSection, L"Options", &KeyData))
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
Options->OsLoadOptions = KeyData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ((_wcsicmp(KeyData, L"BootSector") == 0) ||
|
|
|
|
(_wcsicmp(KeyData, L"\"BootSector\"") == 0))
|
|
|
|
{
|
|
|
|
/* BootType is BootSector */
|
2024-04-23 15:02:06 +00:00
|
|
|
PBOOTSECTOR_OPTIONS Options = (PBOOTSECTOR_OPTIONS)&BootEntry->OsOptions;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2018-10-28 22:33:29 +00:00
|
|
|
DPRINT("This is a '%S' boot entry\n", KeyData);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-04-23 15:02:06 +00:00
|
|
|
BootEntry->OsOptionsLength = sizeof(BOOTSECTOR_OPTIONS);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
RtlCopyMemory(Options->Signature,
|
2024-04-23 15:02:06 +00:00
|
|
|
BOOTSECTOR_OPTIONS_SIGNATURE,
|
|
|
|
RTL_FIELD_SIZE(BOOTSECTOR_OPTIONS, Signature));
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
// BootEntry->BootFilePath = NULL;
|
|
|
|
|
2024-04-23 15:02:06 +00:00
|
|
|
/* Check its BootPath */
|
|
|
|
Options->BootPath = NULL;
|
|
|
|
if (IniGetKey(OsIniSection, L"BootPath", &KeyData))
|
|
|
|
Options->BootPath = KeyData;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
|
|
|
/* Check its BootSector */
|
2024-04-23 15:02:06 +00:00
|
|
|
Options->FileName = NULL;
|
2024-04-24 10:58:09 +00:00
|
|
|
if (IniGetKey(OsIniSection, L"BootSectorFile", &KeyData))
|
2024-04-23 15:02:06 +00:00
|
|
|
Options->FileName = KeyData;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DPRINT1("Unrecognized BootType value '%S'\n", KeyData);
|
|
|
|
// goto DoEnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoEnum:
|
|
|
|
/* Call the user enumeration routine callback */
|
|
|
|
Status = EnumBootEntriesRoutine(FreeLdr, BootEntry, Parameter);
|
|
|
|
|
|
|
|
/* Free temporary buffers */
|
|
|
|
if (Buffer)
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, Buffer);
|
|
|
|
|
|
|
|
/* Stop the enumeration if needed */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
break;
|
|
|
|
}
|
2024-04-23 19:09:36 +00:00
|
|
|
while (IniFindNextValue(Iterator, &SectionName, &KeyData));
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-04-23 19:09:36 +00:00
|
|
|
IniFindClose(Iterator);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
NtLdrEnumerateBootEntries(
|
|
|
|
IN PBOOT_STORE_INI_CONTEXT BootStore,
|
|
|
|
// IN ULONG Flags, // Determine which data to retrieve
|
|
|
|
IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
|
|
|
|
IN PVOID Parameter OPTIONAL)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
PINICACHEITERATOR Iterator;
|
2024-04-24 10:58:09 +00:00
|
|
|
PCWSTR SectionName, KeyData;
|
2017-06-08 17:30:23 +00:00
|
|
|
UCHAR xxBootEntry[FIELD_OFFSET(BOOT_STORE_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)];
|
|
|
|
PBOOT_STORE_ENTRY BootEntry = (PBOOT_STORE_ENTRY)&xxBootEntry;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
|
|
|
|
PWCHAR Buffer;
|
|
|
|
ULONG BufferLength;
|
|
|
|
|
|
|
|
/* Enumerate all the valid installations */
|
2024-04-23 19:09:36 +00:00
|
|
|
Iterator = IniFindFirstValue(BootStore->OsIniSection, &SectionName, &KeyData);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
if (!Iterator) return STATUS_SUCCESS;
|
|
|
|
do
|
|
|
|
{
|
2024-04-24 10:58:09 +00:00
|
|
|
PCWSTR InstallName, OsOptions;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
ULONG InstallNameLength, OsOptionsLength;
|
|
|
|
|
|
|
|
/* Poor-man quotes removal (improvement over bootsup.c:UpdateFreeLoaderIni) */
|
|
|
|
if (*KeyData == L'"')
|
|
|
|
{
|
|
|
|
/* Quoted name, copy up to the closing quote */
|
|
|
|
OsOptions = wcschr(KeyData + 1, L'"');
|
|
|
|
|
|
|
|
/* Retrieve the starting point of the installation name and the OS options */
|
|
|
|
if (OsOptions)
|
|
|
|
{
|
|
|
|
/* Skip the first quote */
|
|
|
|
InstallName = KeyData + 1;
|
|
|
|
InstallNameLength = OsOptions - InstallName;
|
|
|
|
if (InstallNameLength == 0) InstallName = NULL;
|
|
|
|
|
|
|
|
/* Skip the ending quote (if found) */
|
|
|
|
++OsOptions;
|
|
|
|
|
|
|
|
/* Skip any whitespace */
|
|
|
|
while (iswspace(*OsOptions)) ++OsOptions;
|
|
|
|
/* Get its final length */
|
|
|
|
OsOptionsLength = wcslen(OsOptions);
|
|
|
|
if (OsOptionsLength == 0) OsOptions = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No corresponding closing quote, so we include the first one in the InstallName */
|
|
|
|
InstallName = KeyData;
|
|
|
|
InstallNameLength = wcslen(InstallName);
|
|
|
|
if (InstallNameLength == 0) InstallName = NULL;
|
|
|
|
|
|
|
|
/* There are no OS options */
|
|
|
|
// OsOptions = NULL;
|
|
|
|
OsOptionsLength = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Non-quoted name, copy everything */
|
|
|
|
|
|
|
|
/* Retrieve the starting point of the installation name */
|
|
|
|
InstallName = KeyData;
|
|
|
|
InstallNameLength = wcslen(InstallName);
|
|
|
|
if (InstallNameLength == 0) InstallName = NULL;
|
|
|
|
|
|
|
|
/* There are no OS options */
|
|
|
|
OsOptions = NULL;
|
|
|
|
OsOptionsLength = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the temporary buffer */
|
|
|
|
Buffer = NULL;
|
|
|
|
BufferLength = (InstallNameLength + OsOptionsLength) * sizeof(WCHAR);
|
|
|
|
if (BufferLength)
|
|
|
|
Buffer = RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, BufferLength + 2*sizeof(UNICODE_NULL));
|
|
|
|
if (Buffer)
|
|
|
|
{
|
|
|
|
PWCHAR ptr;
|
|
|
|
|
|
|
|
/* Copy the installation name, and make InstallName point into the buffer */
|
|
|
|
if (InstallName && InstallNameLength)
|
|
|
|
{
|
|
|
|
ptr = Buffer;
|
|
|
|
RtlCopyMemory(ptr, InstallName, InstallNameLength * sizeof(WCHAR));
|
|
|
|
ptr[InstallNameLength] = UNICODE_NULL;
|
|
|
|
InstallName = ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the OS options, and make OsOptions point into the buffer */
|
|
|
|
if (OsOptions && OsOptionsLength)
|
|
|
|
{
|
|
|
|
ptr = Buffer + InstallNameLength + 1;
|
|
|
|
RtlCopyMemory(ptr, OsOptions, OsOptionsLength * sizeof(WCHAR));
|
|
|
|
ptr[OsOptionsLength] = UNICODE_NULL;
|
|
|
|
OsOptions = ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT1("Boot entry '%S' in OS section (path) '%S'\n", InstallName, SectionName);
|
|
|
|
// SectionName == SystemRoot;
|
|
|
|
|
2017-06-08 17:30:23 +00:00
|
|
|
BootEntry->Version = NtLdr;
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
BootEntry->BootEntryKey = 0; // FIXME??
|
|
|
|
BootEntry->FriendlyName = InstallName;
|
|
|
|
BootEntry->BootFilePath = NULL;
|
|
|
|
|
|
|
|
BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS);
|
|
|
|
RtlCopyMemory(Options->Signature,
|
|
|
|
NTOS_OPTIONS_SIGNATURE,
|
|
|
|
RTL_FIELD_SIZE(NTOS_OPTIONS, Signature));
|
|
|
|
|
|
|
|
Options->OsLoadPath = SectionName;
|
|
|
|
Options->OsLoadOptions = OsOptions;
|
|
|
|
|
|
|
|
/* Call the user enumeration routine callback */
|
|
|
|
Status = EnumBootEntriesRoutine(NtLdr, BootEntry, Parameter);
|
|
|
|
|
|
|
|
/* Free temporary buffers */
|
|
|
|
if (Buffer)
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, Buffer);
|
|
|
|
|
|
|
|
/* Stop the enumeration if needed */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
break;
|
|
|
|
}
|
2024-04-23 19:09:36 +00:00
|
|
|
while (IniFindNextValue(Iterator, &SectionName, &KeyData));
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
|
2024-04-23 19:09:36 +00:00
|
|
|
IniFindClose(Iterator);
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-06-08 17:30:23 +00:00
|
|
|
EnumerateBootStoreEntries(
|
[SETUPLIB] Introduce a lot of (Work in progress) functions to manipulate boot entries from different boot "stores".
This concerns so far, only freeldr.ini and to an extent, boot.ini, but planning in the future to add support for registry-oriented BCD
as well as possibly direct (u)EFI entries, using the corresponding NT functions.
This code is so far only used in osdetect.c, but will be soon used by usetup's bootsup.c (note that some helper functions: CreateCommonFreeLdrSections()
and (Un)protectBootIni() are already taken from it and used in bldrsup.c).
- In EnumerateNTOSBootEntries(), continue enumerating the boot entries until the user callback returns an status code that is not successful.
- Remove some old code from osdetect.c; use directly BootEntry->FriendlyName when building the display names of the available installations, since now
BootEntry->FriendlyName is a PCWSTR (and not a UNICODE_STRING anymore).
svn path=/branches/setup_improvements/; revision=74943
[SETUPLIB] Make the NTOS_BOOT_ENTRY structure more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options.
In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY".
- Adapt the code in bldrsup.c to these modifications, and re-enable FreeLdr-like boot-sector-file support code that was commented out.
More code cleanup will follow later.
svn path=/branches/setup_improvements/; revision=74952
2017-06-07 15:58:44 +00:00
|
|
|
IN PVOID Handle,
|
|
|
|
// IN ULONG Flags, // Determine which data to retrieve
|
|
|
|
IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine,
|
|
|
|
IN PVOID Parameter OPTIONAL)
|
|
|
|
{
|
|
|
|
PBOOT_STORE_CONTEXT BootStore = (PBOOT_STORE_CONTEXT)Handle;
|
|
|
|
|
|
|
|
if (!BootStore)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
|
|
|
|
{
|
|
|
|
DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
|
|
|
|
/**/return STATUS_SUCCESS;/**/
|
|
|
|
// return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NtosBootLoaders[BootStore->Type].EnumBootStoreEntries(
|
|
|
|
(PBOOT_STORE_INI_CONTEXT)BootStore, // Flags,
|
|
|
|
EnumBootEntriesRoutine, Parameter);
|
2017-05-25 23:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|