[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

@ -129,30 +129,51 @@ FindBootStore( // By handle
OUT PULONG VersionNumber OPTIONAL);
typedef enum _BOOT_STORE_OPENMODE
{
BS_CheckExisting = 0, // See FindBootStore()
BS_CreateNew = 1, // BS_CreateOnly
BS_OpenExisting = 2, // BS_OpenOnly
BS_OpenAlways = 3,
BS_RecreateExisting = 4, // BS_RecreateOnly
BS_CreateAlways = 5,
} BOOT_STORE_OPENMODE;
typedef enum _BOOT_STORE_ACCESS
{
// BS_NoAccess = 0,
BS_ReadAccess = 1,
BS_WriteAccess = 2,
BS_ReadWriteAccess = (BS_ReadAccess | BS_WriteAccess)
} BOOT_STORE_ACCESS;
NTSTATUS
OpenBootStoreByHandle(
OUT PVOID* Handle,
IN HANDLE PartitionDirectoryHandle, // OPTIONAL
IN BOOT_STORE_TYPE Type,
IN BOOLEAN CreateNew);
_Out_ PVOID* Handle,
_In_ HANDLE PartitionDirectoryHandle, // _In_opt_
_In_ BOOT_STORE_TYPE Type,
_In_ BOOT_STORE_OPENMODE OpenMode,
_In_ BOOT_STORE_ACCESS Access);
NTSTATUS
OpenBootStore_UStr(
OUT PVOID* Handle,
IN PUNICODE_STRING SystemPartitionPath,
IN BOOT_STORE_TYPE Type,
IN BOOLEAN CreateNew);
_Out_ PVOID* Handle,
_In_ PUNICODE_STRING SystemPartitionPath,
_In_ BOOT_STORE_TYPE Type,
_In_ BOOT_STORE_OPENMODE OpenMode,
_In_ BOOT_STORE_ACCESS Access);
NTSTATUS
OpenBootStore(
OUT PVOID* Handle,
IN PCWSTR SystemPartition,
IN BOOT_STORE_TYPE Type,
IN BOOLEAN CreateNew);
_Out_ PVOID* Handle,
_In_ PCWSTR SystemPartition,
_In_ BOOT_STORE_TYPE Type,
_In_ BOOT_STORE_OPENMODE OpenMode,
_In_ BOOT_STORE_ACCESS Access);
NTSTATUS
CloseBootStore(
IN PVOID Handle);
_In_ PVOID Handle);
NTSTATUS
AddBootStoreEntry(