ReactOS  0.4.14-dev-608-gd495a4f
bcd.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BcdElementType
 
struct  BcdObjectType
 
struct  _BCD_ELEMENT_HEADER
 
struct  _BCD_PACKED_ELEMENT
 
struct  _BCD_ELEMENT
 
struct  _BCD_DEVICE_OPTION
 
struct  _BCD_OBJECT_DESCRIPTION
 

Macros

#define BCD_CLASS_LIBRARY   0x01
 
#define BCD_CLASS_APPLICATION   0x02
 
#define BCD_CLASS_DEVICE   0x03
 
#define BCD_CLASS_OEM   0x05
 
#define BCD_TYPE_DEVICE   0x01
 
#define BCD_TYPE_STRING   0x02
 
#define BCD_TYPE_OBJECT   0x03
 
#define BCD_TYPE_OBJECT_LIST   0x04
 
#define BCD_TYPE_INTEGER   0x05
 
#define BCD_TYPE_BOOLEAN   0x06
 
#define BCD_TYPE_INTEGER_LIST   0x07
 
#define BCD_IMAGE_TYPE_FIRMWARE   0x01
 
#define BCD_IMAGE_TYPE_BOOT_APP   0x02
 
#define BCD_IMAGE_TYPE_NTLDR   0x03
 
#define BCD_IMAGE_TYPE_REAL_MODE   0x04
 
#define BCD_APPLICATION_TYPE_FWBOOTMGR   0x01
 
#define BCD_APPLICATION_TYPE_BOOTMGR   0x02
 
#define BCD_APPLICATION_TYPE_OSLOADER   0x03
 
#define BCD_APPLICATION_TYPE_RESUME   0x04
 
#define BCD_APPLICATION_TYPE_MEMDIAG   0x05
 
#define BCD_APPLICATION_TYPE_NTLDR   0x06
 
#define BCD_APPLICATION_TYPE_SETUPLDR   0x07
 
#define BCD_APPLICATION_TYPE_BOOTSECTOR   0x08
 
#define BCD_APPLICATION_TYPE_STARTUPCOM   0x09
 
#define BCD_OBJECT_TYPE_APPLICATION   0x01
 
#define BCD_OBJECT_TYPE_INHERIT   0x02
 
#define BCD_OBJECT_TYPE_DEVICE   0x03
 
#define BCD_ENUMERATE_FLAG_DEEP   0x04
 
#define BCD_ENUMERATE_FLAG_DEVICES   0x08
 
#define BCD_ENUMERATE_FLAG_IN_ORDER   0x10
 

Typedefs

typedef enum BcdLibraryElementTypes BcdLibraryElementTypes
 
typedef enum BcdOSLoaderElementTypes BcdOSLoaderElementTypes
 
typedef enum BcdBootMgrElementTypes BcdBootMgrElementTypes
 
typedef enum _BcdResumeElementTypes BcdResumeElementTypes
 
typedef enum _BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY
 
typedef enum BcdStartupElementTypes BcdStartupElementTypes
 
typedef struct _BCD_ELEMENT_HEADER BCD_ELEMENT_HEADER
 
typedef struct _BCD_ELEMENT_HEADERPBCD_ELEMENT_HEADER
 
typedef struct _BCD_PACKED_ELEMENT BCD_PACKED_ELEMENT
 
typedef struct _BCD_PACKED_ELEMENTPBCD_PACKED_ELEMENT
 
typedef struct _BCD_ELEMENT BCD_ELEMENT
 
typedef struct _BCD_ELEMENTPBCD_ELEMENT
 
typedef struct _BCD_DEVICE_OPTION BCD_DEVICE_OPTION
 
typedef struct _BCD_DEVICE_OPTIONPBCD_DEVICE_OPTION
 
typedef struct _BCD_OBJECT_DESCRIPTION BCD_OBJECT_DESCRIPTION
 
typedef struct _BCD_OBJECT_DESCRIPTIONPBCD_OBJECT_DESCRIPTION
 

Enumerations

enum  BcdLibraryElementTypes {
  BcdLibraryDevice_ApplicationDevice = 0x11000001, BcdLibraryString_ApplicationPath = 0x12000002, BcdLibraryString_Description = 0x12000004, BcdLibraryString_PreferredLocale = 0x12000005,
  BcdLibraryObjectList_InheritedObjects = 0x14000006, BcdLibraryInteger_TruncatePhysicalMemory = 0x15000007, BcdLibraryObjectList_RecoverySequence = 0x14000008, BcdLibraryBoolean_AutoRecoveryEnabled = 0x16000009,
  BcdLibraryIntegerList_BadMemoryList = 0x1700000a, BcdLibraryBoolean_AllowBadMemoryAccess = 0x1600000b, BcdLibraryInteger_FirstMegabytePolicy = 0x1500000c, BcdLibraryInteger_RelocatePhysicalMemory = 0x1500000D,
  BcdLibraryInteger_AvoidLowPhysicalMemory = 0x1500000E, BcdLibraryBoolean_DebuggerEnabled = 0x16000010, BcdLibraryInteger_DebuggerType = 0x15000011, BcdLibraryInteger_SerialDebuggerPortAddress = 0x15000012,
  BcdLibraryInteger_SerialDebuggerPort = 0x15000013, BcdLibraryInteger_SerialDebuggerBaudRate = 0x15000014, BcdLibraryInteger_1394DebuggerChannel = 0x15000015, BcdLibraryString_UsbDebuggerTargetName = 0x12000016,
  BcdLibraryBoolean_DebuggerIgnoreUsermodeExceptions = 0x16000017, BcdLibraryInteger_DebuggerStartPolicy = 0x15000018, BcdLibraryString_DebuggerBusParameters = 0x12000019, BcdLibraryInteger_DebuggerNetHostIP = 0x1500001A,
  BcdLibraryInteger_DebuggerNetPort = 0x1500001B, BcdLibraryBoolean_DebuggerNetDhcp = 0x1600001C, BcdLibraryString_DebuggerNetKey = 0x1200001D, BcdLibraryBoolean_EmsEnabled = 0x16000020,
  BcdLibraryInteger_EmsPort = 0x15000022, BcdLibraryInteger_EmsBaudRate = 0x15000023, BcdLibraryString_LoadOptionsString = 0x12000030, BcdLibraryBoolean_DisplayAdvancedOptions = 0x16000040,
  BcdLibraryBoolean_DisplayOptionsEdit = 0x16000041, BcdLibraryDevice_BsdLogDevice = 0x11000043, BcdLibraryString_BsdLogPath = 0x12000044, BcdLibraryBoolean_PreserveBsdLog = 0x16000045,
  BcdLibraryBoolean_GraphicsModeDisabled = 0x16000046, BcdLibraryInteger_ConfigAccessPolicy = 0x15000047, BcdLibraryBoolean_DisableIntegrityChecks = 0x16000048, BcdLibraryBoolean_AllowPrereleaseSignatures = 0x16000049,
  BcdLibraryString_FontPath = 0x1200004A, BcdLibraryInteger_SiPolicy = 0x1500004B, BcdLibraryInteger_FveBandId = 0x1500004C, BcdLibraryBoolean_ConsoleExtendedInput = 0x16000050,
  BcdLibraryInteger_GraphicsResolution = 0x15000052, BcdLibraryInteger_DisplayMessage = 0x15000065, BcdLibraryInteger_DisplayMessageOverride = 0x15000066, BcdLibraryInteger_UndocumentedMagic = 0x15000075,
  BcdLibraryBoolean_RestartOnFailure = 0x16000053, BcdLibraryBoolean_GraphicsForceHighestMode = 0x16000054, BcdLibraryBoolean_IsolatedExecutionContext = 0x16000060, BcdLibraryBoolean_BootUxDisable = 0x1600006C,
  BcdLibraryBoolean_BootShutdownDisabled = 0x16000074, BcdLibraryIntegerList_AllowedInMemorySettings = 0x17000077, BcdLibraryBoolean_ForceFipsCrypto = 0x16000079, BcdLibraryBoolean_MobileGraphics = 0x1600007A
}
 
enum  BcdOSLoaderElementTypes {
  BcdOSLoaderDevice_OSDevice = 0x21000001, BcdOSLoaderString_SystemRoot = 0x22000002, BcdOSLoaderObject_AssociatedResumeObject = 0x23000003, BcdOSLoaderBoolean_DetectKernelAndHal = 0x26000010,
  BcdOSLoaderString_KernelPath = 0x22000011, BcdOSLoaderString_HalPath = 0x22000012, BcdOSLoaderString_DbgTransportPath = 0x22000013, BcdOSLoaderInteger_NxPolicy = 0x25000020,
  BcdOSLoaderInteger_PAEPolicy = 0x25000021, BcdOSLoaderBoolean_WinPEMode = 0x26000022, BcdOSLoaderBoolean_DisableCrashAutoReboot = 0x26000024, BcdOSLoaderBoolean_UseLastGoodSettings = 0x26000025,
  BcdOSLoaderBoolean_AllowPrereleaseSignatures = 0x26000027, BcdOSLoaderBoolean_NoLowMemory = 0x26000030, BcdOSLoaderInteger_RemoveMemory = 0x25000031, BcdOSLoaderInteger_IncreaseUserVa = 0x25000032,
  BcdOSLoaderBoolean_UseVgaDriver = 0x26000040, BcdOSLoaderBoolean_DisableBootDisplay = 0x26000041, BcdOSLoaderBoolean_DisableVesaBios = 0x26000042, BcdOSLoaderBoolean_DisableVgaMode = 0x26000043,
  BcdOSLoaderInteger_ClusterModeAddressing = 0x25000050, BcdOSLoaderBoolean_UsePhysicalDestination = 0x26000051, BcdOSLoaderInteger_RestrictApicCluster = 0x25000052, BcdOSLoaderBoolean_UseLegacyApicMode = 0x26000054,
  BcdOSLoaderInteger_X2ApicPolicy = 0x25000055, BcdOSLoaderBoolean_UseBootProcessorOnly = 0x26000060, BcdOSLoaderInteger_NumberOfProcessors = 0x25000061, BcdOSLoaderBoolean_ForceMaximumProcessors = 0x26000062,
  BcdOSLoaderBoolean_ProcessorConfigurationFlags = 0x25000063, BcdOSLoaderBoolean_MaximizeGroupsCreated = 0x26000064, BcdOSLoaderBoolean_ForceGroupAwareness = 0x26000065, BcdOSLoaderInteger_GroupSize = 0x25000066,
  BcdOSLoaderInteger_UseFirmwarePciSettings = 0x26000070, BcdOSLoaderInteger_MsiPolicy = 0x25000071, BcdOSLoaderInteger_SafeBoot = 0x25000080, BcdOSLoaderBoolean_SafeBootAlternateShell = 0x26000081,
  BcdOSLoaderBoolean_BootLogInitialization = 0x26000090, BcdOSLoaderBoolean_VerboseObjectLoadMode = 0x26000091, BcdOSLoaderBoolean_KernelDebuggerEnabled = 0x260000a0, BcdOSLoaderBoolean_DebuggerHalBreakpoint = 0x260000a1,
  BcdOSLoaderBoolean_UsePlatformClock = 0x260000A2, BcdOSLoaderBoolean_ForceLegacyPlatform = 0x260000A3, BcdOSLoaderInteger_TscSyncPolicy = 0x250000A6, BcdOSLoaderBoolean_EmsEnabled = 0x260000B0,
  BcdOSLoaderInteger_ForceFailure = 0x250000C0, BcdOSLoaderInteger_DriverLoadFailurePolicy = 0x250000C1, BcdOSLoaderInteger_BootMenuPolicy = 0x250000C2, BcdOSLoaderBoolean_AdvancedOptionsOneTime = 0x260000C3,
  BcdOSLoaderBoolean_OptionsEditOneTime = 0x260000C4, BcdOSLoaderInteger_BootStatusPolicy = 0x250000E0, BcdOSLoaderBoolean_DisableElamDrivers = 0x260000E1, BcdOSLoaderInteger_HypervisorLaunchType = 0x250000F0,
  BcdOSLoaderBoolean_HypervisorDebuggerEnabled = 0x260000F2, BcdOSLoaderInteger_HypervisorDebuggerType = 0x250000F3, BcdOSLoaderInteger_HypervisorDebuggerPortNumber = 0x250000F4, BcdOSLoaderInteger_HypervisorDebuggerBaudrate = 0x250000F5,
  BcdOSLoaderInteger_HypervisorDebugger1394Channel = 0x250000F6, BcdOSLoaderInteger_BootUxPolicy = 0x250000F7, BcdOSLoaderString_HypervisorDebuggerBusParams = 0x220000F9, BcdOSLoaderInteger_HypervisorNumProc = 0x250000FA,
  BcdOSLoaderInteger_HypervisorRootProcPerNode = 0x250000FB, BcdOSLoaderBoolean_HypervisorUseLargeVTlb = 0x260000FC, BcdOSLoaderInteger_HypervisorDebuggerNetHostIp = 0x250000FD, BcdOSLoaderInteger_HypervisorDebuggerNetHostPort = 0x250000FE,
  BcdOSLoaderInteger_TpmBootEntropyPolicy = 0x25000100, BcdOSLoaderString_HypervisorDebuggerNetKey = 0x22000110, BcdOSLoaderBoolean_HypervisorDebuggerNetDhcp = 0x26000114, BcdOSLoaderInteger_HypervisorIommuPolicy = 0x25000115,
  BcdOSLoaderInteger_XSaveDisable = 0x2500012b
}
 
enum  BcdBootMgrElementTypes {
  BcdBootMgrObjectList_DisplayOrder = 0x24000001, BcdBootMgrObjectList_BootSequence = 0x24000002, BcdBootMgrObject_DefaultObject = 0x23000003, BcdBootMgrInteger_Timeout = 0x25000004,
  BcdBootMgrBoolean_AttemptResume = 0x26000005, BcdBootMgrObject_ResumeObject = 0x23000006, BcdBootMgrObjectList_ToolsDisplayOrder = 0x24000010, BcdBootMgrBoolean_DisplayBootMenu = 0x26000020,
  BcdBootMgrBoolean_NoErrorDisplay = 0x26000021, BcdBootMgrDevice_BcdDevice = 0x21000022, BcdBootMgrString_BcdFilePath = 0x22000023, BcdBootMgrBoolean_ProcessCustomActionsFirst = 0x26000028,
  BcdBootMgrIntegerList_CustomActionsList = 0x27000030, BcdBootMgrBoolean_PersistBootSequence = 0x26000031
}
 
enum  _BcdResumeElementTypes {
  Reserved1 = 0x21000001, Reserved2 = 0x22000002, BcdResumeBoolean_UseCustomSettings = 0x26000003, BcdResumeDevice_AssociatedOsDevice = 0x21000005,
  BcdResumeBoolean_DebugOptionEnabled = 0x26000006, BcdResumeInteger_BootMenuPolicy = 0x25000008
}
 
enum  _BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY {
  DisplayAllFailures, IgnoreAllFailures, IgnoreShutdownFailures, IgnoreBootFailures,
  IgnoreCheckpointFailures, DisplayShutdownFailures, DisplayBootFailures, DisplayCheckpointFailures
}
 
enum  BcdStartupElementTypes { BcdStartupBoolean_PxeSoftReboot = 0x26000001, BcdStartupString_PxeApplicationName = 0x22000002 }
 

Functions

NTSTATUS BcdOpenStoreFromFile (_In_ PUNICODE_STRING FileName, _In_ PHANDLE StoreHandle)
 
NTSTATUS BiEnumerateElements (_In_ HANDLE BcdHandle, _In_ HANDLE ObjectHandle, _In_ ULONG RootElementType, _In_ ULONG Flags, _Out_opt_ PBCD_PACKED_ELEMENT Elements, _Inout_ PULONG ElementSize, _Out_ PULONG ElementCountNe)
 
NTSTATUS BcdOpenObject (_In_ HANDLE BcdHandle, _In_ PGUID ObjectId, _Out_ PHANDLE ObjectHandle)
 
NTSTATUS BcdDeleteElement (_In_ HANDLE ObjectHandle, _In_ ULONG Type)
 
NTSTATUS BcdEnumerateAndUnpackElements (_In_ HANDLE BcdHandle, _In_ HANDLE ObjectHandle, _Out_opt_ PBCD_ELEMENT Elements, _Inout_ PULONG ElementSize, _Out_ PULONG ElementCount)
 
NTSTATUS BiGetObjectDescription (_In_ HANDLE ObjectHandle, _Out_ PBCD_OBJECT_DESCRIPTION Description)
 

Macro Definition Documentation

◆ BCD_APPLICATION_TYPE_BOOTMGR

#define BCD_APPLICATION_TYPE_BOOTMGR   0x02

Definition at line 35 of file bcd.h.

◆ BCD_APPLICATION_TYPE_BOOTSECTOR

#define BCD_APPLICATION_TYPE_BOOTSECTOR   0x08

Definition at line 41 of file bcd.h.

◆ BCD_APPLICATION_TYPE_FWBOOTMGR

#define BCD_APPLICATION_TYPE_FWBOOTMGR   0x01

Definition at line 34 of file bcd.h.

◆ BCD_APPLICATION_TYPE_MEMDIAG

#define BCD_APPLICATION_TYPE_MEMDIAG   0x05

Definition at line 38 of file bcd.h.

◆ BCD_APPLICATION_TYPE_NTLDR

#define BCD_APPLICATION_TYPE_NTLDR   0x06

Definition at line 39 of file bcd.h.

◆ BCD_APPLICATION_TYPE_OSLOADER

#define BCD_APPLICATION_TYPE_OSLOADER   0x03

Definition at line 36 of file bcd.h.

◆ BCD_APPLICATION_TYPE_RESUME

#define BCD_APPLICATION_TYPE_RESUME   0x04

Definition at line 37 of file bcd.h.

◆ BCD_APPLICATION_TYPE_SETUPLDR

#define BCD_APPLICATION_TYPE_SETUPLDR   0x07

Definition at line 40 of file bcd.h.

◆ BCD_APPLICATION_TYPE_STARTUPCOM

#define BCD_APPLICATION_TYPE_STARTUPCOM   0x09

Definition at line 42 of file bcd.h.

◆ BCD_CLASS_APPLICATION

#define BCD_CLASS_APPLICATION   0x02

Definition at line 17 of file bcd.h.

◆ BCD_CLASS_DEVICE

#define BCD_CLASS_DEVICE   0x03

Definition at line 18 of file bcd.h.

◆ BCD_CLASS_LIBRARY

#define BCD_CLASS_LIBRARY   0x01

Definition at line 16 of file bcd.h.

◆ BCD_CLASS_OEM

#define BCD_CLASS_OEM   0x05

Definition at line 19 of file bcd.h.

◆ BCD_ENUMERATE_FLAG_DEEP

#define BCD_ENUMERATE_FLAG_DEEP   0x04

Definition at line 315 of file bcd.h.

◆ BCD_ENUMERATE_FLAG_DEVICES

#define BCD_ENUMERATE_FLAG_DEVICES   0x08

Definition at line 316 of file bcd.h.

◆ BCD_ENUMERATE_FLAG_IN_ORDER

#define BCD_ENUMERATE_FLAG_IN_ORDER   0x10

Definition at line 317 of file bcd.h.

◆ BCD_IMAGE_TYPE_BOOT_APP

#define BCD_IMAGE_TYPE_BOOT_APP   0x02

Definition at line 30 of file bcd.h.

◆ BCD_IMAGE_TYPE_FIRMWARE

#define BCD_IMAGE_TYPE_FIRMWARE   0x01

Definition at line 29 of file bcd.h.

◆ BCD_IMAGE_TYPE_NTLDR

#define BCD_IMAGE_TYPE_NTLDR   0x03

Definition at line 31 of file bcd.h.

◆ BCD_IMAGE_TYPE_REAL_MODE

#define BCD_IMAGE_TYPE_REAL_MODE   0x04

Definition at line 32 of file bcd.h.

◆ BCD_OBJECT_TYPE_APPLICATION

#define BCD_OBJECT_TYPE_APPLICATION   0x01

Definition at line 44 of file bcd.h.

◆ BCD_OBJECT_TYPE_DEVICE

#define BCD_OBJECT_TYPE_DEVICE   0x03

Definition at line 46 of file bcd.h.

◆ BCD_OBJECT_TYPE_INHERIT

#define BCD_OBJECT_TYPE_INHERIT   0x02

Definition at line 45 of file bcd.h.

◆ BCD_TYPE_BOOLEAN

#define BCD_TYPE_BOOLEAN   0x06

Definition at line 26 of file bcd.h.

◆ BCD_TYPE_DEVICE

#define BCD_TYPE_DEVICE   0x01

Definition at line 21 of file bcd.h.

◆ BCD_TYPE_INTEGER

#define BCD_TYPE_INTEGER   0x05

Definition at line 25 of file bcd.h.

◆ BCD_TYPE_INTEGER_LIST

#define BCD_TYPE_INTEGER_LIST   0x07

Definition at line 27 of file bcd.h.

◆ BCD_TYPE_OBJECT

#define BCD_TYPE_OBJECT   0x03

Definition at line 23 of file bcd.h.

◆ BCD_TYPE_OBJECT_LIST

#define BCD_TYPE_OBJECT_LIST   0x04

Definition at line 24 of file bcd.h.

◆ BCD_TYPE_STRING

#define BCD_TYPE_STRING   0x02

Definition at line 22 of file bcd.h.

Typedef Documentation

◆ BCD_DEVICE_OPTION

◆ BCD_ELEMENT

◆ BCD_ELEMENT_HEADER

◆ BCD_OBJECT_DESCRIPTION

◆ BCD_PACKED_ELEMENT

◆ BcdBootMgrElementTypes

◆ BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY

◆ BcdLibraryElementTypes

◆ BcdOSLoaderElementTypes

◆ BcdResumeElementTypes

◆ BcdStartupElementTypes

◆ PBCD_DEVICE_OPTION

◆ PBCD_ELEMENT

◆ PBCD_ELEMENT_HEADER

◆ PBCD_OBJECT_DESCRIPTION

◆ PBCD_PACKED_ELEMENT

Enumeration Type Documentation

◆ _BCDE_OSLOADER_TYPE_BOOT_STATUS_POLICY

