ReactOS  0.4.15-dev-4920-g5fa8403
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  _BOOT_SECTOR_OPTIONS
 

Macros

#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 BOOT_SECTOR_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 _BOOT_SECTOR_OPTIONS BOOT_SECTOR_OPTIONS
 
typedef struct _BOOT_SECTOR_OPTIONSPBOOT_SECTOR_OPTIONS
 
typedef NTSTATUS(NTAPIPENUM_BOOT_ENTRIES_ROUTINE) (IN BOOT_STORE_TYPE Type, IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL)
 

Enumerations

enum  _BOOT_STORE_TYPE { FreeLdr, NtLdr, BldrTypeMax }
 

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 BOOLEAN CreateNew)
 
NTSTATUS OpenBootStore_UStr (OUT PVOID *Handle, IN PUNICODE_STRING SystemPartitionPath, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
 
NTSTATUS OpenBootStore (OUT PVOID *Handle, IN PCWSTR SystemPartition, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
 
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_SECTOR_OPTIONS_SIGNATURE

#define BOOT_SECTOR_OPTIONS_SIGNATURE   "BootSect"

Definition at line 111 of file bldrsup.h.

◆ IS_INTKEY

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

Definition at line 56 of file bldrsup.h.

◆ MAKEINTKEY

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

Definition at line 55 of file bldrsup.h.

◆ MAKESTRKEY

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

Definition at line 54 of file bldrsup.h.

◆ NTOS_OPTIONS_SIGNATURE

#define NTOS_OPTIONS_SIGNATURE   "NTOS_5\0\0"

Definition at line 98 of file bldrsup.h.

Typedef Documentation

◆ BOOT_SECTOR_OPTIONS

◆ BOOT_STORE_ENTRY

◆ BOOT_STORE_OPTIONS

◆ BOOT_STORE_TYPE

◆ NTOS_OPTIONS

◆ PBOOT_SECTOR_OPTIONS

◆ PBOOT_STORE_ENTRY

◆ PBOOT_STORE_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 115 of file bldrsup.h.

◆ PNTOS_OPTIONS

Enumeration Type Documentation

◆ _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
Definition: bldrsup.h:16
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 854 of file bldrsup.c.

858 {
860 
861  if (!BootStore || !BootEntry)
863 
864  /*
865  * NOTE: Currently we open & map the loader configuration file without
866  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
867  * and NTLDR's boot.ini files. But as soon as we'll implement support for
868  * BOOTMGR detection, the "configuration file" will be the BCD registry
869  * hive and then, we'll have instead to mount the hive & open it.
870  */
871 
872  //
873  // FIXME!!
874  //
875 
876  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
877 
878  if (BootStore->Type == FreeLdr)
879  {
880  if (BootEntry->Version != FreeLdr)
882 
883  return CreateNTOSEntry((PBOOT_STORE_INI_CONTEXT)BootStore,
884  BootEntryKey, BootEntry);
885  }
886  else
887  if (BootStore->Type == NtLdr)
888  {
889  PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
890  PWCHAR Buffer;
892  PCWSTR InstallName, OsOptions;
893  // ULONG InstallNameLength, OsOptionsLength;
894  BOOLEAN IsNameNotQuoted;
895 
896  if (BootEntry->Version != NtLdr)
898 
899  if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) ||
900  RtlCompareMemory(&BootEntry->OsOptions /* Signature */,
904  {
905  // DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version);
906  DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
907  return STATUS_SUCCESS; // STATUS_NOT_SUPPORTED;
908  }
909 
910  InstallName = BootEntry->FriendlyName;
911  OsOptions = Options->OsLoadOptions;
912 
913  // if (InstallNameLength == 0) InstallName = NULL;
914  // if (OsOptionsLength == 0) OsOptions = NULL;
915 
916  IsNameNotQuoted = (InstallName[0] != L'\"' || InstallName[wcslen(InstallName)-1] != L'\"');
917 
918  BufferLength = (IsNameNotQuoted ? 2 /* Quotes for FriendlyName*/ : 0) + wcslen(InstallName);
919  if (OsOptions)
920  BufferLength += 1 /* Space between FriendlyName and options */ + wcslen(OsOptions);
921  BufferLength++; /* NULL-termination */
922 
924  if (!Buffer)
926 
927  *Buffer = UNICODE_NULL;
928  if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
929  RtlStringCchCatW(Buffer, BufferLength, InstallName);
930  if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
931  if (OsOptions)
932  {
934  RtlStringCchCatW(Buffer, BufferLength, OsOptions);
935  }
936 
937  /* Insert the entry into the "Operating Systems" section */
938  IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OsIniSection, NULL, INSERT_LAST,
939  (PWSTR)Options->OsLoadPath, Buffer);
940 
942  return STATUS_SUCCESS;
943  }
944  else
945  {
946  DPRINT1("Loader type %d is currently unsupported!\n", BootStore->Type);
947  return STATUS_NOT_SUPPORTED;
948  }
949 }
#define NTOS_OPTIONS_SIGNATURE
Definition: bldrsup.h:98
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
const uint16_t * PCWSTR
Definition: typedefs.h:57
PINICACHEKEY IniCacheInsertKey(PINICACHESECTION Section, PINICACHEKEY AnchorKey, INSERTION_TYPE InsertionType, PWCHAR Name, PWCHAR Data)
Definition: inicache.c:826
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
return STATUS_NOT_SUPPORTED
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:56
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
uint16_t * PWCHAR
Definition: typedefs.h:56
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
unsigned char BOOLEAN
Definition: bufpool.h:45
Definition: bldrsup.h:16
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3531
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:601
static NTSTATUS CreateNTOSEntry(IN PBOOT_STORE_INI_CONTEXT BootStore, IN ULONG_PTR BootEntryKey, IN PBOOT_STORE_ENTRY BootEntry)
Definition: bldrsup.c:783
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
HANDLE ProcessHeap
Definition: servman.c:15
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
struct _NTOS_OPTIONS * PNTOS_OPTIONS
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
static const WCHAR Signature[]
Definition: parser.c:141
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

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

◆ CloseBootStore()

NTSTATUS CloseBootStore ( IN PVOID  Handle)

Definition at line 754 of file bldrsup.c.

756 {
758 
759  if (!BootStore)
761 
762  /*
763  * NOTE: Currently we open & map the loader configuration file without
764  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
765  * and NTLDR's boot.ini files. But as soon as we'll implement support for
766  * BOOTMGR detection, the "configuration file" will be the BCD registry
767  * hive and then, we'll have instead to mount the hive & open it.
768  */
769 
770  if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
771  {
772  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
773  return STATUS_NOT_SUPPORTED;
774  }
775 
776  return NtosBootLoaders[BootStore->Type].CloseBootStore(Handle /* BootStore */);
777 }
return STATUS_NOT_SUPPORTED
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
PCLOSE_BOOT_STORE CloseBootStore
Definition: bldrsup.c:49
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122

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

◆ DeleteBootStoreEntry()

NTSTATUS DeleteBootStoreEntry ( IN PVOID  Handle,
IN ULONG_PTR  BootEntryKey 
)

Definition at line 952 of file bldrsup.c.

955 {
957 
958  if (!BootStore)
960 
961  /*
962  * NOTE: Currently we open & map the loader configuration file without
963  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
964  * and NTLDR's boot.ini files. But as soon as we'll implement support for
965  * BOOTMGR detection, the "configuration file" will be the BCD registry
966  * hive and then, we'll have instead to mount the hive & open it.
967  */
968 
969  //
970  // FIXME!!
971  //
972 
973  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
974  if (BootStore->Type != FreeLdr)
975  {
976  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
977  return STATUS_NOT_SUPPORTED;
978  }
979 
980  // FIXME! This function needs my INI library rewrite to be implemented!!
982  return STATUS_NOT_IMPLEMENTED;
983 }
return STATUS_NOT_SUPPORTED
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
return STATUS_NOT_IMPLEMENTED
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define UNIMPLEMENTED
Definition: debug.h:115

◆ EnumerateBootStoreEntries()

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

Definition at line 1486 of file bldrsup.c.

1491 {
1493 
1494  if (!BootStore)
1495  return STATUS_INVALID_PARAMETER;
1496 
1497  if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1498  {
1499  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1500  return STATUS_SUCCESS;
1501  // return STATUS_INVALID_PARAMETER;
1502  }
1503 
1504  return NtosBootLoaders[BootStore->Type].EnumBootStoreEntries(
1505  (PBOOT_STORE_INI_CONTEXT)BootStore, // Flags,
1506  EnumBootEntriesRoutine, Parameter);
1507 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PVOID Parameter
Definition: ldrtypes.h:241
PENUM_BOOT_STORE_ENTRIES EnumBootStoreEntries
Definition: bldrsup.c:50
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_SUCCESS
Definition: shellext.h:65

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

◆ FindBootStore()

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

Definition at line 137 of file bldrsup.c.

142 {
143  PCWSTR LoaderExecutable;
144  // UINT i;
145 
146  if (Type >= BldrTypeMax)
148 
149  if (VersionNumber)
150  *VersionNumber = 0;
151 
152  /* Check whether any of the loader executables exist */
153  LoaderExecutable = NtosBootLoaders[Type].LoaderExecutables;
154  while (*LoaderExecutable)
155  {
156  if (DoesFileExist(PartitionDirectoryHandle, LoaderExecutable))
157  {
158  /* A loader was found, stop there */
159  DPRINT("Found loader executable '%S'\n", LoaderExecutable);
160  break;
161  }
162 
163  /* The loader does not exist, continue with another one */
164  DPRINT("Loader executable '%S' does not exist, continue with another one...\n", LoaderExecutable);
165  LoaderExecutable += wcslen(LoaderExecutable) + 1;
166  }
167  if (!*LoaderExecutable)
168  {
169  /* No loader was found */
170  DPRINT("No loader executable was found\n");
171  return STATUS_NOT_FOUND;
172  }
173 
174  /* Check for loader version if needed */
175  if (VersionNumber)
176  {
177  *VersionNumber = 0;
178  // TODO: Check for BLDR version!
179  }
180 
181  /* Check whether the loader configuration file exists */
182  if (!DoesFileExist(PartitionDirectoryHandle, NtosBootLoaders[Type].LoaderConfigurationFile))
183  {
184  /* The loader does not exist, continue with another one */
185  // FIXME: Consider it might be optional??
186  DPRINT1("Loader configuration file '%S' does not exist\n", NtosBootLoaders[Type].LoaderConfigurationFile);
187  return STATUS_NOT_FOUND;
188  }
189 
190 #if 0
191  /* Check whether the loader configuration file exists */
192  Status = OpenAndMapFile(PartitionDirectoryHandle, NtosBootLoaders[Type].LoaderConfigurationFile,
193  &FileHandle, &SectionHandle, &ViewBase, &FileSize, FALSE);
194  if (!NT_SUCCESS(Status))
195  {
196  /* The loader does not exist, continue with another one */
197  // FIXME: Consider it might be optional??
198  DPRINT1("Loader configuration file '%S' does not exist\n", NtosBootLoaders[Type].LoaderConfigurationFile);
199  return STATUS_NOT_FOUND;
200  }
201 #endif
202 
203  return STATUS_SUCCESS;
204 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FALSE
Definition: types.h:117
#define DoesFileExist(RootDirectory, FileName)
Definition: filesup.h:77
PCZZWSTR LoaderExecutables
Definition: bldrsup.c:46
Status
Definition: gdiplustypes.h:24
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Type
Definition: Type.h:6
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1230
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
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)
Definition: filesup.c:858
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

Referenced by FindNTOSInstallations().

◆ ModifyBootStoreEntry()

NTSTATUS ModifyBootStoreEntry ( IN PVOID  Handle,
IN PBOOT_STORE_ENTRY  BootEntry 
)

Definition at line 986 of file bldrsup.c.

989 {
991 
992  if (!BootStore || !BootEntry)
994 
995  /*
996  * NOTE: Currently we open & map the loader configuration file without
997  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
998  * and NTLDR's boot.ini files. But as soon as we'll implement support for
999  * BOOTMGR detection, the "configuration file" will be the BCD registry
1000  * hive and then, we'll have instead to mount the hive & open it.
1001  */
1002 
1003  //
1004  // FIXME!!
1005  //
1006 
1007  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1008  if (BootStore->Type != FreeLdr)
1009  {
1010  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1011  return STATUS_NOT_SUPPORTED;
1012  }
1013 
1014  // FIXME! This function needs my INI library rewrite to operate properly!!
1015  UNIMPLEMENTED;
1016  return STATUS_NOT_IMPLEMENTED;
1017 }
return STATUS_NOT_SUPPORTED
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
return STATUS_NOT_IMPLEMENTED
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define UNIMPLEMENTED
Definition: debug.h:115

◆ OpenBootStore()

NTSTATUS OpenBootStore ( OUT PVOID Handle,
IN PCWSTR  SystemPartition,
IN BOOT_STORE_TYPE  Type,
IN BOOLEAN  CreateNew 
)

Definition at line 742 of file bldrsup.c.

747 {
748  UNICODE_STRING SystemPartitionPath;
749  RtlInitUnicodeString(&SystemPartitionPath, SystemPartition);
750  return OpenBootStore_UStr(Handle, &SystemPartitionPath, Type, CreateNew);
751 }
NTSTATUS OpenBootStore_UStr(OUT PVOID *Handle, IN PUNICODE_STRING SystemPartitionPath, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
Definition: bldrsup.c:691
Type
Definition: Type.h:6
static PPARTENTRY SystemPartition
Definition: usetup.c:61
_In_ HANDLE Handle
Definition: extypes.h:390
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

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 BOOLEAN  CreateNew 
)

Definition at line 691 of file bldrsup.c.

696 {
700  HANDLE PartitionDirectoryHandle;
701 
702  /*
703  * NOTE: Currently we open & map the loader configuration file without
704  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
705  * and NTLDR's boot.ini files. But as soon as we'll implement support for
706  * BOOTMGR detection, the "configuration file" will be the BCD registry
707  * hive and then, we'll have instead to mount the hive & open it.
708  */
709 
711  {
712  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
713  return STATUS_NOT_SUPPORTED;
714  }
715 
716  /* Open SystemPartition */
718  SystemPartitionPath,
720  NULL,
721  NULL);
722  Status = NtOpenFile(&PartitionDirectoryHandle,
723  FILE_LIST_DIRECTORY | FILE_ADD_FILE /* | FILE_ADD_SUBDIRECTORY | FILE_TRAVERSE*/ | SYNCHRONIZE,
725  &IoStatusBlock,
727  FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE /* | FILE_OPEN_FOR_BACKUP_INTENT */);
728  if (!NT_SUCCESS(Status))
729  {
730  DPRINT1("Failed to open SystemPartition '%wZ', Status 0x%08lx\n", SystemPartitionPath, Status);
731  return Status;
732  }
733 
734  Status = OpenBootStoreByHandle(Handle, PartitionDirectoryHandle, Type, CreateNew);
735 
736  /* Done! */
737  NtClose(PartitionDirectoryHandle);
738  return Status;
739 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
return STATUS_NOT_SUPPORTED
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_ADD_FILE
Definition: nt_native.h:632
Status
Definition: gdiplustypes.h:24
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:3951
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Type
Definition: Type.h:6
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define SYNCHRONIZE
Definition: nt_native.h:61
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSTATUS OpenBootStoreByHandle(OUT PVOID *Handle, IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
Definition: bldrsup.c:664

Referenced by OpenBootStore().

◆ OpenBootStoreByHandle()

NTSTATUS OpenBootStoreByHandle ( OUT PVOID Handle,
IN HANDLE  PartitionDirectoryHandle,
IN BOOT_STORE_TYPE  Type,
IN BOOLEAN  CreateNew 
)

Definition at line 664 of file bldrsup.c.

669 {
670  /*
671  * NOTE: Currently we open & map the loader configuration file without
672  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
673  * and NTLDR's boot.ini files. But as soon as we'll implement support for
674  * BOOTMGR detection, the "configuration file" will be the BCD registry
675  * hive and then, we'll have instead to mount the hive & open it.
676  */
677 
679  {
680  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
681  return STATUS_NOT_SUPPORTED;
682  }
683 
685  PartitionDirectoryHandle,
686  Type,
687  CreateNew);
688 }
return STATUS_NOT_SUPPORTED
POPEN_BOOT_STORE OpenBootStore
Definition: bldrsup.c:48
Type
Definition: Type.h:6
#define DPRINT1
Definition: precomp.h:8
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122

Referenced by FindNTOSInstallations(), and OpenBootStore_UStr().

◆ QueryBootStoreEntry()

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

Definition at line 1020 of file bldrsup.c.

1024 {
1026 
1027  if (!BootStore)
1028  return STATUS_INVALID_PARAMETER;
1029 
1030  /*
1031  * NOTE: Currently we open & map the loader configuration file without
1032  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1033  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1034  * BOOTMGR detection, the "configuration file" will be the BCD registry
1035  * hive and then, we'll have instead to mount the hive & open it.
1036  */
1037 
1038  //
1039  // FIXME!!
1040  //
1041 
1042  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1043  if (BootStore->Type != FreeLdr)
1044  {
1045  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1046  return STATUS_NOT_SUPPORTED;
1047  }
1048 
1049  // FIXME! This function needs my INI library rewrite to be implemented!!
1050  UNIMPLEMENTED;
1051  return STATUS_NOT_IMPLEMENTED;
1052 }
return STATUS_NOT_SUPPORTED
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
return STATUS_NOT_IMPLEMENTED
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define UNIMPLEMENTED
Definition: debug.h:115

◆ QueryBootStoreOptions()

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

Definition at line 1055 of file bldrsup.c.

1059 {
1062  PWCHAR TimeoutStr;
1063 
1064  if (!BootStore || !BootOptions)
1065  return STATUS_INVALID_PARAMETER;
1066 
1067  /*
1068  * NOTE: Currently we open & map the loader configuration file without
1069  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1070  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1071  * BOOTMGR detection, the "configuration file" will be the BCD registry
1072  * hive and then, we'll have instead to mount the hive & open it.
1073  */
1074 
1075  //
1076  // FIXME!!
1077  //
1078 
1079  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1080  if (BootStore->Type != FreeLdr && BootStore->Type != NtLdr)
1081  {
1082  DPRINT1("Loader type %d is currently unsupported!\n", BootStore->Type);
1083  return STATUS_NOT_SUPPORTED;
1084  }
1085 
1086  if (BootStore->Type == FreeLdr)
1087  {
1088  BootOptions->Version = FreeLdr;
1089 
1090  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1091  L"DefaultOS", (PWCHAR*)&BootOptions->CurrentBootEntryKey);
1092  if (!NT_SUCCESS(Status))
1093  BootOptions->CurrentBootEntryKey = 0;
1094 
1095  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1096  L"TimeOut", &TimeoutStr);
1097  if (NT_SUCCESS(Status) && TimeoutStr)
1098  BootOptions->Timeout = _wtoi(TimeoutStr);
1099  else
1100  BootOptions->Timeout = 0;
1101  }
1102  else if (BootStore->Type == NtLdr)
1103  {
1104  BootOptions->Version = NtLdr;
1105 
1106  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1107  L"default", (PWCHAR*)&BootOptions->CurrentBootEntryKey);
1108  if (!NT_SUCCESS(Status))
1109  BootOptions->CurrentBootEntryKey = 0;
1110 
1111  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1112  L"timeout", &TimeoutStr);
1113  if (NT_SUCCESS(Status) && TimeoutStr)
1114  BootOptions->Timeout = _wtoi(TimeoutStr);
1115  else
1116  BootOptions->Timeout = 0;
1117  }
1118 
1119  return STATUS_SUCCESS; // FIXME: use Status; instead?
1120 }
return STATUS_NOT_SUPPORTED
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
Definition: bldrsup.h:16
Status
Definition: gdiplustypes.h:24
NTSTATUS IniCacheGetKey(PINICACHESECTION Section, PWCHAR KeyName, PWCHAR *KeyData)
Definition: inicache.c:716
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ SetBootStoreOptions()

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

