124 {
FreeLdr,
L"freeldr.sys\0",
L"freeldr.ini",
126 {
NtLdr ,
L"ntldr\0" L"osloader.exe\0",
L"boot.ini",
154 while (*LoaderExecutable)
156 if (
DoesFileExist(PartitionDirectoryHandle, LoaderExecutable))
159 DPRINT(
"Found loader executable '%S'\n", LoaderExecutable);
164 DPRINT(
"Loader executable '%S' does not exist, continue with another one...\n", LoaderExecutable);
165 LoaderExecutable +=
wcslen(LoaderExecutable) + 1;
167 if (!*LoaderExecutable)
170 DPRINT(
"No loader executable was found\n");
225 DPRINT1(
"CreateCommonFreeLdrSections: Failed to create 'FREELOADER' section!\n");
229 BootStore->OptionsIniSection = IniSection;
240 L"TitleText",
L"ReactOS Boot Manager");
244 L"MinimalUI",
L"Yes");
258 DPRINT1(
"CreateCommonFreeLdrSections: Failed to create 'Operating Systems' section!\n");
262 BootStore->OsIniSection = IniSection;
293 DPRINT1(
"OpenIniBootLoaderStore() unsupported for NTLDR!\n");
302 DPRINT1(
"IniCacheCreate() failed.\n");
327 PartitionDirectoryHandle,
373 DPRINT1(
"Loader configuration file '%S' does not exist (Status 0x%08lx)\n",
387 DPRINT1(
"IniCacheLoadFromMemory() failed (Status 0x%08lx)\n",
Status);
412 DPRINT1(
"OpenIniBootLoaderStore: Failed to retrieve 'FREELOADER' section!\n");
430 DPRINT1(
"OpenIniBootLoaderStore: Failed to retrieve 'Operating Systems' section!\n");
497 DPRINT1(
"OpenIniBootLoaderStore: Failed to retrieve 'boot loader' section!\n");
517 DPRINT1(
"OpenIniBootLoaderStore: Failed to retrieve 'operating systems' section!\n");
546 DPRINT1(
"NtQueryInformationFile() failed (Status 0x%08lx)\n",
Status);
564 DPRINT1(
"NtSetInformationFile() failed (Status 0x%08lx)\n",
Status);
585 DPRINT1(
"NtQueryInformationFile() failed (Status 0x%08lx)\n",
Status);
597 DPRINT1(
"NtSetInformationFile() failed (Status 0x%08lx)\n",
Status);
608 ULONG FileAttribute = 0;
624 DPRINT1(
"Could not unprotect BOOT.INI ! (Status 0x%08lx)\n",
Status);
685 PartitionDirectoryHandle,
700 HANDLE PartitionDirectoryHandle;
730 DPRINT1(
"Failed to open SystemPartition '%wZ', Status 0x%08lx\n", SystemPartitionPath,
Status);
737 NtClose(PartitionDirectoryHandle);
793 Section, (
PWSTR)BootEntry->FriendlyName);
798 if (BootEntry->OsOptionsLength >=
sizeof(
NTOS_OPTIONS) &&
808 L"BootType",
L"Windows2003");
829 L"BootType",
L"BootSector");
847 DPRINT1(
"Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
861 if (!BootStore || !BootEntry)
880 if (BootEntry->Version !=
FreeLdr)
884 BootEntryKey, BootEntry);
892 PCWSTR InstallName, OsOptions;
896 if (BootEntry->Version !=
NtLdr)
899 if (BootEntry->OsOptionsLength <
sizeof(
NTOS_OPTIONS) ||
906 DPRINT1(
"Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
910 InstallName = BootEntry->FriendlyName;
911 OsOptions =
Options->OsLoadOptions;
916 IsNameNotQuoted = (InstallName[0] !=
L'\"' || InstallName[
wcslen(InstallName)-1] !=
L'\"');
946 DPRINT1(
"Loader type %d is currently unsupported!\n", BootStore->
Type);
992 if (!BootStore || !BootEntry)
1082 DPRINT1(
"Loader type %d is currently unsupported!\n", BootStore->
Type);
1096 L"TimeOut", &TimeoutStr);
1112 L"timeout", &TimeoutStr);
1129 WCHAR TimeoutStr[15];
1167 L"TimeOut", TimeoutStr);
1184 PWCHAR SectionName, KeyData;
1196 ULONG InstallNameLength;
1199 if (*KeyData ==
L'"')
1207 InstallName = KeyData + 1;
1208 InstallNameLength = End - InstallName;
1213 InstallName = KeyData;
1214 InstallNameLength =
wcslen(InstallName);
1216 if (InstallNameLength == 0) InstallName =
NULL;
1221 InstallName = KeyData;
1222 InstallNameLength =
wcslen(InstallName);
1223 if (InstallNameLength == 0) InstallName =
NULL;
1228 if (InstallNameLength)
1237 DPRINT(
"Boot entry '%S' in OS section '%S'\n", InstallName, SectionName);
1255 DPRINT1(
"No BootType value present!\n");
1260 if ((
_wcsicmp(KeyData,
L"Windows2003") == 0) ||
1261 (
_wcsicmp(KeyData,
L"\"Windows2003\"") == 0))
1266 DPRINT(
"This is a '%S' boot entry\n", KeyData);
1280 Options->OsLoadPath = KeyData;
1288 Options->OsLoadOptions = KeyData;
1291 if ((
_wcsicmp(KeyData,
L"BootSector") == 0) ||
1292 (
_wcsicmp(KeyData,
L"\"BootSector\"") == 0))
1297 DPRINT(
"This is a '%S' boot entry\n", KeyData);
1325 Options->BootSectorFileName = KeyData;
1329 DPRINT1(
"Unrecognized BootType value '%S'\n", KeyData);
1360 PWCHAR SectionName, KeyData;
1372 PWCHAR InstallName, OsOptions;
1373 ULONG InstallNameLength, OsOptionsLength;
1376 if (*KeyData ==
L'"')
1379 OsOptions =
wcschr(KeyData + 1,
L'"');
1385 InstallName = KeyData + 1;
1386 InstallNameLength = OsOptions - InstallName;
1387 if (InstallNameLength == 0) InstallName =
NULL;
1393 while (
iswspace(*OsOptions)) ++OsOptions;
1395 OsOptionsLength =
wcslen(OsOptions);
1396 if (OsOptionsLength == 0) OsOptions =
NULL;
1401 InstallName = KeyData;
1402 InstallNameLength =
wcslen(InstallName);
1403 if (InstallNameLength == 0) InstallName =
NULL;
1407 OsOptionsLength = 0;
1415 InstallName = KeyData;
1416 InstallNameLength =
wcslen(InstallName);
1417 if (InstallNameLength == 0) InstallName =
NULL;
1421 OsOptionsLength = 0;
1434 if (InstallName && InstallNameLength)
1443 if (OsOptions && OsOptionsLength)
1452 DPRINT1(
"Boot entry '%S' in OS section (path) '%S'\n", InstallName, SectionName);
1455 BootEntry->Version =
NtLdr;
1456 BootEntry->BootEntryKey = 0;
1457 BootEntry->FriendlyName = InstallName;
1458 BootEntry->BootFilePath =
NULL;
1465 Options->OsLoadPath = SectionName;
1466 Options->OsLoadOptions = OsOptions;
#define FILE_DIRECTORY_FILE
#define FILE_NON_DIRECTORY_FILE
static NTSTATUS NtLdrEnumerateBootEntries(IN PBOOT_STORE_INI_CONTEXT BootStore, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
struct _BOOT_STORE_BCDREG_CONTEXT * PBOOT_STORE_BCDREG_CONTEXT
static NTSTATUS OpenIniBootLoaderStore(OUT PVOID *Handle, IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
static NTSTATUS UnprotectBootIni(IN HANDLE FileHandle, OUT PULONG Attributes)
NTSTATUS OpenBootStoreByHandle(OUT PVOID *Handle, IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
NTSTATUS OpenBootStore(OUT PVOID *Handle, IN PCWSTR SystemPartition, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
static VOID CreateCommonFreeLdrSections(IN OUT PBOOT_STORE_INI_CONTEXT BootStore)
NTSTATUS OpenBootStore_UStr(OUT PVOID *Handle, IN PUNICODE_STRING SystemPartitionPath, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
NTSTATUS DeleteBootStoreEntry(IN PVOID Handle, IN ULONG_PTR BootEntryKey)
struct _BOOT_STORE_INI_CONTEXT BOOT_STORE_INI_CONTEXT
static NTSTATUS FreeLdrEnumerateBootEntries(IN PBOOT_STORE_INI_CONTEXT BootStore, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
NTSTATUS QueryBootStoreEntry(IN PVOID Handle, IN ULONG_PTR BootEntryKey, OUT PBOOT_STORE_ENTRY BootEntry)
static NTSTATUS ProtectBootIni(IN HANDLE FileHandle, IN ULONG Attributes)
static NTSTATUS CreateNTOSEntry(IN PBOOT_STORE_INI_CONTEXT BootStore, IN ULONG_PTR BootEntryKey, IN PBOOT_STORE_ENTRY BootEntry)
NTSTATUS SetBootStoreOptions(IN PVOID Handle, IN PBOOT_STORE_OPTIONS BootOptions, IN ULONG FieldsToChange)
struct _BOOT_STORE_INI_CONTEXT * PBOOT_STORE_INI_CONTEXT
struct _BOOT_STORE_BCDREG_CONTEXT BOOT_STORE_BCDREG_CONTEXT
NTSTATUS AddBootStoreEntry(IN PVOID Handle, IN PBOOT_STORE_ENTRY BootEntry, IN ULONG_PTR BootEntryKey)
NTSTATUS(* PCLOSE_BOOT_STORE)(IN PVOID Handle)
static NTSTATUS CloseIniBootLoaderStore(IN PVOID Handle)
struct _NTOS_BOOT_LOADER_FILES * PNTOS_BOOT_LOADER_FILES
NTSTATUS ModifyBootStoreEntry(IN PVOID Handle, IN PBOOT_STORE_ENTRY BootEntry)
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
NTSTATUS EnumerateBootStoreEntries(IN PVOID Handle, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
struct _BOOT_STORE_CONTEXT BOOT_STORE_CONTEXT
NTSTATUS QueryBootStoreOptions(IN PVOID Handle, IN OUT PBOOT_STORE_OPTIONS BootOptions)
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
NTSTATUS FindBootStore(IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, OUT PULONG VersionNumber OPTIONAL)
struct _NTOS_BOOT_LOADER_FILES NTOS_BOOT_LOADER_FILES
NTSTATUS(* POPEN_BOOT_STORE)(OUT PVOID *Handle, IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
NTSTATUS CloseBootStore(IN PVOID Handle)
NTSTATUS(* PENUM_BOOT_STORE_ENTRIES)(IN PVOID Handle, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
struct _BOOT_SECTOR_OPTIONS * PBOOT_SECTOR_OPTIONS
struct _NTOS_OPTIONS NTOS_OPTIONS
#define BOOT_SECTOR_OPTIONS_SIGNATURE
struct _NTOS_OPTIONS * PNTOS_OPTIONS
struct _BOOT_STORE_ENTRY * PBOOT_STORE_ENTRY
NTSTATUS(NTAPI * PENUM_BOOT_ENTRIES_ROUTINE)(IN BOOT_STORE_TYPE Type, IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL)
#define NTOS_OPTIONS_SIGNATURE
struct _BOOT_SECTOR_OPTIONS BOOT_SECTOR_OPTIONS
enum _BOOT_STORE_TYPE BOOT_STORE_TYPE
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define FILE_ATTRIBUTE_NORMAL
static const WCHAR Signature[]
#define RtlCompareMemory(s1, s2, l)
NTSTATUS OpenAndMapFile(IN HANDLE RootDirectory OPTIONAL, IN PCWSTR PathNameToFile, OUT PHANDLE FileHandle, OUT PHANDLE SectionHandle, OUT PVOID *BaseAddress, OUT PULONG FileSize OPTIONAL, IN BOOLEAN ReadWriteAccess)
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)
#define DoesFileExist(RootDirectory, FileName)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
#define FILE_SEQUENTIAL_ONLY
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
NTSTATUS IniCacheLoadFromMemory(PINICACHE *Cache, PCHAR FileBuffer, ULONG FileLength, BOOLEAN String)
NTSTATUS IniCacheSaveByHandle(PINICACHE Cache, HANDLE FileHandle)
NTSTATUS IniCacheGetKey(PINICACHESECTION Section, PWCHAR KeyName, PWCHAR *KeyData)
PINICACHESECTION IniCacheAppendSection(PINICACHE Cache, PWCHAR Name)
BOOLEAN IniCacheFindNextValue(PINICACHEITERATOR Iterator, PWCHAR *KeyName, PWCHAR *KeyData)
PINICACHEITERATOR IniCacheFindFirstValue(PINICACHESECTION Section, PWCHAR *KeyName, PWCHAR *KeyData)
PINICACHEKEY IniCacheInsertKey(PINICACHESECTION Section, PINICACHEKEY AnchorKey, INSERTION_TYPE InsertionType, PWCHAR Name, PWCHAR Data)
PINICACHESECTION IniCacheGetSection(PINICACHE Cache, PWCHAR Name)
PINICACHE IniCacheCreate(VOID)
VOID IniCacheDestroy(PINICACHE Cache)
VOID IniCacheFindClose(PINICACHEITERATOR Iterator)
#define RTL_FIELD_SIZE(type, field)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
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)
#define FILE_ATTRIBUTE_READONLY
#define FILE_LIST_DIRECTORY
#define FILE_ATTRIBUTE_HIDDEN
#define FILE_ATTRIBUTE_SYSTEM
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define FILE_GENERIC_READ
#define FILE_GENERIC_WRITE
_NullNull_terminated_ CONST WCHAR * PCZZWSTR
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
PULONG MinorVersion OPTIONAL
BOOT_STORE_CONTEXT Header
UCHAR OsOptions[ANYSIZE_ARRAY]
BOOT_STORE_CONTEXT Header
PINICACHESECTION OptionsIniSection
PINICACHESECTION OsIniSection
PCLOSE_BOOT_STORE CloseBootStore
POPEN_BOOT_STORE OpenBootStore
PENUM_BOOT_STORE_ENTRIES EnumBootStoreEntries
PCZZWSTR LoaderExecutables
PCWSTR LoaderConfigurationFile
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
static PPARTENTRY SystemPartition
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength