ReactOS 0.4.15-dev-8100-g1887773
bldrsup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _BOOT_STORE_OPTIONS
 
struct  _BOOT_STORE_ENTRY
 
struct  _NTOS_OPTIONS
 
struct  _BOOTSECTOR_OPTIONS
 

Macros

#define BOOT_OPTIONS_TIMEOUT   1
 
#define BOOT_OPTIONS_NEXT_BOOTENTRY_KEY   2
 
#define MAKESTRKEY(i)   ((ULONG_PTR)(i))
 
#define MAKEINTKEY(i)   ((ULONG_PTR)((USHORT)(i)))
 
#define IS_INTKEY(i)   (((ULONG_PTR)(i) >> 16) == 0)
 
#define NTOS_OPTIONS_SIGNATURE   "NTOS_5\0\0"
 
#define BOOTSECTOR_OPTIONS_SIGNATURE   "BootSect"
 

Typedefs

typedef enum _BOOT_STORE_TYPE BOOT_STORE_TYPE
 
typedef struct _BOOT_STORE_OPTIONS BOOT_STORE_OPTIONS
 
typedef struct _BOOT_STORE_OPTIONSPBOOT_STORE_OPTIONS
 
typedef struct _BOOT_STORE_ENTRY BOOT_STORE_ENTRY
 
typedef struct _BOOT_STORE_ENTRYPBOOT_STORE_ENTRY
 
typedef struct _NTOS_OPTIONS NTOS_OPTIONS
 
typedef struct _NTOS_OPTIONSPNTOS_OPTIONS
 
typedef struct _BOOTSECTOR_OPTIONS BOOTSECTOR_OPTIONS
 
typedef struct _BOOTSECTOR_OPTIONSPBOOTSECTOR_OPTIONS
 
typedef NTSTATUS(NTAPIPENUM_BOOT_ENTRIES_ROUTINE) (IN BOOT_STORE_TYPE Type, IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL)
 
typedef enum _BOOT_STORE_OPENMODE BOOT_STORE_OPENMODE
 
typedef enum _BOOT_STORE_ACCESS BOOT_STORE_ACCESS
 

Enumerations

enum  _BOOT_STORE_TYPE { FreeLdr , NtLdr , BldrTypeMax }
 
enum  _BOOT_STORE_OPENMODE {
  BS_CheckExisting = 0 , BS_CreateNew = 1 , BS_OpenExisting = 2 , BS_OpenAlways = 3 ,
  BS_RecreateExisting = 4 , BS_CreateAlways = 5
}
 
enum  _BOOT_STORE_ACCESS { BS_ReadAccess = 1 , BS_WriteAccess = 2 , BS_ReadWriteAccess = (BS_ReadAccess | BS_WriteAccess) }
 

Functions

NTSTATUS FindBootStore (IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, OUT PULONG VersionNumber OPTIONAL)
 
NTSTATUS OpenBootStoreByHandle (_Out_ PVOID *Handle, _In_ HANDLE PartitionDirectoryHandle, _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_ BOOT_STORE_OPENMODE OpenMode, _In_ BOOT_STORE_ACCESS Access)
 
NTSTATUS OpenBootStore (_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)
 
NTSTATUS AddBootStoreEntry (IN PVOID Handle, IN PBOOT_STORE_ENTRY BootEntry, IN ULONG_PTR BootEntryKey)
 
NTSTATUS DeleteBootStoreEntry (IN PVOID Handle, IN ULONG_PTR BootEntryKey)
 
NTSTATUS ModifyBootStoreEntry (IN PVOID Handle, IN PBOOT_STORE_ENTRY BootEntry)
 
NTSTATUS QueryBootStoreEntry (IN PVOID Handle, IN ULONG_PTR BootEntryKey, OUT PBOOT_STORE_ENTRY BootEntry)
 
NTSTATUS QueryBootStoreOptions (IN PVOID Handle, IN OUT PBOOT_STORE_OPTIONS BootOptions)
 
NTSTATUS SetBootStoreOptions (IN PVOID Handle, IN PBOOT_STORE_OPTIONS BootOptions, IN ULONG FieldsToChange)
 
NTSTATUS EnumerateBootStoreEntries (IN PVOID Handle, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
 

Macro Definition Documentation

◆ BOOT_OPTIONS_NEXT_BOOTENTRY_KEY

#define BOOT_OPTIONS_NEXT_BOOTENTRY_KEY   2

Definition at line 42 of file bldrsup.h.

◆ BOOT_OPTIONS_TIMEOUT

#define BOOT_OPTIONS_TIMEOUT   1

Definition at line 41 of file bldrsup.h.

◆ BOOTSECTOR_OPTIONS_SIGNATURE

#define BOOTSECTOR_OPTIONS_SIGNATURE   "BootSect"

Definition at line 114 of file bldrsup.h.

◆ IS_INTKEY

#define IS_INTKEY (   i)    (((ULONG_PTR)(i) >> 16) == 0)

Definition at line 60 of file bldrsup.h.

◆ MAKEINTKEY

#define MAKEINTKEY (   i)    ((ULONG_PTR)((USHORT)(i)))

Definition at line 59 of file bldrsup.h.

◆ MAKESTRKEY

#define MAKESTRKEY (   i)    ((ULONG_PTR)(i))

Definition at line 58 of file bldrsup.h.

◆ NTOS_OPTIONS_SIGNATURE

#define NTOS_OPTIONS_SIGNATURE   "NTOS_5\0\0"

Definition at line 102 of file bldrsup.h.

Typedef Documentation

◆ BOOT_STORE_ACCESS

◆ BOOT_STORE_ENTRY

◆ BOOT_STORE_OPENMODE

◆ BOOT_STORE_OPTIONS

◆ BOOT_STORE_TYPE

◆ BOOTSECTOR_OPTIONS

◆ NTOS_OPTIONS

◆ PBOOT_STORE_ENTRY

◆ PBOOT_STORE_OPTIONS

◆ PBOOTSECTOR_OPTIONS

◆ PENUM_BOOT_ENTRIES_ROUTINE

typedef NTSTATUS(NTAPI * PENUM_BOOT_ENTRIES_ROUTINE) (IN BOOT_STORE_TYPE Type, IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL)

Definition at line 117 of file bldrsup.h.

◆ PNTOS_OPTIONS

Enumeration Type Documentation

◆ _BOOT_STORE_ACCESS

Enumerator
BS_ReadAccess 
BS_WriteAccess 
BS_ReadWriteAccess 

Definition at line 141 of file bldrsup.h.

142{
143 // BS_NoAccess = 0,
144 BS_ReadAccess = 1,
145 BS_WriteAccess = 2,
@ BS_WriteAccess
Definition: bldrsup.h:145
@ BS_ReadWriteAccess
Definition: bldrsup.h:146
@ BS_ReadAccess
Definition: bldrsup.h:144
enum _BOOT_STORE_ACCESS BOOT_STORE_ACCESS

◆ _BOOT_STORE_OPENMODE

Enumerator
BS_CheckExisting 
BS_CreateNew 
BS_OpenExisting 
BS_OpenAlways 
BS_RecreateExisting 
BS_CreateAlways 

Definition at line 131 of file bldrsup.h.

132{
133 BS_CheckExisting = 0, // See FindBootStore()
134 BS_CreateNew = 1, // BS_CreateOnly
135 BS_OpenExisting = 2, // BS_OpenOnly
136 BS_OpenAlways = 3,
137 BS_RecreateExisting = 4, // BS_RecreateOnly
138 BS_CreateAlways = 5,
@ BS_OpenAlways
Definition: bldrsup.h:136
@ BS_OpenExisting
Definition: bldrsup.h:135
@ BS_CreateAlways
Definition: bldrsup.h:138
@ BS_CheckExisting
Definition: bldrsup.h:133
@ BS_CreateNew
Definition: bldrsup.h:134
@ BS_RecreateExisting
Definition: bldrsup.h:137
enum _BOOT_STORE_OPENMODE BOOT_STORE_OPENMODE

◆ _BOOT_STORE_TYPE

Enumerator
FreeLdr 
NtLdr 
BldrTypeMax 

Definition at line 13 of file bldrsup.h.

14{
15 FreeLdr, // ReactOS' FreeLoader
16 NtLdr, // Windows <= 2k3 NT "FlexBoot" OS Loader NTLDR
17// BootMgr, // Vista+ BCD-oriented BOOTMGR
@ NtLdr
Definition: bldrsup.h:16
@ BldrTypeMax
Definition: bldrsup.h:18
@ FreeLdr
Definition: bldrsup.h:15
enum _BOOT_STORE_TYPE BOOT_STORE_TYPE

Function Documentation

◆ AddBootStoreEntry()

NTSTATUS AddBootStoreEntry ( IN PVOID  Handle,
IN PBOOT_STORE_ENTRY  BootEntry,
IN ULONG_PTR  BootEntryKey 
)

Definition at line 1094 of file bldrsup.c.

1098{
1100
1101 if (!BootStore || !BootEntry)
1103
1104 /*
1105 * NOTE: Currently we open & map the loader configuration file without
1106 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1107 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1108 * BOOTMGR detection, the "configuration file" will be the BCD registry
1109 * hive and then, we'll have instead to mount the hive & open it.
1110 */
1111
1112 //
1113 // FIXME!!
1114 //
1115
1116 // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1117
1118 if (BootStore->Type == FreeLdr)
1119 {
1120 if (BootEntry->Version != FreeLdr)
1122
1123 return CreateNTOSEntry((PBOOT_STORE_INI_CONTEXT)BootStore,
1124 BootEntryKey, BootEntry);
1125 }
1126 else
1127 if (BootStore->Type == NtLdr)
1128 {
1129 PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
1130 PWCHAR Buffer;
1132 PCWSTR InstallName, OsOptions;
1133 // ULONG InstallNameLength, OsOptionsLength;
1134 BOOLEAN IsNameNotQuoted;
1135
1136 if (BootEntry->Version != NtLdr)
1138
1139 if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) ||
1140 RtlCompareMemory(&BootEntry->OsOptions /* Signature */,
1144 {
1145 // DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version);
1146 DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
1147 return STATUS_SUCCESS; // STATUS_NOT_SUPPORTED;
1148 }
1149
1150 InstallName = BootEntry->FriendlyName;
1151 OsOptions = Options->OsLoadOptions;
1152
1153 // if (InstallNameLength == 0) InstallName = NULL;
1154 // if (OsOptionsLength == 0) OsOptions = NULL;
1155
1156 IsNameNotQuoted = (InstallName[0] != L'\"' || InstallName[wcslen(InstallName)-1] != L'\"');
1157
1158 BufferLength = (IsNameNotQuoted ? 2 /* Quotes for FriendlyName*/ : 0) + wcslen(InstallName);
1159 if (OsOptions)
1160 BufferLength += 1 /* Space between FriendlyName and options */ + wcslen(OsOptions);
1161 BufferLength++; /* NULL-termination */
1162
1164 if (!Buffer)
1166
1168 if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
1169 RtlStringCchCatW(Buffer, BufferLength, InstallName);
1170 if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
1171 if (OsOptions)
1172 {
1175 }
1176
1177 /* Insert the entry into the "Operating Systems" section */
1178 IniAddKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OsIniSection,
1179 Options->OsLoadPath, Buffer);
1180
1182 return STATUS_SUCCESS;
1183 }
1184 else
1185 {
1186 DPRINT1("Loader type %d is currently unsupported!\n", BootStore->Type);
1187 return STATUS_NOT_SUPPORTED;
1188 }
1189}
unsigned char BOOLEAN
HANDLE ProcessHeap
Definition: servman.c:15
#define DPRINT1
Definition: precomp.h:8
static NTSTATUS CreateNTOSEntry(IN PBOOT_STORE_INI_CONTEXT BootStore, IN ULONG_PTR BootEntryKey, IN PBOOT_STORE_ENTRY BootEntry)
Definition: bldrsup.c:1042
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
struct _NTOS_OPTIONS * PNTOS_OPTIONS
#define NTOS_OPTIONS_SIGNATURE
Definition: bldrsup.h:102
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
Definition: bufpool.h:45
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const WCHAR Signature[]
Definition: parser.c:141
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
ULONG Handle
Definition: gdb_input.c:15
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PINI_KEYWORD IniAddKey(_In_ PINI_SECTION Section, _In_ PCWSTR Name, _In_ PCWSTR Data)
Definition: inicache.c:883
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
if(dx< 0)
Definition: linetemp.h:194
#define UNICODE_NULL
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:601
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOT_STORE_TYPE Type
Definition: bldrsup.c:60
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CreateFreeLoaderIniForReactOSAndBootSector(), CreateFreeLoaderReactOSEntries(), UpdateBootIni(), and UpdateFreeLoaderIni().

◆ CloseBootStore()

NTSTATUS CloseBootStore ( _In_ PVOID  Handle)

Definition at line 1014 of file bldrsup.c.

1016{
1018
1019 if (!BootStore)
1021
1022 /*
1023 * NOTE: Currently we open & map the loader configuration file without
1024 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1025 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1026 * BOOTMGR detection, the "configuration file" will be the BCD registry
1027 * hive and then, we'll have instead to mount the hive & open it.
1028 */
1029
1030 if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1031 {
1032 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1033 return STATUS_NOT_SUPPORTED;
1034 }
1035
1036 return NtosBootLoaders[BootStore->Type].CloseBootStore(Handle /* BootStore */);
1037}
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:125
PCLOSE_BOOT_STORE CloseBootStore
Definition: bldrsup.c:50
BOOT_STORE_TYPE Type
Definition: bldrsup.c:46

Referenced by CreateFreeLoaderIniForReactOS(), CreateFreeLoaderIniForReactOSAndBootSector(), FindNTOSInstallations(), UpdateBootIni(), and UpdateFreeLoaderIni().

◆ DeleteBootStoreEntry()

NTSTATUS DeleteBootStoreEntry ( IN PVOID  Handle,
IN ULONG_PTR  BootEntryKey 
)

Definition at line 1192 of file bldrsup.c.

1195{
1197
1198 if (!BootStore)
1200
1201 /*
1202 * NOTE: Currently we open & map the loader configuration file without
1203 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1204 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1205 * BOOTMGR detection, the "configuration file" will be the BCD registry
1206 * hive and then, we'll have instead to mount the hive & open it.
1207 */
1208
1209 //
1210 // FIXME!!
1211 //
1212
1213 // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1214 if (BootStore->Type != FreeLdr)
1215 {
1216 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1217 return STATUS_NOT_SUPPORTED;
1218 }
1219
1220 // FIXME! This function needs my INI library rewrite to be implemented!!
1223}
#define UNIMPLEMENTED
Definition: debug.h:118
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

◆ EnumerateBootStoreEntries()

NTSTATUS EnumerateBootStoreEntries ( IN PVOID  Handle,
IN PENUM_BOOT_ENTRIES_ROUTINE  EnumBootEntriesRoutine,
IN PVOID Parameter  OPTIONAL 
)

Definition at line 1703 of file bldrsup.c.

1708{
1710
1711 if (!BootStore)
1713
1714 if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1715 {
1716 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1717 return STATUS_SUCCESS;
1718 // return STATUS_INVALID_PARAMETER;
1719 }
1720
1721 return NtosBootLoaders[BootStore->Type].EnumBootStoreEntries(
1722 (PBOOT_STORE_INI_CONTEXT)BootStore, // Flags,
1723 EnumBootEntriesRoutine, Parameter);
1724}
PENUM_BOOT_STORE_ENTRIES EnumBootStoreEntries
Definition: bldrsup.c:51
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:323

Referenced by FindNTOSInstallations(), UpdateBootIni(), and UpdateFreeLoaderIni().

◆ FindBootStore()

NTSTATUS FindBootStore ( IN HANDLE  PartitionDirectoryHandle,
IN BOOT_STORE_TYPE  Type,
OUT PULONG VersionNumber  OPTIONAL 
)

Definition at line 151 of file bldrsup.c.

156{
157 PCWSTR LoaderExecutable;
158 // UINT i;
159
160 if (Type >= BldrTypeMax)
162
163 if (VersionNumber)
164 *VersionNumber = 0;
165
166 /* Check whether any of the loader executables exist */
167 LoaderExecutable = NtosBootLoaders[Type].LoaderExecutables;
168 while (*LoaderExecutable)
169 {
170 if (DoesFileExist(PartitionDirectoryHandle, LoaderExecutable))
171 {
172 /* A loader was found, stop there */
173 DPRINT("Found loader executable '%S'\n", LoaderExecutable);
174 break;
175 }
176
177 /* The loader does not exist, continue with another one */
178 DPRINT("Loader executable '%S' does not exist, continue with another one...\n", LoaderExecutable);
179 LoaderExecutable += wcslen(LoaderExecutable) + 1;
180 }
181 if (!*LoaderExecutable)
182 {
183 /* No loader was found */
184 DPRINT("No loader executable was found\n");
185 return STATUS_NOT_FOUND;
186 }
187
188 /* Check for loader version if needed */
189 if (VersionNumber)
190 {
191 *VersionNumber = 0;
192 // TODO: Check for BLDR version!
193 }
194
195 /* Check whether the loader configuration file exists */
196#if 0
197 Status = OpenAndMapFile(PartitionDirectoryHandle, NtosBootLoaders[Type].LoaderConfigurationFile,
198 &FileHandle, &FileSize, &SectionHandle, &ViewBase, FALSE);
199 if (!NT_SUCCESS(Status))
200#else
201 if (!DoesFileExist(PartitionDirectoryHandle, NtosBootLoaders[Type].LoaderConfigurationFile))
202#endif
203 {
204 /* The loader does not exist, continue with another one */
205 // FIXME: Consider it might be optional??
206 DPRINT1("Loader configuration file '%S' does not exist\n", NtosBootLoaders[Type].LoaderConfigurationFile);
207 return STATUS_NOT_FOUND;
208 }
209
210 return STATUS_SUCCESS;
211}
Type
Definition: Type.h:7
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS OpenAndMapFile(_In_opt_ HANDLE RootDirectory, _In_ PCWSTR PathNameToFile, _Out_opt_ PHANDLE FileHandle, _Out_opt_ PULONG FileSize, _Out_ PHANDLE SectionHandle, _Out_ PVOID *BaseAddress, _In_ BOOLEAN ReadWriteAccess)
Opens and maps a file in memory.
Definition: filesup.c:887
#define DoesFileExist(RootDirectory, FileName)
Definition: filesup.h:77
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define DPRINT
Definition: sndvol32.h:73
PCZZWSTR LoaderExecutables
Definition: bldrsup.c:47

Referenced by FindNTOSInstallations().

◆ ModifyBootStoreEntry()

NTSTATUS ModifyBootStoreEntry ( IN PVOID  Handle,
IN PBOOT_STORE_ENTRY  BootEntry 
)

Definition at line 1226 of file bldrsup.c.

1229{
1231
1232 if (!BootStore || !BootEntry)
1234
1235 /*
1236 * NOTE: Currently we open & map the loader configuration file without
1237 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1238 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1239 * BOOTMGR detection, the "configuration file" will be the BCD registry
1240 * hive and then, we'll have instead to mount the hive & open it.
1241 */
1242
1243 //
1244 // FIXME!!
1245 //
1246
1247 // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1248 if (BootStore->Type != FreeLdr)
1249 {
1250 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1251 return STATUS_NOT_SUPPORTED;
1252 }
1253
1254 // FIXME! This function needs my INI library rewrite to operate properly!!
1257}

◆ OpenBootStore()

NTSTATUS OpenBootStore ( _Out_ PVOID Handle,
_In_ PCWSTR  SystemPartition,
_In_ BOOT_STORE_TYPE  Type,
_In_ BOOT_STORE_OPENMODE  OpenMode,
_In_ BOOT_STORE_ACCESS  Access 
)

Definition at line 997 of file bldrsup.c.

1003{
1004 UNICODE_STRING SystemPartitionPath;
1005 RtlInitUnicodeString(&SystemPartitionPath, SystemPartition);
1007 &SystemPartitionPath,
1008 Type,
1009 OpenMode,
1010 Access);
1011}
NTSTATUS OpenBootStore_UStr(_Out_ PVOID *Handle, _In_ PUNICODE_STRING SystemPartitionPath, _In_ BOOT_STORE_TYPE Type, _In_ BOOT_STORE_OPENMODE OpenMode, _In_ BOOT_STORE_ACCESS Access)
Definition: bldrsup.c:940
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static PPARTENTRY SystemPartition
Definition: usetup.c:61

Referenced by CreateFreeLoaderIniForReactOS(), CreateFreeLoaderIniForReactOSAndBootSector(), UpdateBootIni(), and UpdateFreeLoaderIni().

◆ OpenBootStore_UStr()

NTSTATUS OpenBootStore_UStr ( _Out_ PVOID Handle,
_In_ PUNICODE_STRING  SystemPartitionPath,
_In_ BOOT_STORE_TYPE  Type,
_In_ BOOT_STORE_OPENMODE  OpenMode,
_In_ BOOT_STORE_ACCESS  Access 
)

Definition at line 940 of file bldrsup.c.

946{
950 HANDLE PartitionDirectoryHandle;
951
952 /*
953 * NOTE: Currently we open & map the loader configuration file without
954 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
955 * and NTLDR's boot.ini files. But as soon as we'll implement support for
956 * BOOTMGR detection, the "configuration file" will be the BCD registry
957 * hive and then, we'll have instead to mount the hive & open it.
958 */
959
961 {
962 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
964 }
965
966 /* Open SystemPartition */
968 SystemPartitionPath,
970 NULL,
971 NULL);
972 Status = NtOpenFile(&PartitionDirectoryHandle,
973 FILE_LIST_DIRECTORY | FILE_ADD_FILE /* | FILE_ADD_SUBDIRECTORY | FILE_TRAVERSE*/ | SYNCHRONIZE,
977 FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE /* | FILE_OPEN_FOR_BACKUP_INTENT */);
978 if (!NT_SUCCESS(Status))
979 {
980 DPRINT1("Failed to open SystemPartition '%wZ' (Status 0x%08lx)\n",
981 SystemPartitionPath, Status);
982 return Status;
983 }
984
986 PartitionDirectoryHandle,
987 Type,
988 OpenMode,
989 Access);
990
991 /* Done! */
992 NtClose(PartitionDirectoryHandle);
993 return Status;
994}
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
NTSTATUS OpenBootStoreByHandle(_Out_ PVOID *Handle, _In_ HANDLE PartitionDirectoryHandle, _In_ BOOT_STORE_TYPE Type, _In_ BOOT_STORE_OPENMODE OpenMode, _In_ BOOT_STORE_ACCESS Access)
Definition: bldrsup.c:897
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_ADD_FILE
Definition: nt_native.h:632