Enumerator
DisplayAllFailures 
IgnoreAllFailures 
IgnoreShutdownFailures 
IgnoreBootFailures 
IgnoreCheckpointFailures 
DisplayShutdownFailures 
DisplayBootFailures 
DisplayCheckpointFailures 

Definition at line 209 of file bcd.h.

◆ _BcdResumeElementTypes

Enumerator
Reserved1 
Reserved2 
BcdResumeBoolean_UseCustomSettings 
BcdResumeDevice_AssociatedOsDevice 
BcdResumeBoolean_DebugOptionEnabled 
BcdResumeInteger_BootMenuPolicy 

Definition at line 199 of file bcd.h.

200 {
201  Reserved1 = 0x21000001,
202  Reserved2 = 0x22000002,
enum _BcdResumeElementTypes BcdResumeElementTypes
Definition: bcd.h:202
Definition: bcd.h:201

◆ BcdBootMgrElementTypes

Enumerator
BcdBootMgrObjectList_DisplayOrder 
BcdBootMgrObjectList_BootSequence 
BcdBootMgrObject_DefaultObject 
BcdBootMgrInteger_Timeout 
BcdBootMgrBoolean_AttemptResume 
BcdBootMgrObject_ResumeObject 
BcdBootMgrObjectList_ToolsDisplayOrder 
BcdBootMgrBoolean_DisplayBootMenu 
BcdBootMgrBoolean_NoErrorDisplay 
BcdBootMgrDevice_BcdDevice 
BcdBootMgrString_BcdFilePath 
BcdBootMgrBoolean_ProcessCustomActionsFirst 
BcdBootMgrIntegerList_CustomActionsList 
BcdBootMgrBoolean_PersistBootSequence 

Definition at line 181 of file bcd.h.

182 {
185  BcdBootMgrObject_DefaultObject = 0x23000003,
186  BcdBootMgrInteger_Timeout = 0x25000004,
187  BcdBootMgrBoolean_AttemptResume = 0x26000005,
188  BcdBootMgrObject_ResumeObject = 0x23000006,
192  BcdBootMgrDevice_BcdDevice = 0x21000022,
193  BcdBootMgrString_BcdFilePath = 0x22000023,
BcdBootMgrElementTypes
Definition: bcd.h:181

◆ BcdLibraryElementTypes

Enumerator
BcdLibraryDevice_ApplicationDevice 
BcdLibraryString_ApplicationPath 
BcdLibraryString_Description 
BcdLibraryString_PreferredLocale 
BcdLibraryObjectList_InheritedObjects 
BcdLibraryInteger_TruncatePhysicalMemory 
BcdLibraryObjectList_RecoverySequence 
BcdLibraryBoolean_AutoRecoveryEnabled 
BcdLibraryIntegerList_BadMemoryList 
BcdLibraryBoolean_AllowBadMemoryAccess 
BcdLibraryInteger_FirstMegabytePolicy 
BcdLibraryInteger_RelocatePhysicalMemory 
BcdLibraryInteger_AvoidLowPhysicalMemory 
BcdLibraryBoolean_DebuggerEnabled 
BcdLibraryInteger_DebuggerType 
BcdLibraryInteger_SerialDebuggerPortAddress 
BcdLibraryInteger_SerialDebuggerPort 
BcdLibraryInteger_SerialDebuggerBaudRate 
BcdLibraryInteger_1394DebuggerChannel 
BcdLibraryString_UsbDebuggerTargetName 
BcdLibraryBoolean_DebuggerIgnoreUsermodeExceptions 
BcdLibraryInteger_DebuggerStartPolicy 
BcdLibraryString_DebuggerBusParameters 
BcdLibraryInteger_DebuggerNetHostIP 
BcdLibraryInteger_DebuggerNetPort 
BcdLibraryBoolean_DebuggerNetDhcp 
BcdLibraryString_DebuggerNetKey 
BcdLibraryBoolean_EmsEnabled 
BcdLibraryInteger_EmsPort 
BcdLibraryInteger_EmsBaudRate 
BcdLibraryString_LoadOptionsString 
BcdLibraryBoolean_DisplayAdvancedOptions 
BcdLibraryBoolean_DisplayOptionsEdit 
BcdLibraryDevice_BsdLogDevice 
BcdLibraryString_BsdLogPath 
BcdLibraryBoolean_PreserveBsdLog 
BcdLibraryBoolean_GraphicsModeDisabled 
BcdLibraryInteger_ConfigAccessPolicy 
BcdLibraryBoolean_DisableIntegrityChecks 
BcdLibraryBoolean_AllowPrereleaseSignatures 
BcdLibraryString_FontPath 
BcdLibraryInteger_SiPolicy 
BcdLibraryInteger_FveBandId 
BcdLibraryBoolean_ConsoleExtendedInput 
BcdLibraryInteger_GraphicsResolution 
BcdLibraryInteger_DisplayMessage 
BcdLibraryInteger_DisplayMessageOverride 
BcdLibraryInteger_UndocumentedMagic 
BcdLibraryBoolean_RestartOnFailure 
BcdLibraryBoolean_GraphicsForceHighestMode 
BcdLibraryBoolean_IsolatedExecutionContext 
BcdLibraryBoolean_BootUxDisable 
BcdLibraryBoolean_BootShutdownDisabled 
BcdLibraryIntegerList_AllowedInMemorySettings 
BcdLibraryBoolean_ForceFipsCrypto 
BcdLibraryBoolean_MobileGraphics 

Definition at line 48 of file bcd.h.

49 {
52  BcdLibraryString_Description = 0x12000004,
64  BcdLibraryInteger_DebuggerType = 0x15000011,
77  BcdLibraryBoolean_EmsEnabled = 0x16000020,
78  BcdLibraryInteger_EmsPort = 0x15000022,
79  BcdLibraryInteger_EmsBaudRate = 0x15000023,
83  BcdLibraryDevice_BsdLogDevice = 0x11000043,
84  BcdLibraryString_BsdLogPath = 0x12000044,
85  BcdLibraryBoolean_PreserveBsdLog = 0x16000045, /* Undocumented */
90  BcdLibraryString_FontPath = 0x1200004A,
91  BcdLibraryInteger_SiPolicy = 0x1500004B,
92  BcdLibraryInteger_FveBandId = 0x1500004C,
95  BcdLibraryInteger_DisplayMessage = 0x15000065, /* Undocumented */
96  BcdLibraryInteger_DisplayMessageOverride = 0x15000066, /* Undocumented */
97  BcdLibraryInteger_UndocumentedMagic = 0x15000075, /* Undocumented magic */
101  BcdLibraryBoolean_BootUxDisable = 0x1600006C,
105  BcdLibraryBoolean_MobileGraphics = 0x1600007A /* Undocumented */
BcdLibraryElementTypes
Definition: bcd.h:48

◆ BcdOSLoaderElementTypes

Enumerator
BcdOSLoaderDevice_OSDevice 
BcdOSLoaderString_SystemRoot 
BcdOSLoaderObject_AssociatedResumeObject 
BcdOSLoaderBoolean_DetectKernelAndHal 
BcdOSLoaderString_KernelPath 
BcdOSLoaderString_HalPath 
BcdOSLoaderString_DbgTransportPath 
BcdOSLoaderInteger_NxPolicy 
BcdOSLoaderInteger_PAEPolicy 
BcdOSLoaderBoolean_WinPEMode 
BcdOSLoaderBoolean_DisableCrashAutoReboot 
BcdOSLoaderBoolean_UseLastGoodSettings 
BcdOSLoaderBoolean_AllowPrereleaseSignatures 
BcdOSLoaderBoolean_NoLowMemory 
BcdOSLoaderInteger_RemoveMemory 
BcdOSLoaderInteger_IncreaseUserVa 
BcdOSLoaderBoolean_UseVgaDriver 
BcdOSLoaderBoolean_DisableBootDisplay 
BcdOSLoaderBoolean_DisableVesaBios 
BcdOSLoaderBoolean_DisableVgaMode 
BcdOSLoaderInteger_ClusterModeAddressing 
BcdOSLoaderBoolean_UsePhysicalDestination 
BcdOSLoaderInteger_RestrictApicCluster 
BcdOSLoaderBoolean_UseLegacyApicMode 
BcdOSLoaderInteger_X2ApicPolicy 
BcdOSLoaderBoolean_UseBootProcessorOnly 
BcdOSLoaderInteger_NumberOfProcessors 
BcdOSLoaderBoolean_ForceMaximumProcessors 
BcdOSLoaderBoolean_ProcessorConfigurationFlags 
BcdOSLoaderBoolean_MaximizeGroupsCreated 
BcdOSLoaderBoolean_ForceGroupAwareness 
BcdOSLoaderInteger_GroupSize 
BcdOSLoaderInteger_UseFirmwarePciSettings 
BcdOSLoaderInteger_MsiPolicy 
BcdOSLoaderInteger_SafeBoot 
BcdOSLoaderBoolean_SafeBootAlternateShell 
BcdOSLoaderBoolean_BootLogInitialization 
BcdOSLoaderBoolean_VerboseObjectLoadMode 
BcdOSLoaderBoolean_KernelDebuggerEnabled 
BcdOSLoaderBoolean_DebuggerHalBreakpoint 
BcdOSLoaderBoolean_UsePlatformClock 
BcdOSLoaderBoolean_ForceLegacyPlatform 
BcdOSLoaderInteger_TscSyncPolicy 
BcdOSLoaderBoolean_EmsEnabled 
BcdOSLoaderInteger_ForceFailure 
BcdOSLoaderInteger_DriverLoadFailurePolicy 
BcdOSLoaderInteger_BootMenuPolicy 
BcdOSLoaderBoolean_AdvancedOptionsOneTime 
BcdOSLoaderBoolean_OptionsEditOneTime 
BcdOSLoaderInteger_BootStatusPolicy 
BcdOSLoaderBoolean_DisableElamDrivers 
BcdOSLoaderInteger_HypervisorLaunchType 
BcdOSLoaderBoolean_HypervisorDebuggerEnabled 
BcdOSLoaderInteger_HypervisorDebuggerType 
BcdOSLoaderInteger_HypervisorDebuggerPortNumber 
BcdOSLoaderInteger_HypervisorDebuggerBaudrate 
BcdOSLoaderInteger_HypervisorDebugger1394Channel 
BcdOSLoaderInteger_BootUxPolicy 
BcdOSLoaderString_HypervisorDebuggerBusParams 
BcdOSLoaderInteger_HypervisorNumProc 
BcdOSLoaderInteger_HypervisorRootProcPerNode 
BcdOSLoaderBoolean_HypervisorUseLargeVTlb 
BcdOSLoaderInteger_HypervisorDebuggerNetHostIp 
BcdOSLoaderInteger_HypervisorDebuggerNetHostPort 
BcdOSLoaderInteger_TpmBootEntropyPolicy 
BcdOSLoaderString_HypervisorDebuggerNetKey 
BcdOSLoaderBoolean_HypervisorDebuggerNetDhcp 
BcdOSLoaderInteger_HypervisorIommuPolicy 
BcdOSLoaderInteger_XSaveDisable 

Definition at line 108 of file bcd.h.

109 {
110  BcdOSLoaderDevice_OSDevice = 0x21000001,
111  BcdOSLoaderString_SystemRoot = 0x22000002,
114  BcdOSLoaderString_KernelPath = 0x22000011,
115  BcdOSLoaderString_HalPath = 0x22000012,
117  BcdOSLoaderInteger_NxPolicy = 0x25000020,
118  BcdOSLoaderInteger_PAEPolicy = 0x25000021,
119  BcdOSLoaderBoolean_WinPEMode = 0x26000022,
123  BcdOSLoaderBoolean_NoLowMemory = 0x26000030,
124  BcdOSLoaderInteger_RemoveMemory = 0x25000031,
126  BcdOSLoaderBoolean_UseVgaDriver = 0x26000040,
134  BcdOSLoaderInteger_X2ApicPolicy = 0x25000055,
141  BcdOSLoaderInteger_GroupSize = 0x25000066,
143  BcdOSLoaderInteger_MsiPolicy = 0x25000071,
144  BcdOSLoaderInteger_SafeBoot = 0x25000080,
153  BcdOSLoaderBoolean_EmsEnabled = 0x260000B0,
154  BcdOSLoaderInteger_ForceFailure = 0x250000C0,
158  BcdOSLoaderBoolean_OptionsEditOneTime = 0x260000C4, /* Undocumented */
167  BcdOSLoaderInteger_BootUxPolicy = 0x250000F7,
BcdOSLoaderElementTypes
Definition: bcd.h:108

◆ BcdStartupElementTypes

Enumerator
BcdStartupBoolean_PxeSoftReboot 
BcdStartupString_PxeApplicationName 

Definition at line 222 of file bcd.h.

Function Documentation

◆ BcdDeleteElement()

NTSTATUS BcdDeleteElement ( _In_ HANDLE  ObjectHandle,
_In_ ULONG  Type 
)

Definition at line 560 of file bcd.c.

564 {
566  HANDLE ElementsHandle, ElementHandle;
567  WCHAR TypeString[22];
568 
569  /* Open the elements key */
570  Status = BiOpenKey(ObjectHandle, L"Elements", &ElementsHandle);
571  if (NT_SUCCESS(Status))
572  {
573  /* Convert the element ID into a string */
574  if (!_ultow(Type, TypeString, 16))
575  {
576  /* Failed to do so */
578  }
579  else
580  {
581  /* Open the element specifically */
582  Status = BiOpenKey(ElementsHandle, TypeString, &ElementHandle);
583  if (NT_SUCCESS(Status))
584  {
585  /* Delete it */
586  Status = BiDeleteKey(ElementHandle);
587  if (NT_SUCCESS(Status))
588  {
589  /* No point in closing the handle anymore */
590  ElementHandle = NULL;
591  }
592  }
593  else
594  {
595  /* The element doesn't exist */
597  }
598 
599  /* Check if we should close the key */
600  if (ElementHandle)
601  {
602  /* Do it */
603  BiCloseKey(ElementHandle);
604  }
605  }
606  }
607 
608  /* Check if we should close the elements handle */
609  if (ElementsHandle)
610  {
611  /* Do it */
612  BiCloseKey(ElementsHandle);
613  }
614 
615  /* Return whatever the result was */
616  return Status;
617 }
VOID BiCloseKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:141
_CRTIMP wchar_t *__cdecl _ultow(_In_ unsigned long _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
Type
Definition: Type.h:6
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_NOT_FOUND
Definition: shellext.h:72
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS BiOpenKey(_In_ HANDLE ParentHandle, _In_ PWCHAR KeyName, _Out_ PHANDLE Handle)
Definition: bootreg.c:186
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS BiDeleteKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:886
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24

Referenced by BmPurgeOption().

◆ BcdEnumerateAndUnpackElements()

NTSTATUS BcdEnumerateAndUnpackElements ( _In_ HANDLE  BcdHandle,
_In_ HANDLE  ObjectHandle,
_Out_opt_ PBCD_ELEMENT  Elements,
_Inout_ PULONG  ElementSize,
_Out_ PULONG  ElementCount 
)

Definition at line 1241 of file bcd.c.

1248 {
1249  PVOID LocalElements;
1250  NTSTATUS Status;
1251  ULONG LocalElementCount, LocalElementSize;
1252 
1253  /* Make sure required parameters are there */
1254  if (!(ElementSize) || !(ElementCount) || ((Elements) && (!*ElementSize)))
1255  {
1256  return STATUS_INVALID_PARAMETER;
1257  }
1258 
1259  /* Set initial count to zero */
1260  *ElementCount = 0;
1261 
1262  /* Do the initial enumeration to figure out the size required */
1263  LocalElementSize = 0;
1264  LocalElementCount = 0;
1265  Status = BiEnumerateElements(BcdHandle,
1266  ObjectHandle,
1267  0,
1271  NULL,
1272  &LocalElementSize,
1273  &LocalElementCount);
1275  {
1276  return Status;
1277  }
1278 
1279  /* Now allocate a buffer large enough to hold them */
1280  LocalElements = BlMmAllocateHeap(LocalElementSize);
1281  if (!LocalElements)
1282  {
1284  }
1285 
1286  /* Zero out the array and do the real enumeration this time around */
1287  RtlZeroMemory(LocalElements, LocalElementSize);
1288  Status = BiEnumerateElements(BcdHandle,
1289  ObjectHandle,
1290  0,
1294  LocalElements,
1295  &LocalElementSize,
1296  &LocalElementCount);
1297  if (!NT_SUCCESS(Status))
1298  {
1299  return Status;
1300  }
1301 
1302  /* Now we know the real count */
1303  *ElementCount = LocalElementCount;
1304 
1305  /* Now unpack the data */
1306  Status = BiConvertBcdElements(LocalElements,
1307  Elements,
1308  ElementSize,
1309  &LocalElementCount);
1310  if (NT_SUCCESS(Status))
1311  {
1312  /* Not all elements may have been converted */
1313  *ElementCount = LocalElementCount;
1314  }
1315 
1316  /* Free the local (unpacked) buffer and return status */
1317  BlMmFreeHeap(LocalElements);
1318  return Status;
1319 }
NTSTATUS BiEnumerateElements(_In_ HANDLE BcdHandle, _In_ HANDLE ObjectHandle, _In_ ULONG RootElementType, _In_ ULONG Flags, _Out_opt_ PBCD_PACKED_ELEMENT Elements, _Inout_ PULONG ElementSize, _Out_ PULONG ElementCount)
Definition: bcd.c:804
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define BCD_ENUMERATE_FLAG_DEEP
Definition: bcd.h:315
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
smooth NULL
Definition: ftsmooth.c:416
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define BCD_ENUMERATE_FLAG_IN_ORDER
Definition: bcd.h:317
Status
Definition: gdiplustypes.h:24
#define BCD_ENUMERATE_FLAG_DEVICES
Definition: bcd.h:316
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS BiConvertBcdElements(_In_ PBCD_PACKED_ELEMENT Elements, _Out_opt_ PBCD_ELEMENT Buffer, _Inout_ PULONG BufferSize, _Inout_ PULONG ElementCount)
Definition: bcd.c:350

Referenced by BmGetOptionList().

◆ BcdOpenObject()

NTSTATUS BcdOpenObject ( _In_ HANDLE  BcdHandle,
_In_ PGUID  ObjectId,
_Out_ PHANDLE  ObjectHandle 
)

Definition at line 506 of file bcd.c.

511 {
513  GUID LocalGuid;
515  HANDLE RootObjectHandle;
516 
517  /* Assume failure */
518  *ObjectHandle = NULL;
519 
520  /* Initialize GUID string */
521  GuidString.Buffer = NULL;
522 
523  /* Open the root "Objects" handle */
524  RootObjectHandle = NULL;
525  Status = BiOpenKey(BcdHandle, L"Objects", &RootObjectHandle);
526  if (!NT_SUCCESS(Status))
527  {
528  goto Quickie;
529  }
530 
531  /* Capture the object ID and convert it into a string */
532  LocalGuid = *ObjectId;
533  Status = RtlStringFromGUID(&LocalGuid, &GuidString);
534  if (!NT_SUCCESS(Status))
535  {
536  goto Quickie;
537  }
538 
539  /* Now open the key containing this object ID */
540  Status = BiOpenKey(RootObjectHandle, GuidString.Buffer, ObjectHandle);
541 
542 Quickie:
543  /* Free the GUID string if we had one allocated */
544  if (GuidString.Buffer)
545  {
547  }
548 
549  /* Close the root handle if it was open */
550  if (RootObjectHandle)
551  {
552  BiCloseKey(RootObjectHandle);
553  }
554 
555  /* Return the final status */
556  return Status;
557 }
static PWSTR GuidString
Definition: apphelp.c:91
VOID BiCloseKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:141
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS BiOpenKey(_In_ HANDLE ParentHandle, _In_ PWCHAR KeyName, _Out_ PHANDLE Handle)
Definition: bootreg.c:186
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
Status
Definition: gdiplustypes.h:24

Referenced by BiEnumerateSubElements(), BmGetEntryDescription(), BmGetOptionList(), and BmPurgeOption().

◆ BcdOpenStoreFromFile()

NTSTATUS BcdOpenStoreFromFile ( _In_ PUNICODE_STRING  FileName,
_In_ PHANDLE  StoreHandle 
)

Definition at line 1322 of file bcd.c.

1326 {
1327  ULONG Length;
1329  NTSTATUS Status;
1331 
1332  /* Assume failure */
1333  LocalHandle = NULL;
1334 
1335  /* Allocate a path descriptor */
1336  Length = FileName->Length + sizeof(*FilePath);
1338  if (!FilePath)
1339  {
1340  return STATUS_NO_MEMORY;
1341  }
1342 
1343  /* Initialize it */
1344  FilePath->Version = 1;
1345  FilePath->PathType = InternalPath;
1346  FilePath->Length = Length;
1347 
1348  /* Copy the name and NULL-terminate it */
1349  RtlCopyMemory(FilePath->Path, FileName->Buffer, Length);
1350  FilePath->Path[Length / sizeof(WCHAR)] = UNICODE_NULL;
1351 
1352  /* Open the BCD */
1354  if (NT_SUCCESS(Status))
1355  {
1356  /* Return the handle on success */
1357  *BcdHandle = LocalHandle;
1358  }
1359 
1360  /* Free the descriptor and return the status */
1362  return Status;
1363 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS BiAddStoreFromFile(_In_ PBL_FILE_PATH_DESCRIPTOR FilePath, _Out_ PHANDLE StoreHandle)
Definition: bcd.c:1143
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
PCWSTR FilePath
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int ULONG
Definition: retypes.h:1
HLOCAL NTAPI LocalHandle(LPCVOID pMem)
Definition: heapmem.c:1588

Referenced by BmOpenDataStore().

◆ BiEnumerateElements()

NTSTATUS BiEnumerateElements ( _In_ HANDLE  BcdHandle,
_In_ HANDLE  ObjectHandle,
_In_ ULONG  RootElementType,
_In_ ULONG  Flags,
_Out_opt_ PBCD_PACKED_ELEMENT  Elements,
_Inout_ PULONG  ElementSize,
_Out_ PULONG  ElementCountNe 
)

Definition at line 804 of file bcd.c.

813 {
814  HANDLE ElementsHandle, ElementHandle;
815  ULONG TotalLength, RegistryElementDataLength, RemainingLength;
817  ULONG i;
818  PVOID ElementData, SubObjectList, RegistryElementData;
819  BcdElementType ElementType;
820  PBCD_PACKED_ELEMENT PreviousElement, ElementsStart;
821  ULONG SubElementCount, SubKeyCount, SubObjectCount, ElementDataLength;
822  PWCHAR ElementName;
823  PWCHAR* SubKeys;
824 
825  /* Assume failure */
826  *ElementCount = 0;
827 
828  /* Initialize all locals that are checked at the end*/
829  SubKeys = NULL;
830  ElementsHandle = NULL;
831  ElementHandle = NULL;
832  ElementData = NULL;
833  RegistryElementData = NULL;
834  PreviousElement = NULL;
835  ElementName = NULL;
836  SubObjectList = NULL;
837  TotalLength = 0;
838  ElementDataLength = 0;
839  SubObjectCount = 0;
840  RemainingLength = 0;
841  ElementsStart = Elements;
842 
843  /* Open the root object key's elements */
844  Status = BiOpenKey(ObjectHandle, L"Elements", &ElementsHandle);
845  if (!NT_SUCCESS(Status))
846  {
847  goto Quickie;
848  }
849 
850  /* Enumerate all elements */
851  Status = BiEnumerateSubKeys(ElementsHandle, &SubKeys, &SubKeyCount);
852  if (!NT_SUCCESS(Status))
853  {
854  goto Quickie;
855  }
856 
857  /* Iterate over each one */
858  for (i = 0; i < SubKeyCount; i++)
859  {
860  /* Open the element */
861  ElementName = SubKeys[i];
862  Status = BiOpenKey(ElementsHandle, ElementName, &ElementHandle);
863  if (!NT_SUCCESS(Status))
864  {
865  EfiPrintf(L"ELEMENT ERROR: %lx\r\n", Status);
866  EfiStall(100000);
867  break;
868  }
869 
870  /* The name of the element is its data type */
871  ElementType.PackedValue = wcstoul(SubKeys[i], NULL, 16);
872  if (!(ElementType.PackedValue) || (ElementType.PackedValue == -1))
873  {
874  EfiPrintf(L"Value invalid\r\n");
875  BiCloseKey(ElementHandle);
876  ElementHandle = NULL;
877  continue;
878  }
879 
880  /* Read the appropriate registry value type for this element */
881  Status = BiGetRegistryValue(ElementHandle,
882  L"Element",
884  ElementType.Format),
885  &RegistryElementData,
886  &RegistryElementDataLength);
887  if (!NT_SUCCESS(Status))
888  {
889  EfiPrintf(L"Element invalid\r\n");
890  break;
891  }
892 
893  /* Now figure out how much space the converted element will need */
894  ElementDataLength = 0;
895  Status = BiConvertRegistryDataToElement(ObjectHandle,
896  RegistryElementData,
897  RegistryElementDataLength,
898  ElementType,
899  NULL,
900  &ElementDataLength);
902  {
903  break;
904  }
905 
906  /* Allocate a buffer big enough for the converted element */
907  ElementData = BlMmAllocateHeap(ElementDataLength);
908  if (!ElementData)
909  {
911  break;
912  }
913 
914  /* And actually convert it this time around */
915  Status = BiConvertRegistryDataToElement(ObjectHandle,
916  RegistryElementData,
917  RegistryElementDataLength,
918  ElementType,
919  ElementData,
920  &ElementDataLength);
921  if (!NT_SUCCESS(Status))
922  {
923  break;
924  }
925 
926  /* Safely add space for the packed element header */
927  Status = RtlULongAdd(TotalLength,
929  &TotalLength);
930  if (!NT_SUCCESS(Status))
931  {
932  break;
933  }
934 
935  /* Safely add space for the data of the element itself */
936  Status = RtlULongAdd(TotalLength, ElementDataLength, &TotalLength);
937  if (!NT_SUCCESS(Status))
938  {
939  break;
940  }
941 
942  /* One more element */
943  ++*ElementCount;
944 
945  /* See how much space we were given */
946  RemainingLength = *ElementSize;
947  if (RemainingLength >= TotalLength)
948  {
949  /* Set the next pointer */
950  Elements->NextEntry = (PBCD_PACKED_ELEMENT)((ULONG_PTR)ElementsStart + TotalLength);
951 
952  /* Fill this one out */
953  Elements->RootType.PackedValue = RootElementType;
954  Elements->Version = 1;
955  Elements->Type = ElementType.PackedValue;
956  Elements->Size = ElementDataLength;
957 
958  /* Add the data */
959  RtlCopyMemory(Elements->Data, ElementData, ElementDataLength);
960  RemainingLength -= TotalLength;
961 
962  /* Move to the next element on the next pass */
963  PreviousElement = Elements;
964  Elements = Elements->NextEntry;
965  }
966  else
967  {
968  /* We're out of space */
969  RemainingLength = 0;
970  }
971 
972  /* Are we enumerating devices, and is this a device? */
974  (ElementType.Format == BCD_TYPE_DEVICE))
975  {
976  /* Yep, so go inside to enumerate it */
977  Status = BiEnumerateSubElements(BcdHandle,
978  ElementData,
979  ElementType.PackedValue,
980  Flags,
981  &Elements,
982  &ElementDataLength,
983  &SubElementCount);
985  {
986  /* Safely add the length of the sub elements */
987  Status = RtlULongAdd(TotalLength,
988  ElementDataLength,
989  &TotalLength);
990  if (!NT_SUCCESS(Status))
991  {
992  break;
993  }
994 
995  /* Add the sub elements to the total */
996  *ElementCount += SubElementCount;
997 
998  /* See if we have enough space*/
999  if (*ElementSize >= TotalLength)
1000  {
1001  /* Were there any subelements? */
1002  if (SubElementCount)
1003  {
1004  /* Update to keep track of these new subelements */
1005  ElementDataLength = *ElementSize - TotalLength;
1006 
1007  /* Link the subelements into the chain */
1008  PreviousElement = Elements;
1009  PreviousElement->NextEntry =
1010  (PBCD_PACKED_ELEMENT)((ULONG_PTR)ElementsStart +
1011  TotalLength);
1012  Elements = PreviousElement->NextEntry;
1013  }
1014  }
1015  else
1016  {
1017  /* We're out of space */
1018  ElementDataLength = 0;
1019  }
1020  }
1021  else if ((Status != STATUS_NOT_FOUND) &&
1023  {
1024  /* Fatal error trying to read the data, so fail */
1025  break;
1026  }
1027  }
1028  else if ((Flags & BCD_ENUMERATE_FLAG_DEEP) &&
1030  {
1031  /* Inherited objects are requested, so allocate a buffer for them */
1032  SubObjectList = BlMmAllocateHeap(ElementDataLength);
1033  if (!SubObjectList)
1034  {
1036  break;
1037  }
1038 
1039  /* Copy the elements into the list. They are arrays of GUIDs */
1040  RtlCopyMemory(SubObjectList, ElementData, ElementDataLength);
1041  SubObjectCount = ElementDataLength / sizeof(GUID);
1042  }
1043 
1044  /* Free our local buffers */
1045  BlMmFreeHeap(ElementData);
1046  BlMmFreeHeap(RegistryElementData);
1047  ElementData = NULL;
1048  RegistryElementData = NULL;
1049 
1050  /* Close the key */
1051  BiCloseKey(ElementHandle);
1052  ElementHandle = NULL;
1053  ElementName = NULL;
1054  }
1055 
1056  /* Did we end up here with a sub object list after successful loop parsing? */
1057  if ((i != 0) && (i == SubKeyCount) && (SubObjectList))
1058  {
1059  /* We will actually enumerate it now, at the end */
1061  SubObjectList,
1062  SubObjectCount,
1063  Flags,
1064  Elements,
1065  &RemainingLength,
1066  &SubElementCount);
1068  {
1069  /* Safely add the length of the sub elements */
1070  Status = RtlULongAdd(TotalLength, RemainingLength, &TotalLength);
1071  if ((NT_SUCCESS(Status)) && (SubElementCount))
1072  {
1073  /* Add the sub elements to the total */
1074  *ElementCount += SubElementCount;
1075 
1076  /* Don't touch PreviousElement anymore */
1077  PreviousElement = NULL;
1078  }
1079  }
1080  }
1081 
1082 Quickie:
1083  /* Free the sub object list, if any */
1084  if (SubObjectList)
1085  {
1086  BlMmFreeHeap(SubObjectList);
1087  }
1088 
1089  /* Free any local element data */
1090  if (ElementData)
1091  {
1092  BlMmFreeHeap(ElementData);
1093  }
1094 
1095  /* Free any local registry data */
1096  if (RegistryElementData)
1097  {
1098  BlMmFreeHeap(RegistryElementData);
1099  }
1100 
1101  /* Close the handle if still opened */
1102  if (ElementHandle)
1103  {
1104  BiCloseKey(ElementHandle);
1105  }
1106 
1107  /* Terminate the last element, if any */
1108  if (PreviousElement)
1109  {
1110  PreviousElement->NextEntry = NULL;
1111  }
1112 
1113  /* Close the root handle if still opened */
1114  if (ElementsHandle)
1115  {
1116  BiCloseKey(ElementsHandle);
1117  }
1118 
1119  /* Set failure code if out of space */
1120  if (*ElementSize < TotalLength)
1121  {
1123  }
1124 
1125  /* Other errors will send a notification error */
1127  {
1128  BiNotifyEnumerationError(ObjectHandle, ElementName, Status);
1129  }
1130 
1131  /* Finally free the subkeys array */
1132  if (SubKeys)
1133  {
1134  BlMmFreeHeap(SubKeys);
1135  }
1136 
1137  /* And return the required, final length and status */
1138  *ElementSize = TotalLength;
1139  return Status;
1140 }
VOID BiCloseKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:141
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS EfiStall(_In_ ULONG StallTime)
Definition: firmware.c:1003
NTSTATUS BiConvertRegistryDataToElement(_In_ HANDLE ObjectHandle, _In_ PVOID Data, _In_ ULONG DataLength, _In_ BcdElementType ElementType, _Out_ PVOID Element, _Out_ PULONG ElementSize)
Definition: bcd.c:52
#define BCD_ENUMERATE_FLAG_DEEP
Definition: bcd.h:315
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_In_ ULONG TotalLength
Definition: usbdlib.h:145
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _BCD_PACKED_ELEMENT * NextEntry
Definition: bcd.h:283
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS BiGetRegistryValue(_In_ HANDLE KeyHandle, _In_ PWCHAR ValueName, _In_ ULONG Type, _Out_ PVOID *Buffer, _Out_ PULONG ValueLength)
Definition: bootreg.c:651
struct _BCD_PACKED_ELEMENT * PBCD_PACKED_ELEMENT
smooth NULL
Definition: ftsmooth.c:416
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
#define STATUS_NOT_FOUND
Definition: shellext.h:72
ULONG Format
Definition: bcd.h:238
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS BiOpenKey(_In_ HANDLE ParentHandle, _In_ PWCHAR KeyName, _Out_ PHANDLE Handle)
Definition: bootreg.c:186
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
struct _GUID GUID
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
NTSTATUS BiEnumerateSubElements(_In_ HANDLE BcdHandle, _In_ PVOID Object, _In_ ULONG ElementType, _In_ ULONG Flags, _Out_opt_ PBCD_PACKED_ELEMENT *Elements, _Inout_ PULONG ElementSize, _Out_ PULONG ElementCount)
Definition: bcd.c:620
NTSTATUS BiEnumerateSubObjectElements(_In_ HANDLE BcdHandle, _Out_ PGUID SubObjectList, _In_ ULONG SubObjectCount, _In_ ULONG Flags, _Out_opt_ PBCD_PACKED_ELEMENT Elements, _Inout_ PULONG ElementSize, _Out_ PULONG ElementCount)
Definition: bcd.c:688
ULONG BiConvertElementFormatToValueType(_In_ ULONG Format)
Definition: bcd.c:31
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define BCD_TYPE_DEVICE
Definition: bcd.h:21
ULONG PackedValue
Definition: bcd.h:234
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
#define BCD_ENUMERATE_FLAG_DEVICES
Definition: bcd.h:316
VOID BiNotifyEnumerationError(_In_ HANDLE ObjectHandle, _In_ PWCHAR ElementName, _In_ NTSTATUS Status)
Definition: bcd.c:17
NTSTATUS BiEnumerateSubKeys(_In_ HANDLE KeyHandle, _Out_ PWCHAR **SubKeyList, _Out_ PULONG SubKeyCount)
Definition: bootreg.c:717
unsigned int ULONG
Definition: retypes.h:1

Referenced by BcdEnumerateAndUnpackElements(), and BiEnumerateSubElements().

◆ BiGetObjectDescription()

NTSTATUS BiGetObjectDescription ( _In_ HANDLE  ObjectHandle,
_Out_ PBCD_OBJECT_DESCRIPTION  Description 
)

Definition at line 1178 of file bcd.c.

1182 {
1183  NTSTATUS Status;
1184  HANDLE DescriptionHandle;
1185  PULONG Data;
1186  ULONG Length;
1187 
1188  /* Initialize locals */
1189  Data = NULL;
1190  DescriptionHandle = NULL;
1191 
1192  /* Open the description key */
1193  Status = BiOpenKey(ObjectHandle, L"Description", &DescriptionHandle);
1194  if (NT_SUCCESS(Status))
1195  {
1196  /* It exists */
1197  Description->Valid = TRUE;
1198 
1199  /* Read the type */
1200  Length = 0;
1201  Status = BiGetRegistryValue(DescriptionHandle,
1202  L"Type",
1203  REG_DWORD,
1204  (PVOID*)&Data,
1205  &Length);
1206  if (NT_SUCCESS(Status))
1207  {
1208  /* Make sure it's the length we expected it to be */
1209  if (Length == sizeof(Data))
1210  {
1211  /* Return the type that is stored there */
1212  Description->Type = *Data;
1213  }
1214  else
1215  {
1216  /* Invalid type value */
1218  }
1219  }
1220  }
1221 
1222  /* Did we have a handle open? */
1223  if (DescriptionHandle)
1224  {
1225  /* Close it */
1226  BiCloseKey(DescriptionHandle);
1227  }
1228 
1229  /* Did we have data allocated? */
1230  if (Data)
1231  {
1232  /* Free it */
1233  BlMmFreeHeap(Data);
1234  }
1235 
1236  /* Return back to caller */
1237  return Status;
1238 }
VOID BiCloseKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:141
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR Description[]
Definition: oid.c:1266
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
NTSTATUS BiGetRegistryValue(_In_ HANDLE KeyHandle, _In_ PWCHAR ValueName, _In_ ULONG Type, _Out_ PVOID *Buffer, _Out_ PULONG ValueLength)
Definition: bootreg.c:651
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:259
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS BiOpenKey(_In_ HANDLE ParentHandle, _In_ PWCHAR KeyName, _Out_ PHANDLE Handle)
Definition: bootreg.c:186
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by BmGetEntryDescription().