[SETUPLIB] Support different boot store file creation/opening and access modes

The support is so far enabled only for INI files (freeldr.ini, boot.ini).
May be subject to further improvements in the future.

Usage examples:

- When finding existing ReactOS or Windows installations, the boot store
  should exist and is opened in read-only mode. Closing the boot store
  doesn't store any temporary modifications made to it.

- When doing a clean installation, freeldr.ini is created in read-write
  access.

- When installing with an existing freeldr.ini or boot.ini, they are
  opened as existing files in read-write access.
This commit is contained in:
Hermès Bélusca-Maïto 2024-05-04 12:38:07 +02:00
parent d1b8feb690
commit c7295b2cdf
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 348 additions and 209 deletions

View file

@ -170,7 +170,8 @@ CreateFreeLoaderIniForReactOS(
PVOID BootStoreHandle;
/* Initialize the INI file and create the common FreeLdr sections */
Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr, TRUE);
Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr,
BS_CreateAlways /* BS_OpenAlways */, BS_ReadWriteAccess);
if (!NT_SUCCESS(Status))
return Status;
@ -199,7 +200,8 @@ CreateFreeLoaderIniForReactOSAndBootSector(
PBOOT_SECTOR_OPTIONS Options = (PBOOT_SECTOR_OPTIONS)&BootEntry->OsOptions;
/* Initialize the INI file and create the common FreeLdr sections */
Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr, TRUE);
Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr,
BS_CreateAlways /* BS_OpenAlways */, BS_ReadWriteAccess);
if (!NT_SUCCESS(Status))
return Status;
@ -337,7 +339,8 @@ UpdateFreeLoaderIni(
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
/* Open the INI file */
Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr, /*TRUE*/ FALSE);
Status = OpenBootStore(&BootStoreHandle, IniPath, FreeLdr,
BS_OpenExisting /* BS_OpenAlways */, BS_ReadWriteAccess);
if (!NT_SUCCESS(Status))
return Status;
@ -398,7 +401,8 @@ UpdateBootIni(
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
/* Open the INI file */
Status = OpenBootStore(&BootStoreHandle, IniPath, NtLdr, FALSE);
Status = OpenBootStore(&BootStoreHandle, IniPath, NtLdr,
BS_OpenExisting /* BS_OpenAlways */, BS_ReadWriteAccess);
if (!NT_SUCCESS(Status))
return Status;