Referenced by OpenBootStore().

◆ OpenBootStoreByHandle()

NTSTATUS OpenBootStoreByHandle ( _Out_ PVOID Handle,
_In_ HANDLE  PartitionDirectoryHandle,
_In_ BOOT_STORE_TYPE  Type,
_In_ BOOT_STORE_OPENMODE  OpenMode,
_In_ BOOT_STORE_ACCESS  Access 
)

Definition at line 897 of file bldrsup.c.

903{
904 /*
905 * NOTE: Currently we open & map the loader configuration file without
906 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
907 * and NTLDR's boot.ini files. But as soon as we'll implement support for
908 * BOOTMGR detection, the "configuration file" will be the BCD registry
909 * hive and then, we'll have instead to mount the hive & open it.
910 */
911
913 {
914 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
916 }
917
918 /*
919 * Verify the access modes to perform the open actions.
920 * The operating system may allow e.g. file creation even with
921 * read-only access, but we do not allow this because we want
922 * to protect any existing boot store file in case the caller
923 * specified such an open mode.
924 */
925 // if ((OpenMode == BS_CheckExisting) && !(Access & BS_ReadAccess))
926 // return STATUS_ACCESS_DENIED;
927 if ((OpenMode == BS_CreateNew || OpenMode == BS_CreateAlways || OpenMode == BS_RecreateExisting) && !(Access & BS_WriteAccess))
929 if ((OpenMode == BS_OpenExisting || OpenMode == BS_OpenAlways) && !(Access & BS_ReadWriteAccess))
931
933 PartitionDirectoryHandle,
934 Type,
935 OpenMode,
936 Access);
937}
POPEN_BOOT_STORE OpenBootStore
Definition: bldrsup.c:49
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

Referenced by FindNTOSInstallations(), and OpenBootStore_UStr().

◆ QueryBootStoreEntry()

NTSTATUS QueryBootStoreEntry ( IN PVOID  Handle,
IN ULONG_PTR  BootEntryKey,
OUT PBOOT_STORE_ENTRY  BootEntry 
)

Definition at line 1260 of file bldrsup.c.

1264{
1266
1267 if (!BootStore)
1269
1270 /*
1271 * NOTE: Currently we open & map the loader configuration file without
1272 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1273 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1274 * BOOTMGR detection, the "configuration file" will be the BCD registry
1275 * hive and then, we'll have instead to mount the hive & open it.
1276 */
1277
1278 //
1279 // FIXME!!
1280 //
1281
1282 // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1283 if (BootStore->Type != FreeLdr)
1284 {
1285 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1286 return STATUS_NOT_SUPPORTED;
1287 }
1288
1289 // FIXME! This function needs my INI library rewrite to be implemented!!
1292}

◆ QueryBootStoreOptions()

NTSTATUS QueryBootStoreOptions ( IN PVOID  Handle,
IN OUT PBOOT_STORE_OPTIONS  BootOptions 
)

Definition at line 1295 of file bldrsup.c.

1299{
1301 PCWSTR TimeoutStr;
1302
1303 if (!BootStore || !BootOptions)
1305
1306 /*
1307 * NOTE: Currently we open & map the loader configuration file without
1308 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1309 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1310 * BOOTMGR detection, the "configuration file" will be the BCD registry
1311 * hive and then, we'll have instead to mount the hive & open it.
1312 */
1313
1314 //
1315 // FIXME!!
1316 //
1317
1318 // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1319 if (BootStore->Type != FreeLdr && BootStore->Type != NtLdr)
1320 {
1321 DPRINT1("Loader type %d is currently unsupported!\n", BootStore->Type);
1322 return STATUS_NOT_SUPPORTED;
1323 }
1324
1325 BootOptions->Timeout = 0;
1326 BootOptions->CurrentBootEntryKey = 0;
1327 BootOptions->NextBootEntryKey = 0;
1328
1329 if (IniGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1330 BootOptionNames[BootStore->Type][BO_TimeOut],
1331 &TimeoutStr) && TimeoutStr)
1332 {
1333 BootOptions->Timeout = _wtoi(TimeoutStr);
1334 }
1335
1336 IniGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1337 BootOptionNames[BootStore->Type][BO_DefaultOS],
1338 (PCWSTR*)&BootOptions->NextBootEntryKey);
1339
1340 /*
1341 * NOTE: BootOptions->CurrentBootEntryKey is an informative field only.
1342 * It indicates which boot entry has been selected for starting the
1343 * current OS instance. Such information is NOT stored in the INI file,
1344 * but has to be determined via other means. On UEFI the 'BootCurrent'
1345 * environment variable does that. Otherwise, one could heuristically
1346 * determine it by comparing the boot path and options of each entry
1347 * with those used by the current OS instance.
1348 * Since we currently do not need this information (and it can be costly
1349 * to determine), BootOptions->CurrentBootEntryKey is not evaluated.
1350 */
1351
1352 return STATUS_SUCCESS;
1353}
@ BootOptions
Definition: bl.h:898
@ BO_DefaultOS
Definition: bldrsup.c:139
@ BO_TimeOut
Definition: bldrsup.c:138
static const PCWSTR BootOptionNames[][2]
Definition: bldrsup.c:141
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
PINI_KEYWORD IniGetKey(_In_ PINI_SECTION Section, _In_ PCWSTR KeyName, _Out_ PCWSTR *KeyData)
Definition: inicache.c:730

