1 /* 2 * COPYRIGHT: See COPYING.ARM in the top level directory 3 * PROJECT: ReactOS Boot Configuration Data 4 * FILE: boot/environ/include/bcd.h 5 * PURPOSE: BCD Main Header 6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org) 7 */ 8 9 #ifndef _BCD_H 10 #define _BCD_H 11 12 /* ENUMERATIONS **************************************************************/ 13 14 /* See https://msdn.microsoft.com/en-us/library/windows/desktop/aa964229(v=vs.85).aspx */ 15 16 #define BCD_CLASS_LIBRARY 0x01 17 #define BCD_CLASS_APPLICATION 0x02 18 #define BCD_CLASS_DEVICE 0x03 19 #define BCD_CLASS_OEM 0x05 20 21 #define BCD_TYPE_DEVICE 0x01 22 #define BCD_TYPE_STRING 0x02 23 #define BCD_TYPE_OBJECT 0x03 24 #define BCD_TYPE_OBJECT_LIST 0x04 25 #define BCD_TYPE_INTEGER 0x05 26 #define BCD_TYPE_BOOLEAN 0x06 27 #define BCD_TYPE_INTEGER_LIST 0x07 28 29 #define BCD_IMAGE_TYPE_FIRMWARE 0x01 30 #define BCD_IMAGE_TYPE_BOOT_APP 0x02 31 #define BCD_IMAGE_TYPE_NTLDR 0x03 32 #define BCD_IMAGE_TYPE_REAL_MODE 0x04 33 34 #define BCD_APPLICATION_TYPE_FWBOOTMGR 0x01 35 #define BCD_APPLICATION_TYPE_BOOTMGR 0x02 36 #define BCD_APPLICATION_TYPE_OSLOADER 0x03 37 #define BCD_APPLICATION_TYPE_RESUME 0x04 38 #define BCD_APPLICATION_TYPE_MEMDIAG 0x05 39 #define BCD_APPLICATION_TYPE_NTLDR 0x06 40 #define BCD_APPLICATION_TYPE_SETUPLDR 0x07 41 #define BCD_APPLICATION_TYPE_BOOTSECTOR 0x08 42 #define BCD_APPLICATION_TYPE_STARTUPCOM 0x09 43 44 #define BCD_OBJECT_TYPE_APPLICATION 0x01 45 #define BCD_OBJECT_TYPE_INHERIT 0x02 46 #define BCD_OBJECT_TYPE_DEVICE 0x03 47 48 typedef enum BcdLibraryElementTypes 49 { 50 BcdLibraryDevice_ApplicationDevice = 0x11000001, 51 BcdLibraryString_ApplicationPath = 0x12000002, 52 BcdLibraryString_Description = 0x12000004, 53 BcdLibraryString_PreferredLocale = 0x12000005, 54 BcdLibraryObjectList_InheritedObjects = 0x14000006, 55 BcdLibraryInteger_TruncatePhysicalMemory = 0x15000007, 56 BcdLibraryObjectList_RecoverySequence = 0x14000008, 57 BcdLibraryBoolean_AutoRecoveryEnabled = 0x16000009, 58 BcdLibraryIntegerList_BadMemoryList = 0x1700000a, 59 BcdLibraryBoolean_AllowBadMemoryAccess = 0x1600000b, 60 BcdLibraryInteger_FirstMegabytePolicy = 0x1500000c, 61 BcdLibraryInteger_RelocatePhysicalMemory = 0x1500000D, 62 BcdLibraryInteger_AvoidLowPhysicalMemory = 0x1500000E, 63 BcdLibraryBoolean_DebuggerEnabled = 0x16000010, 64 BcdLibraryInteger_DebuggerType = 0x15000011, 65 BcdLibraryInteger_SerialDebuggerPortAddress = 0x15000012, 66 BcdLibraryInteger_SerialDebuggerPort = 0x15000013, 67 BcdLibraryInteger_SerialDebuggerBaudRate = 0x15000014, 68 BcdLibraryInteger_1394DebuggerChannel = 0x15000015, 69 BcdLibraryString_UsbDebuggerTargetName = 0x12000016, 70 BcdLibraryBoolean_DebuggerIgnoreUsermodeExceptions = 0x16000017, 71 BcdLibraryInteger_DebuggerStartPolicy = 0x15000018, 72 BcdLibraryString_DebuggerBusParameters = 0x12000019, 73 BcdLibraryInteger_DebuggerNetHostIP = 0x1500001A, 74 BcdLibraryInteger_DebuggerNetPort = 0x1500001B, 75 BcdLibraryBoolean_DebuggerNetDhcp = 0x1600001C, 76 BcdLibraryString_DebuggerNetKey = 0x1200001D, 77 BcdLibraryBoolean_EmsEnabled = 0x16000020, 78 BcdLibraryInteger_EmsPort = 0x15000022, 79 BcdLibraryInteger_EmsBaudRate = 0x15000023, 80 BcdLibraryString_LoadOptionsString = 0x12000030, 81 BcdLibraryBoolean_DisplayAdvancedOptions = 0x16000040, 82 BcdLibraryBoolean_DisplayOptionsEdit = 0x16000041, 83 BcdLibraryDevice_BsdLogDevice = 0x11000043, 84 BcdLibraryString_BsdLogPath = 0x12000044, 85 BcdLibraryBoolean_PreserveBsdLog = 0x16000045, /* Undocumented */ 86 BcdLibraryBoolean_GraphicsModeDisabled = 0x16000046, 87 BcdLibraryInteger_ConfigAccessPolicy = 0x15000047, 88 BcdLibraryBoolean_DisableIntegrityChecks = 0x16000048, 89 BcdLibraryBoolean_AllowPrereleaseSignatures = 0x16000049, 90 BcdLibraryString_FontPath = 0x1200004A, 91 BcdLibraryInteger_SiPolicy = 0x1500004B, 92 BcdLibraryInteger_FveBandId = 0x1500004C, 93 BcdLibraryBoolean_ConsoleExtendedInput = 0x16000050, 94 BcdLibraryInteger_GraphicsResolution = 0x15000052, 95 BcdLibraryInteger_DisplayMessage = 0x15000065, /* Undocumented */ 96 BcdLibraryInteger_DisplayMessageOverride = 0x15000066, /* Undocumented */ 97 BcdLibraryInteger_UndocumentedMagic = 0x15000075, /* Undocumented magic */ 98 BcdLibraryBoolean_RestartOnFailure = 0x16000053, 99 BcdLibraryBoolean_GraphicsForceHighestMode = 0x16000054, 100 BcdLibraryBoolean_IsolatedExecutionContext = 0x16000060, 101 BcdLibraryBoolean_BootUxDisable = 0x1600006C, 102 BcdLibraryBoolean_BootShutdownDisabled = 0x16000074, 103 BcdLibraryIntegerList_AllowedInMemorySettings = 0x17000077, 104 BcdLibraryBoolean_ForceFipsCrypto = 0x16000079, 105 BcdLibraryBoolean_MobileGraphics = 0x1600007A /* Undocumented */ 106 } BcdLibraryElementTypes; 107 108 typedef enum BcdOSLoaderElementTypes 109 { 110 BcdOSLoaderDevice_OSDevice = 0x21000001, 111 BcdOSLoaderString_SystemRoot = 0x22000002, 112 BcdOSLoaderObject_AssociatedResumeObject = 0x23000003, 113 BcdOSLoaderBoolean_DetectKernelAndHal = 0x26000010, 114 BcdOSLoaderString_KernelPath = 0x22000011, 115 BcdOSLoaderString_HalPath = 0x22000012, 116 BcdOSLoaderString_DbgTransportPath = 0x22000013, 117 BcdOSLoaderInteger_NxPolicy = 0x25000020, 118 BcdOSLoaderInteger_PAEPolicy = 0x25000021, 119 BcdOSLoaderBoolean_WinPEMode = 0x26000022, 120 BcdOSLoaderBoolean_DisableCrashAutoReboot = 0x26000024, 121 BcdOSLoaderBoolean_UseLastGoodSettings = 0x26000025, 122 BcdOSLoaderBoolean_AllowPrereleaseSignatures = 0x26000027, 123 BcdOSLoaderBoolean_NoLowMemory = 0x26000030, 124 BcdOSLoaderInteger_RemoveMemory = 0x25000031, 125 BcdOSLoaderInteger_IncreaseUserVa = 0x25000032, 126 BcdOSLoaderBoolean_UseVgaDriver = 0x26000040, 127 BcdOSLoaderBoolean_DisableBootDisplay = 0x26000041, 128 BcdOSLoaderBoolean_DisableVesaBios = 0x26000042, 129 BcdOSLoaderBoolean_DisableVgaMode = 0x26000043, 130 BcdOSLoaderInteger_ClusterModeAddressing = 0x25000050, 131 BcdOSLoaderBoolean_UsePhysicalDestination = 0x26000051, 132 BcdOSLoaderInteger_RestrictApicCluster = 0x25000052, 133 BcdOSLoaderBoolean_UseLegacyApicMode = 0x26000054, 134 BcdOSLoaderInteger_X2ApicPolicy = 0x25000055, 135 BcdOSLoaderBoolean_UseBootProcessorOnly = 0x26000060, 136 BcdOSLoaderInteger_NumberOfProcessors = 0x25000061, 137 BcdOSLoaderBoolean_ForceMaximumProcessors = 0x26000062, 138 BcdOSLoaderBoolean_ProcessorConfigurationFlags = 0x25000063, 139 BcdOSLoaderBoolean_MaximizeGroupsCreated = 0x26000064, 140 BcdOSLoaderBoolean_ForceGroupAwareness = 0x26000065, 141 BcdOSLoaderInteger_GroupSize = 0x25000066, 142 BcdOSLoaderInteger_UseFirmwarePciSettings = 0x26000070, 143 BcdOSLoaderInteger_MsiPolicy = 0x25000071, 144 BcdOSLoaderInteger_SafeBoot = 0x25000080, 145 BcdOSLoaderBoolean_SafeBootAlternateShell = 0x26000081, 146 BcdOSLoaderBoolean_BootLogInitialization = 0x26000090, 147 BcdOSLoaderBoolean_VerboseObjectLoadMode = 0x26000091, 148 BcdOSLoaderBoolean_KernelDebuggerEnabled = 0x260000a0, 149 BcdOSLoaderBoolean_DebuggerHalBreakpoint = 0x260000a1, 150 BcdOSLoaderBoolean_UsePlatformClock = 0x260000A2, 151 BcdOSLoaderBoolean_ForceLegacyPlatform = 0x260000A3, 152 BcdOSLoaderInteger_TscSyncPolicy = 0x250000A6, 153 BcdOSLoaderBoolean_EmsEnabled = 0x260000b0, 154 BcdOSLoaderInteger_DriverLoadFailurePolicy = 0x250000c1, 155 BcdOSLoaderInteger_BootMenuPolicy = 0x250000C2, 156 BcdOSLoaderBoolean_AdvancedOptionsOneTime = 0x260000C3, 157 BcdOSLoaderBoolean_OptionsEditOneTime = 0x260000C4, /* Undocumented */ 158 BcdOSLoaderInteger_BootStatusPolicy = 0x250000E0, 159 BcdOSLoaderBoolean_DisableElamDrivers = 0x260000E1, 160 BcdOSLoaderInteger_HypervisorLaunchType = 0x250000F0, 161 BcdOSLoaderBoolean_HypervisorDebuggerEnabled = 0x260000F2, 162 BcdOSLoaderInteger_HypervisorDebuggerType = 0x250000F3, 163 BcdOSLoaderInteger_HypervisorDebuggerPortNumber = 0x250000F4, 164 BcdOSLoaderInteger_HypervisorDebuggerBaudrate = 0x250000F5, 165 BcdOSLoaderInteger_HypervisorDebugger1394Channel = 0x250000F6, 166 BcdOSLoaderInteger_BootUxPolicy = 0x250000F7, 167 BcdOSLoaderString_HypervisorDebuggerBusParams = 0x220000F9, 168 BcdOSLoaderInteger_HypervisorNumProc = 0x250000FA, 169 BcdOSLoaderInteger_HypervisorRootProcPerNode = 0x250000FB, 170 BcdOSLoaderBoolean_HypervisorUseLargeVTlb = 0x260000FC, 171 BcdOSLoaderInteger_HypervisorDebuggerNetHostIp = 0x250000FD, 172 BcdOSLoaderInteger_HypervisorDebuggerNetHostPort = 0x250000FE, 173 BcdOSLoaderInteger_TpmBootEntropyPolicy = 0x25000100, 174 BcdOSLoaderString_HypervisorDebuggerNetKey = 0x22000110, 175 BcdOSLoaderBoolean_HypervisorDebuggerNetDhcp = 0x26000114, 176 BcdOSLoaderInteger_HypervisorIommuPolicy = 0x25000115, 177 BcdOSLoaderInteger_XSaveDisable = 0x2500012b 178 } BcdOSLoaderElementTypes; 179 180 typedef enum BcdBootMgrElementTypes 181 { 182 BcdBootMgrObjectList_DisplayOrder = 0x24000001, 183 BcdBootMgrObjectList_BootSequence = 0x24000002, 184 BcdBootMgrObject_DefaultObject = 0x23000003, 185 BcdBootMgrInteger_Timeout = 0x25000004, 186 BcdBootMgrBoolean_AttemptResume = 0x26000005, 187 BcdBootMgrObject_ResumeObject = 0x23000006, 188 BcdBootMgrObjectList_ToolsDisplayOrder = 0x24000010, 189 BcdBootMgrBoolean_DisplayBootMenu = 0x26000020, 190 BcdBootMgrBoolean_NoErrorDisplay = 0x26000021, 191 BcdBootMgrDevice_BcdDevice = 0x21000022, 192 BcdBootMgrString_BcdFilePath = 0x22000023, 193 BcdBootMgrBoolean_ProcessCustomActionsFirst = 0x26000028, 194 BcdBootMgrIntegerList_CustomActionsList = 0x27000030, 195 BcdBootMgrBoolean_PersistBootSequence = 0x26000031 196 } BcdBootMgrElementTypes; 197 198 typedef enum _BcdResumeElementTypes { 199 Reserved1 = 0x21000001, 200 Reserved2 = 0x22000002, 201 BcdResumeBoolean_UseCustomSettings = 0x26000003, 202 BcdResumeDevice_AssociatedOsDevice = 0x21000005, 203 BcdResumeBoolean_DebugOptionEnabled = 0x26000006, 204 BcdResumeInteger_BootMenuPolicy = 0x25000008 205 } BcdResumeElementTypes; 206 207 /* Undocumented */ 208 typedef enum BcdStartupElementTypes 209 { 210 BcdStartupBoolean_PxeSoftReboot = 0x26000001, 211 BcdStartupString_PxeApplicationName = 0x22000002, 212 } BcdStartupElementTypes; 213 214 /* DATA STRUCTURES ***********************************************************/ 215 216 typedef struct 217 { 218 union 219 { 220 ULONG PackedValue; 221 struct 222 { 223 ULONG SubType : 24; 224 ULONG Format : 4; 225 ULONG Class : 4; 226 }; 227 }; 228 } BcdElementType; 229 230 typedef struct 231 { 232 union 233 { 234 ULONG PackedValue; 235 union 236 { 237 struct 238 { 239 ULONG ApplicationCode : 20; 240 ULONG ImageCode : 4; 241 ULONG Reserved : 4; 242 ULONG ObjectCode : 4; 243 } Application; 244 struct 245 { 246 ULONG Value : 20; 247 ULONG ClassCode : 4; 248 ULONG Reserved : 4; 249 ULONG ObjectCode : 4; 250 } Inherit; 251 struct 252 { 253 ULONG Reserved:28; 254 ULONG ObjectCode : 4; 255 } Device; 256 }; 257 }; 258 } BcdObjectType; 259 260 typedef struct _BCD_ELEMENT_HEADER 261 { 262 ULONG Version; 263 ULONG Type; 264 ULONG Size; 265 } BCD_ELEMENT_HEADER, *PBCD_ELEMENT_HEADER; 266 267 typedef struct _BCD_PACKED_ELEMENT 268 { 269 struct _BCD_PACKED_ELEMENT* NextEntry; 270 BcdElementType RootType; 271 BCD_ELEMENT_HEADER; 272 UCHAR Data[ANYSIZE_ARRAY]; 273 } BCD_PACKED_ELEMENT, *PBCD_PACKED_ELEMENT; 274 275 typedef struct _BCD_ELEMENT 276 { 277 PBCD_ELEMENT_HEADER Header; 278 PUCHAR Body; 279 } BCD_ELEMENT, *PBCD_ELEMENT; 280 281 typedef struct _BCD_DEVICE_OPTION 282 { 283 GUID AssociatedEntry; 284 BL_DEVICE_DESCRIPTOR DeviceDescriptor; 285 } BCD_DEVICE_OPTION, *PBCD_DEVICE_OPTION; 286 287 typedef struct _BCD_OBJECT_DESCRIPTION 288 { 289 ULONG Valid; 290 ULONG Type; 291 } BCD_OBJECT_DESCRIPTION, *PBCD_OBJECT_DESCRIPTION; 292 293 /* FUNCTIONS ******************************************************************/ 294 295 NTSTATUS 296 BcdOpenStoreFromFile ( 297 _In_ PUNICODE_STRING FileName, 298 _In_ PHANDLE StoreHandle 299 ); 300 301 #define BCD_ENUMERATE_FLAG_DEEP 0x04 302 #define BCD_ENUMERATE_FLAG_DEVICES 0x08 303 #define BCD_ENUMERATE_FLAG_IN_ORDER 0x10 304 305 NTSTATUS 306 BiEnumerateElements ( 307 _In_ HANDLE BcdHandle, 308 _In_ HANDLE ObjectHandle, 309 _In_ ULONG RootElementType, 310 _In_ ULONG Flags, 311 _Out_opt_ PBCD_PACKED_ELEMENT Elements, 312 _Inout_ PULONG ElementSize, 313 _Out_ PULONG ElementCountNe 314 ); 315 316 NTSTATUS 317 BcdOpenObject ( 318 _In_ HANDLE BcdHandle, 319 _In_ PGUID ObjectId, 320 _Out_ PHANDLE ObjectHandle 321 ); 322 323 NTSTATUS 324 BcdDeleteElement ( 325 _In_ HANDLE ObjectHandle, 326 _In_ ULONG Type 327 ); 328 329 NTSTATUS 330 BcdEnumerateAndUnpackElements ( 331 _In_ HANDLE BcdHandle, 332 _In_ HANDLE ObjectHandle, 333 _Out_opt_ PBCD_ELEMENT Elements, 334 _Inout_ PULONG ElementSize, 335 _Out_ PULONG ElementCount 336 ); 337 338 NTSTATUS 339 BiGetObjectDescription ( 340 _In_ HANDLE ObjectHandle, 341 _Out_ PBCD_OBJECT_DESCRIPTION Description 342 ); 343 344 #endif 345