Definition at line 1123 of file bldrsup.c.

1127 {
1129  WCHAR TimeoutStr[15];
1130 
1131  if (!BootStore || !BootOptions)
1132  return STATUS_INVALID_PARAMETER;
1133 
1134  /*
1135  * NOTE: Currently we open & map the loader configuration file without
1136  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1137  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1138  * BOOTMGR detection, the "configuration file" will be the BCD registry
1139  * hive and then, we'll have instead to mount the hive & open it.
1140  */
1141 
1142  //
1143  // FIXME!!
1144  //
1145 
1146  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1147  if (BootStore->Type != FreeLdr)
1148  {
1149  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1150  return STATUS_NOT_SUPPORTED;
1151  }
1152 
1153  if (BootOptions->Version != FreeLdr)
1154  return STATUS_INVALID_PARAMETER;
1155 
1156  //
1157  // TODO: Depending on the flags set in 'FieldsToChange',
1158  // change either one or both these bootloader options.
1159  //
1160  IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1161  NULL, INSERT_LAST,
1162  L"DefaultOS", (PWCHAR)BootOptions->CurrentBootEntryKey);
1163 
1164  RtlStringCchPrintfW(TimeoutStr, ARRAYSIZE(TimeoutStr), L"%d", BootOptions->Timeout);
1165  IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1166  NULL, INSERT_FIRST, // INSERT_LAST, // FIXME!! There is a bug in the INI parser where a given key can be inserted twice in the same section...
1167  L"TimeOut", TimeoutStr);
1168 
1169  return STATUS_SUCCESS;
1170 }
PINICACHEKEY IniCacheInsertKey(PINICACHESECTION Section, PINICACHEKEY AnchorKey, INSERTION_TYPE InsertionType, PWCHAR Name, PWCHAR Data)
Definition: inicache.c:826
return STATUS_NOT_SUPPORTED
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
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
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
uint16_t * PWCHAR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
_In_ HANDLE Handle
Definition: extypes.h:390
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by CreateFreeLoaderReactOSEntries().