◆ SetBootStoreOptions()

NTSTATUS SetBootStoreOptions ( IN PVOID  Handle,
IN PBOOT_STORE_OPTIONS  BootOptions,
IN ULONG  FieldsToChange 
)

Definition at line 1356 of file bldrsup.c.

1360{
1362
1363 if (!BootStore || !BootOptions)
1365
1366 /*
1367 * NOTE: Currently we open & map the loader configuration file without
1368 * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1369 * and NTLDR's boot.ini files. But as soon as we'll implement support for
1370 * BOOTMGR detection, the "configuration file" will be the BCD registry
1371 * hive and then, we'll have instead to mount the hive & open it.
1372 */
1373
1374 //
1375 // FIXME!!
1376 //
1377
1378 // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1379 if (BootStore->Type != FreeLdr && BootStore->Type != NtLdr)
1380 {
1381 DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1382 return STATUS_NOT_SUPPORTED;
1383 }
1384
1385 // if (BootOptions->Length < sizeof(*BootOptions))
1386 // return STATUS_INVALID_PARAMETER;
1387
1388 if (FieldsToChange & BOOT_OPTIONS_TIMEOUT)
1389 {
1390 WCHAR TimeoutStr[15];
1391 RtlStringCchPrintfW(TimeoutStr, ARRAYSIZE(TimeoutStr), L"%d", BootOptions->Timeout);
1392 IniAddKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1393 BootOptionNames[BootStore->Type][BO_TimeOut],
1394 TimeoutStr);
1395 }
1396 if (FieldsToChange & BOOT_OPTIONS_NEXT_BOOTENTRY_KEY)
1397 {
1398 IniAddKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1399 BootOptionNames[BootStore->Type][BO_DefaultOS],
1400 (PCWSTR)BootOptions->NextBootEntryKey);
1401 }
1402
1403 return STATUS_SUCCESS;
1404}
#define BOOT_OPTIONS_NEXT_BOOTENTRY_KEY
Definition: bldrsup.h:42
#define BOOT_OPTIONS_TIMEOUT
Definition: bldrsup.h:41
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110

Referenced by CreateFreeLoaderReactOSEntries().