xref: /reactos/boot/environ/include/bcd.h (revision 9ec85c29)
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_ForceFailure = 0x250000C0,
155     BcdOSLoaderInteger_DriverLoadFailurePolicy = 0x250000C1,
156     BcdOSLoaderInteger_BootMenuPolicy = 0x250000C2,
157     BcdOSLoaderBoolean_AdvancedOptionsOneTime = 0x260000C3,
158     BcdOSLoaderBoolean_OptionsEditOneTime = 0x260000C4, /* Undocumented */
159     BcdOSLoaderInteger_BootStatusPolicy = 0x250000E0,
160     BcdOSLoaderBoolean_DisableElamDrivers = 0x260000E1,
161     BcdOSLoaderInteger_HypervisorLaunchType = 0x250000F0,
162     BcdOSLoaderBoolean_HypervisorDebuggerEnabled = 0x260000F2,
163     BcdOSLoaderInteger_HypervisorDebuggerType = 0x250000F3,
164     BcdOSLoaderInteger_HypervisorDebuggerPortNumber = 0x250000F4,
165     BcdOSLoaderInteger_HypervisorDebuggerBaudrate = 0x250000F5,
166     BcdOSLoaderInteger_HypervisorDebugger1394Channel = 0x250000F6,
167     BcdOSLoaderInteger_BootUxPolicy = 0x250000F7,
168     BcdOSLoaderString_HypervisorDebuggerBusParams = 0x220000F9,
169     BcdOSLoaderInteger_HypervisorNumProc = 0x250000FA,
170     BcdOSLoaderInteger_HypervisorRootProcPerNode = 0x250000FB,
171     BcdOSLoaderBoolean_HypervisorUseLargeVTlb = 0x260000FC,
172     BcdOSLoaderInteger_HypervisorDebuggerNetHostIp = 0x250000FD,
173     BcdOSLoaderInteger_HypervisorDebuggerNetHostPort = 0x250000FE,
174     BcdOSLoaderInteger_TpmBootEntropyPolicy = 0x25000100,
175     BcdOSLoaderString_HypervisorDebuggerNetKey = 0x22000110,
176     BcdOSLoaderBoolean_HypervisorDebuggerNetDhcp = 0x26000114,
177     BcdOSLoaderInteger_HypervisorIommuPolicy = 0x25000115,
178     BcdOSLoaderInteger_XSaveDisable = 0x2500012b
179 } BcdOSLoaderElementTypes;
180 
181 typedef enum BcdBootMgrElementTypes
182 {
183     BcdBootMgrObjectList_DisplayOrder = 0x24000001,
184     BcdBootMgrObjectList_BootSequence = 0x24000002,
185     BcdBootMgrObject_DefaultObject = 0x23000003,
186     BcdBootMgrInteger_Timeout = 0x25000004,
187     BcdBootMgrBoolean_AttemptResume = 0x26000005,
188     BcdBootMgrObject_ResumeObject = 0x23000006,
189     BcdBootMgrObjectList_ToolsDisplayOrder = 0x24000010,
190     BcdBootMgrBoolean_DisplayBootMenu = 0x26000020,
191     BcdBootMgrBoolean_NoErrorDisplay = 0x26000021,
192     BcdBootMgrDevice_BcdDevice = 0x21000022,
193     BcdBootMgrString_BcdFilePath = 0x22000023,
194     BcdBootMgrBoolean_ProcessCustomActionsFirst = 0x26000028,
195     BcdBootMgrIntegerList_CustomActionsList = 0x27000030,
196     BcdBootMgrBoolean_PersistBootSequence = 0x26000031
197 } BcdBootMgrElementTypes;
198 
199 typedef enum _BcdResumeElementTypes
200 {
201     Reserved1 = 0x21000001,
202     Reserved2 = 0x22000002,
203     BcdResumeBoolean_UseCustomSettings = 0x26000003,
204     BcdResumeDevice_AssociatedOsDevice = 0x21000005,
205     BcdResumeBoolean_DebugOptionEnabled = 0x26000006,
206     BcdResumeInteger_BootMenuPolicy = 0x25000008
207 } BcdResumeElementTypes;
208 
209 typedef enum _BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY
210 {
211     DisplayAllFailures,
212     IgnoreAllFailures,
213     IgnoreShutdownFailures,
214     IgnoreBootFailures,
215     IgnoreCheckpointFailures,
216     DisplayShutdownFailures,
217     DisplayBootFailures,
218     DisplayCheckpointFailures
219 } BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY;
220 
221 /* Undocumented */
222 typedef enum BcdStartupElementTypes
223 {
224     BcdStartupBoolean_PxeSoftReboot = 0x26000001,
225     BcdStartupString_PxeApplicationName = 0x22000002,
226 } BcdStartupElementTypes;
227 
228 /* DATA STRUCTURES ***********************************************************/
229 
230 typedef struct
231 {
232     union
233     {
234         ULONG PackedValue;
235         struct
236         {
237             ULONG SubType : 24;
238             ULONG Format : 4;
239             ULONG Class : 4;
240         };
241     };
242 } BcdElementType;
243 
244 typedef struct
245 {
246     union
247     {
248         ULONG PackedValue;
249         union
250         {
251             struct
252             {
253                 ULONG ApplicationCode : 20;
254                 ULONG ImageCode : 4;
255                 ULONG Reserved : 4;
256                 ULONG ObjectCode : 4;
257             } Application;
258             struct
259             {
260                 ULONG Value : 20;
261                 ULONG ClassCode : 4;
262                 ULONG Reserved : 4;
263                 ULONG ObjectCode : 4;
264             } Inherit;
265             struct
266             {
267                 ULONG Reserved:28;
268                 ULONG ObjectCode : 4;
269             } Device;
270         };
271     };
272 } BcdObjectType;
273 
274 typedef struct _BCD_ELEMENT_HEADER
275 {
276     ULONG Version;
277     ULONG Type;
278     ULONG Size;
279 } BCD_ELEMENT_HEADER, *PBCD_ELEMENT_HEADER;
280 
281 typedef struct _BCD_PACKED_ELEMENT
282 {
283     struct _BCD_PACKED_ELEMENT* NextEntry;
284     BcdElementType RootType;
285     BCD_ELEMENT_HEADER;
286     UCHAR Data[ANYSIZE_ARRAY];
287 } BCD_PACKED_ELEMENT, *PBCD_PACKED_ELEMENT;
288 
289 typedef struct _BCD_ELEMENT
290 {
291     PBCD_ELEMENT_HEADER Header;
292     PUCHAR Body;
293 } BCD_ELEMENT, *PBCD_ELEMENT;
294 
295 typedef struct _BCD_DEVICE_OPTION
296 {
297     GUID AssociatedEntry;
298     BL_DEVICE_DESCRIPTOR DeviceDescriptor;
299 } BCD_DEVICE_OPTION, *PBCD_DEVICE_OPTION;
300 
301 typedef struct _BCD_OBJECT_DESCRIPTION
302 {
303     ULONG Valid;
304     ULONG Type;
305 } BCD_OBJECT_DESCRIPTION, *PBCD_OBJECT_DESCRIPTION;
306 
307 /* FUNCTIONS ******************************************************************/
308 
309 NTSTATUS
310 BcdOpenStoreFromFile (
311     _In_ PUNICODE_STRING FileName,
312     _In_ PHANDLE StoreHandle
313     );
314 
315 #define BCD_ENUMERATE_FLAG_DEEP         0x04
316 #define BCD_ENUMERATE_FLAG_DEVICES      0x08
317 #define BCD_ENUMERATE_FLAG_IN_ORDER     0x10
318 
319 NTSTATUS
320 BiEnumerateElements (
321     _In_ HANDLE BcdHandle,
322     _In_ HANDLE ObjectHandle,
323     _In_ ULONG RootElementType,
324     _In_ ULONG Flags,
325     _Out_opt_ PBCD_PACKED_ELEMENT Elements,
326     _Inout_ PULONG ElementSize,
327     _Out_ PULONG ElementCountNe
328     );
329 
330 NTSTATUS
331 BcdOpenObject (
332     _In_ HANDLE BcdHandle,
333     _In_ PGUID ObjectId,
334     _Out_ PHANDLE ObjectHandle
335     );
336 
337 NTSTATUS
338 BcdDeleteElement (
339     _In_ HANDLE ObjectHandle,
340     _In_ ULONG Type
341     );
342 
343 NTSTATUS
344 BcdEnumerateAndUnpackElements (
345     _In_ HANDLE BcdHandle,
346     _In_ HANDLE ObjectHandle,
347     _Out_opt_ PBCD_ELEMENT Elements,
348     _Inout_ PULONG ElementSize,
349     _Out_ PULONG ElementCount
350     );
351 
352 NTSTATUS
353 BiGetObjectDescription (
354     _In_ HANDLE ObjectHandle,
355     _Out_ PBCD_OBJECT_DESCRIPTION Description
356     );
357 
358 #endif
359