ReactOS  0.4.13-dev-259-g5ca9c9c
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 927 of file bldrsup.c.

931 {
933 
934  if (!BootStore || !BootEntry)
936 
937  /*
938  * NOTE: Currently we open & map the loader configuration file without
939  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
940  * and NTLDR's boot.ini files. But as soon as we'll implement support for
941  * BOOTMGR detection, the "configuration file" will be the BCD registry
942  * hive and then, we'll have instead to mount the hive & open it.
943  */
944 
945  //
946  // FIXME!!
947  //
948 
949  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
950 
951  if (BootStore->Type == FreeLdr)
952  {
953  if (BootEntry->Version != FreeLdr)
955 
956  return CreateNTOSEntry((PBOOT_STORE_INI_CONTEXT)BootStore,
957  BootEntryKey, BootEntry);
958  }
959  else
960  if (BootStore->Type == NtLdr)
961  {
962  PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
963  PWCHAR Buffer;
965  PCWSTR InstallName, OsOptions;
966  // ULONG InstallNameLength, OsOptionsLength;
967  BOOLEAN IsNameNotQuoted;
968 
969  if (BootEntry->Version != NtLdr)
971 
972  if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) ||
973  RtlCompareMemory(&BootEntry->OsOptions /* Signature */,
977  {
978  // DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version);
979  DPRINT1("Unsupported BootType %lu\n", BootEntry->OsOptionsLength);
980  return STATUS_SUCCESS; // STATUS_NOT_SUPPORTED;
981  }
982 
983  InstallName = BootEntry->FriendlyName;
984  OsOptions = Options->OsLoadOptions;
985 
986  // if (InstallNameLength == 0) InstallName = NULL;
987  // if (OsOptionsLength == 0) OsOptions = NULL;
988 
989  IsNameNotQuoted = (InstallName[0] != L'\"' || InstallName[wcslen(InstallName)-1] != L'\"');
990 
991  BufferLength = (IsNameNotQuoted ? 2 /* Quotes for FriendlyName*/ : 0) + wcslen(InstallName);
992  if (OsOptions)
993  BufferLength += 1 /* Space between FriendlyName and options */ + wcslen(OsOptions);
994  BufferLength++; /* NULL-termination */
995 
997  if (!Buffer)
999 
1000  *Buffer = UNICODE_NULL;
1001  if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
1002  RtlStringCchCatW(Buffer, BufferLength, InstallName);
1003  if (IsNameNotQuoted) RtlStringCchCatW(Buffer, BufferLength, L"\"");
1004  if (OsOptions)
1005  {
1007  RtlStringCchCatW(Buffer, BufferLength, OsOptions);
1008  }
1009 
1010  /* Insert the entry into the "Operating Systems" section */
1011  IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OsIniSection, NULL, INSERT_LAST,
1012  (PWSTR)Options->OsLoadPath, Buffer);
1013 
1015  return STATUS_SUCCESS;
1016  }
1017  else
1018  {
1019  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1020  return STATUS_NOT_SUPPORTED;
1021  }
1022 }
#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:55
PINICACHEKEY IniCacheInsertKey(PINICACHESECTION Section, PINICACHEKEY AnchorKey, INSERTION_TYPE InsertionType, PWCHAR Name, PWCHAR Data)
Definition: inicache.c:826
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:54
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
uint16_t * PWCHAR
Definition: typedefs.h:54
enum OPTION_FLAGS Options
Definition: stats.c:44
#define UNICODE_NULL
_In_ ULONG BufferLength
Definition: usbdlib.h:225
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
Definition: bldrsup.h:16
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
_In_ HANDLE Handle
Definition: extypes.h:390
if(!(yy_init))
Definition: macro.lex.yy.c:714
__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:589
static NTSTATUS CreateNTOSEntry(IN PBOOT_STORE_INI_CONTEXT BootStore, IN ULONG_PTR BootEntryKey, IN PBOOT_STORE_ENTRY BootEntry)
Definition: bldrsup.c:856
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
static const WCHAR L[]
Definition: oid.c:1250
HANDLE ProcessHeap
Definition: servman.c:15
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
struct _NTOS_OPTIONS * PNTOS_OPTIONS
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2745
static const WCHAR Signature[]
Definition: parser.c:141
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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 827 of file bldrsup.c.

829 {
831 
832  if (!BootStore)
834 
835  /*
836  * NOTE: Currently we open & map the loader configuration file without
837  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
838  * and NTLDR's boot.ini files. But as soon as we'll implement support for
839  * BOOTMGR detection, the "configuration file" will be the BCD registry
840  * hive and then, we'll have instead to mount the hive & open it.
841  */
842 
843  if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
844  {
845  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
846  return STATUS_NOT_SUPPORTED;
847  }
848 
849  return NtosBootLoaders[BootStore->Type].CloseBootStore(Handle /* BootStore */);
850 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ HANDLE Handle
Definition: extypes.h:390
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
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

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

◆ DeleteBootStoreEntry()

NTSTATUS DeleteBootStoreEntry ( IN PVOID  Handle,
IN ULONG_PTR  BootEntryKey 
)

Definition at line 1025 of file bldrsup.c.

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

◆ EnumerateBootStoreEntries()

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

Definition at line 1559 of file bldrsup.c.

1564 {
1566 
1567  if (!BootStore)
1568  return STATUS_INVALID_PARAMETER;
1569 
1570  if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1571  {
1572  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1573  return STATUS_SUCCESS;
1574  // return STATUS_INVALID_PARAMETER;
1575  }
1576 
1577  return NtosBootLoaders[BootStore->Type].EnumBootStoreEntries(
1578  (PBOOT_STORE_INI_CONTEXT)BootStore, // Flags,
1579  EnumBootEntriesRoutine, Parameter);
1580 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PVOID Parameter
Definition: ldrtypes.h:240
PENUM_BOOT_STORE_ENTRIES EnumBootStoreEntries
Definition: bldrsup.c:50
_In_ HANDLE Handle
Definition: extypes.h:390
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
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
return STATUS_SUCCESS
Definition: btrfs.c:2745

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:55
Type
Definition: Type.h:6
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
HANDLE FileHandle
Definition: stats.c:38
void DPRINT(...)
Definition: polytest.cpp:61
#define DoesFileExist(RootDirectory, FileName)
Definition: filesup.h:77
PCZZWSTR LoaderExecutables
Definition: bldrsup.c:46
#define STATUS_NOT_FOUND
Definition: shellext.h:67
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:24
#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
return STATUS_SUCCESS
Definition: btrfs.c:2745
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by FindNTOSInstallations().

◆ ModifyBootStoreEntry()

NTSTATUS ModifyBootStoreEntry ( IN PVOID  Handle,
IN PBOOT_STORE_ENTRY  BootEntry 
)

Definition at line 1059 of file bldrsup.c.

1062 {
1064 
1065  if (!BootStore || !BootEntry)
1066  return STATUS_INVALID_PARAMETER;
1067 
1068  /*
1069  * NOTE: Currently we open & map the loader configuration file without
1070  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1071  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1072  * BOOTMGR detection, the "configuration file" will be the BCD registry
1073  * hive and then, we'll have instead to mount the hive & open it.
1074  */
1075 
1076  //
1077  // FIXME!!
1078  //
1079 
1080  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1081  if (BootStore->Type != FreeLdr)
1082  {
1083  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1084  return STATUS_NOT_SUPPORTED;
1085  }
1086 
1087  // FIXME! This function needs my INI library rewrite to operate properly!!
1088  UNIMPLEMENTED;
1089  return STATUS_NOT_IMPLEMENTED;
1090 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ HANDLE Handle
Definition: extypes.h:390
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
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ OpenBootStore()

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

Definition at line 815 of file bldrsup.c.

820 {
821  UNICODE_STRING SystemPartitionPath;
822  RtlInitUnicodeString(&SystemPartitionPath, SystemPartition);
823  return OpenBootStore_UStr(Handle, &SystemPartitionPath, Type, CreateNew);
824 }
Type
Definition: Type.h:6
NTSTATUS OpenBootStore_UStr(OUT PVOID *Handle, IN PUNICODE_STRING SystemPartitionPath, IN BOOT_STORE_TYPE Type, IN BOOLEAN CreateNew)
Definition: bldrsup.c:764
_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 764 of file bldrsup.c.

769 {
773  HANDLE PartitionDirectoryHandle;
774 
775  /*
776  * NOTE: Currently we open & map the loader configuration file without
777  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
778  * and NTLDR's boot.ini files. But as soon as we'll implement support for
779  * BOOTMGR detection, the "configuration file" will be the BCD registry
780  * hive and then, we'll have instead to mount the hive & open it.
781  */
782 
784  {
785  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
786  return STATUS_NOT_SUPPORTED;
787  }
788 
789  /* Open SystemPartition */
791  SystemPartitionPath,
793  NULL,
794  NULL);
795  Status = NtOpenFile(&PartitionDirectoryHandle,
796  FILE_LIST_DIRECTORY | FILE_ADD_FILE /* | FILE_ADD_SUBDIRECTORY | FILE_TRAVERSE*/ | SYNCHRONIZE,
798  &IoStatusBlock,
800  FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE /* | FILE_OPEN_FOR_BACKUP_INTENT */);
801  if (!NT_SUCCESS(Status))
802  {
803  DPRINT1("Failed to open SystemPartition '%wZ', Status 0x%08lx\n", SystemPartitionPath, Status);
804  return Status;
805  }
806 
807  Status = OpenBootStoreByHandle(Handle, PartitionDirectoryHandle, Type, CreateNew);
808 
809  /* Done! */
810  NtClose(PartitionDirectoryHandle);
811  return Status;
812 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
Type
Definition: Type.h:6
#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:125
#define FILE_ADD_FILE
Definition: nt_native.h:632
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
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
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#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:737

Referenced by OpenBootStore().

◆ OpenBootStoreByHandle()

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

Definition at line 737 of file bldrsup.c.

742 {
743  /*
744  * NOTE: Currently we open & map the loader configuration file without
745  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
746  * and NTLDR's boot.ini files. But as soon as we'll implement support for
747  * BOOTMGR detection, the "configuration file" will be the BCD registry
748  * hive and then, we'll have instead to mount the hive & open it.
749  */
750 
752  {
753  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[Type].Type);
754  return STATUS_NOT_SUPPORTED;
755  }
756 
758  PartitionDirectoryHandle,
759  Type,
760  CreateNew);
761 }
Type
Definition: Type.h:6
POPEN_BOOT_STORE OpenBootStore
Definition: bldrsup.c:48
_In_ HANDLE Handle
Definition: extypes.h:390
#define DPRINT1
Definition: precomp.h:8
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

Referenced by FindNTOSInstallations(), and OpenBootStore_UStr().

◆ QueryBootStoreEntry()

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

Definition at line 1093 of file bldrsup.c.

1097 {
1099 
1100  if (!BootStore)
1101  return STATUS_INVALID_PARAMETER;
1102 
1103  /*
1104  * NOTE: Currently we open & map the loader configuration file without
1105  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1106  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1107  * BOOTMGR detection, the "configuration file" will be the BCD registry
1108  * hive and then, we'll have instead to mount the hive & open it.
1109  */
1110 
1111  //
1112  // FIXME!!
1113  //
1114 
1115  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1116  if (BootStore->Type != FreeLdr)
1117  {
1118  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1119  return STATUS_NOT_SUPPORTED;
1120  }
1121 
1122  // FIXME! This function needs my INI library rewrite to be implemented!!
1123  UNIMPLEMENTED;
1124  return STATUS_NOT_IMPLEMENTED;
1125 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ HANDLE Handle
Definition: extypes.h:390
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
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ QueryBootStoreOptions()

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

Definition at line 1128 of file bldrsup.c.

1132 {
1135  PWCHAR TimeoutStr;
1136 
1137  if (!BootStore || !BootOptions)
1138  return STATUS_INVALID_PARAMETER;
1139 
1140  /*
1141  * NOTE: Currently we open & map the loader configuration file without
1142  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1143  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1144  * BOOTMGR detection, the "configuration file" will be the BCD registry
1145  * hive and then, we'll have instead to mount the hive & open it.
1146  */
1147 
1148  //
1149  // FIXME!!
1150  //
1151 
1152  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1153  if (BootStore->Type != FreeLdr || BootStore->Type != NtLdr)
1154  {
1155  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1156  return STATUS_NOT_SUPPORTED;
1157  }
1158 
1159  if (BootStore->Type == FreeLdr)
1160  {
1161  BootOptions->Version = FreeLdr;
1162 
1163  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1164  L"DefaultOS", (PWCHAR*)&BootOptions->CurrentBootEntryKey);
1165  if (!NT_SUCCESS(Status))
1166  BootOptions->CurrentBootEntryKey = 0;
1167 
1168  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1169  L"TimeOut", &TimeoutStr);
1170  if (NT_SUCCESS(Status) && TimeoutStr)
1171  BootOptions->Timeout = _wtoi(TimeoutStr);
1172  else
1173  BootOptions->Timeout = 0;
1174  }
1175  else if (BootStore->Type == NtLdr)
1176  {
1177  BootOptions->Version = NtLdr;
1178 
1179  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1180  L"default", (PWCHAR*)&BootOptions->CurrentBootEntryKey);
1181  if (!NT_SUCCESS(Status))
1182  BootOptions->CurrentBootEntryKey = 0;
1183 
1184  Status = IniCacheGetKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1185  L"timeout", &TimeoutStr);
1186  if (NT_SUCCESS(Status) && TimeoutStr)
1187  BootOptions->Timeout = _wtoi(TimeoutStr);
1188  else
1189  BootOptions->Timeout = 0;
1190  }
1191 
1192  return STATUS_SUCCESS; // FIXME: use Status; instead?
1193 }
#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:54
Definition: bldrsup.h:16
_In_ HANDLE Handle
Definition: extypes.h:390
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
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ SetBootStoreOptions()

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

Definition at line 1196 of file bldrsup.c.

1200 {
1202  WCHAR TimeoutStr[15];
1203 
1204  if (!BootStore || !BootOptions)
1205  return STATUS_INVALID_PARAMETER;
1206 
1207  /*
1208  * NOTE: Currently we open & map the loader configuration file without
1209  * further tests. It's OK as long as we only deal with FreeLdr's freeldr.ini
1210  * and NTLDR's boot.ini files. But as soon as we'll implement support for
1211  * BOOTMGR detection, the "configuration file" will be the BCD registry
1212  * hive and then, we'll have instead to mount the hive & open it.
1213  */
1214 
1215  //
1216  // FIXME!!
1217  //
1218 
1219  // if (BootStore->Type >= BldrTypeMax || NtosBootLoaders[BootStore->Type].Type >= BldrTypeMax)
1220  if (BootStore->Type != FreeLdr)
1221  {
1222  DPRINT1("Loader type %d is currently unsupported!\n", NtosBootLoaders[BootStore->Type].Type);
1223  return STATUS_NOT_SUPPORTED;
1224  }
1225 
1226  if (BootOptions->Version != FreeLdr)
1227  return STATUS_INVALID_PARAMETER;
1228 
1229  //
1230  // TODO: Depending on the flags set in 'FieldsToChange',
1231  // change either one or both these bootloader options.
1232  //
1233  IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1234  NULL, INSERT_LAST,
1235  L"DefaultOS", (PWCHAR)BootOptions->CurrentBootEntryKey);
1236 
1237  RtlStringCchPrintfW(TimeoutStr, ARRAYSIZE(TimeoutStr), L"%d", BootOptions->Timeout);
1238  IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OptionsIniSection,
1239  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...
1240  L"TimeOut", TimeoutStr);
1241 
1242  return STATUS_SUCCESS;
1243 }
PINICACHEKEY IniCacheInsertKey(PINICACHESECTION Section, PINICACHEKEY AnchorKey, INSERTION_TYPE InsertionType, PWCHAR Name, PWCHAR Data)
Definition: inicache.c:826
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
uint16_t * PWCHAR
Definition: typedefs.h:54
smooth NULL
Definition: ftsmooth.c:416
static __inline NTSTATUS RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1064
_In_ HANDLE Handle
Definition: extypes.h:390
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _BOOT_STORE_CONTEXT * PBOOT_STORE_CONTEXT
BOOT_STORE_TYPE Type
Definition: bldrsup.c:45
static const WCHAR L[]
Definition: oid.c:1250
#define DPRINT1
Definition: precomp.h:8
BOOT_STORE_TYPE Type
Definition: bldrsup.c:59
NTOS_BOOT_LOADER_FILES NtosBootLoaders[]
Definition: bldrsup.c:122
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by CreateFreeLoaderReactOSEntries().