2015-09-05 16:05:20 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING.ARM in the top level directory
|
|
|
|
* PROJECT: ReactOS UEFI Boot Library
|
|
|
|
* FILE: boot/environ/lib/misc/bcd.c
|
|
|
|
* PURPOSE: Boot Library BCD Routines
|
|
|
|
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include "bl.h"
|
2015-10-04 21:11:48 +00:00
|
|
|
#include <bcd.h>
|
2015-09-05 16:05:20 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
VOID
|
|
|
|
BiNotifyEnumerationError (
|
|
|
|
_In_ HANDLE ObjectHandle,
|
|
|
|
_In_ PWCHAR ElementName,
|
|
|
|
_In_ NTSTATUS Status
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
)
|
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Stub for now */
|
|
|
|
UNREFERENCED_PARAMETER(ObjectHandle);
|
|
|
|
UNREFERENCED_PARAMETER(ElementName);
|
|
|
|
UNREFERENCED_PARAMETER(Status);
|
2016-01-18 04:18:12 +00:00
|
|
|
EfiPrintf(L"Error in BiNotify: %lx for element %s\r\n", Status, ElementName);
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG
|
2016-01-05 06:09:22 +00:00
|
|
|
BiConvertElementFormatToValueType (
|
|
|
|
_In_ ULONG Format
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
)
|
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Strings and objects are strings */
|
|
|
|
if ((Format == BCD_TYPE_STRING) || (Format == BCD_TYPE_OBJECT))
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
return REG_SZ;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Object lists are arrays of strings */
|
|
|
|
if (Format == BCD_TYPE_OBJECT_LIST)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
return REG_MULTI_SZ;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Everything else is binary */
|
|
|
|
return REG_BINARY;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 18:09:04 +00:00
|
|
|
NTSTATUS
|
2016-01-05 06:09:22 +00:00
|
|
|
BiConvertRegistryDataToElement (
|
|
|
|
_In_ HANDLE ObjectHandle,
|
|
|
|
_In_ PVOID Data,
|
|
|
|
_In_ ULONG DataLength,
|
|
|
|
_In_ BcdElementType ElementType,
|
|
|
|
_Out_ PVOID Element,
|
|
|
|
_Out_ PULONG ElementSize
|
2015-09-09 18:09:04 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2016-01-05 06:09:22 +00:00
|
|
|
ULONG Length, Size, ReturnedLength;
|
|
|
|
PBL_DEVICE_DESCRIPTOR Device;
|
|
|
|
BOOLEAN NullTerminate;
|
|
|
|
PBCD_DEVICE_OPTION BcdDevice, ElementDevice;
|
|
|
|
PWCHAR BcdString, ElementString;
|
|
|
|
PGUID ElementGuid; UNICODE_STRING GuidString;
|
|
|
|
PULONGLONG ElementInteger;
|
|
|
|
PUSHORT ElementWord; PBOOLEAN BcdBoolean;
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Assume failure */
|
|
|
|
ReturnedLength = 0;
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Check what type of format we are dealing with */
|
|
|
|
switch (ElementType.Format)
|
2015-09-09 18:09:04 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Devices -- they are in a binary format */
|
|
|
|
case BCD_TYPE_DEVICE:
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* First, make sure it's at least big enough for an empty descriptor */
|
|
|
|
if (DataLength < FIELD_OFFSET(BCD_DEVICE_OPTION,
|
|
|
|
DeviceDescriptor.Unknown))
|
|
|
|
{
|
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Both the registry and BCD format are the same */
|
|
|
|
BcdDevice = (PBCD_DEVICE_OPTION)Data;
|
|
|
|
ElementDevice = (PBCD_DEVICE_OPTION)Element;
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the device fits in the registry data */
|
|
|
|
Device = &BcdDevice->DeviceDescriptor;
|
|
|
|
Size = Device->Size;
|
|
|
|
if ((Size + sizeof(BcdDevice->AssociatedEntry)) != DataLength)
|
2015-09-09 18:09:04 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
2015-09-09 18:09:04 +00:00
|
|
|
}
|
2016-01-05 06:09:22 +00:00
|
|
|
|
|
|
|
/* Check if this is a locate device */
|
|
|
|
if (Device->DeviceType == LocateDevice)
|
2015-09-09 18:09:04 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
EfiPrintf(L"Locates not yet supported\r\n");
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
2015-09-09 18:09:04 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the caller's buffer can fit the device */
|
|
|
|
ReturnedLength = Size + sizeof(BcdDevice->AssociatedEntry);
|
|
|
|
if (ReturnedLength > *ElementSize)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* It'll fit -- copy it in */
|
|
|
|
RtlCopyMemory(&ElementDevice->DeviceDescriptor, Device, Size);
|
|
|
|
ElementDevice->AssociatedEntry = BcdDevice->AssociatedEntry;
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Strings -- they are stored as is */
|
|
|
|
case BCD_TYPE_STRING:
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the string isn't empty or misaligned */
|
|
|
|
if (!(DataLength) || (DataLength & 1))
|
|
|
|
{
|
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Both the registry and BCD format are the same */
|
|
|
|
BcdString = (PWCHAR)Data;
|
|
|
|
ElementString = (PWCHAR)Element;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* We'll need as much data as the string has to offer */
|
|
|
|
ReturnedLength = DataLength;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* If the string isn't NULL-terminated, do it now */
|
|
|
|
NullTerminate = FALSE;
|
|
|
|
if (BcdString[(DataLength / sizeof(WCHAR)) - 1] != UNICODE_NULL)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
ReturnedLength += sizeof(UNICODE_NULL);
|
|
|
|
NullTerminate = TRUE;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Will we fit in the caller's buffer? */
|
|
|
|
if (ReturnedLength > *ElementSize)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Yep -- copy it in, and NULL-terminate if needed */
|
|
|
|
RtlCopyMemory(Element, Data, DataLength);
|
|
|
|
if (NullTerminate)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
ElementString[DataLength / sizeof(WCHAR)] = UNICODE_NULL;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Objects -- they are stored as GUID Strings */
|
|
|
|
case BCD_TYPE_OBJECT:
|
|
|
|
|
|
|
|
/* Registry data is a string, BCD data is a GUID */
|
|
|
|
BcdString = (PWCHAR)Data;
|
|
|
|
ElementGuid = (PGUID)Element;
|
|
|
|
|
|
|
|
/* We need a GUID-sized buffer, does the caller have one? */
|
|
|
|
ReturnedLength = sizeof(*ElementGuid);
|
|
|
|
if (*ElementSize < ReturnedLength)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
2016-01-05 06:09:22 +00:00
|
|
|
|
|
|
|
/* Yep, copy the GUID */
|
|
|
|
RtlInitUnicodeString(&GuidString, BcdString);
|
|
|
|
Status = RtlGUIDFromString(&GuidString, ElementGuid);
|
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Object Lists -- they are stored as arrays of GUID strings */
|
|
|
|
case BCD_TYPE_OBJECT_LIST:
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Assume an empty list*/
|
|
|
|
ReturnedLength = 0;
|
|
|
|
Length = 0;
|
|
|
|
Status = STATUS_SUCCESS;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Registry data is an array of strings, BCD data is array of GUIDs */
|
|
|
|
BcdString = (PWCHAR)Data;
|
|
|
|
ElementGuid = (PGUID)Element;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Loop as long as the array still has strings */
|
|
|
|
while (*BcdString)
|
|
|
|
{
|
|
|
|
/* Don't read beyond the registry data */
|
|
|
|
if (Length >= DataLength)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* One more GUID -- does the caller have space? */
|
|
|
|
ReturnedLength += sizeof(GUID);
|
|
|
|
if (ReturnedLength <= *ElementSize)
|
|
|
|
{
|
|
|
|
/* Convert and add it in */
|
|
|
|
RtlInitUnicodeString(&GuidString, BcdString);
|
|
|
|
Status = RtlGUIDFromString(&GuidString, ElementGuid);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move to the next GUID in the caller's buffer */
|
|
|
|
ElementGuid++;
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Move to the next string in the registry array */
|
|
|
|
Size = (wcslen(BcdString) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
|
|
|
|
Length += Size;
|
|
|
|
BcdString = (PWCHAR)((ULONG_PTR)BcdString + Length);
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Check if we failed anywhere */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Check if we consumed more space than we have */
|
|
|
|
if (ReturnedLength > *ElementSize)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* All good here */
|
|
|
|
break;
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Integer -- stored as binary */
|
|
|
|
case BCD_TYPE_INTEGER:
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* BCD data is a ULONGLONG, registry data is 8 bytes binary */
|
|
|
|
ElementInteger = (PULONGLONG)Element;
|
|
|
|
ReturnedLength = sizeof(*ElementInteger);
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the registry data makes sense */
|
|
|
|
if (DataLength > ReturnedLength)
|
|
|
|
{
|
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
}
|
2015-09-09 18:09:04 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the caller has space */
|
|
|
|
if (*ElementSize < ReturnedLength)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Write the integer result */
|
|
|
|
*ElementInteger = 0;
|
|
|
|
RtlCopyMemory(ElementInteger, Data, DataLength);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Boolean -- stored as binary */
|
|
|
|
case BCD_TYPE_BOOLEAN:
|
2015-09-05 16:05:20 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* BCD data is a BOOLEAN, registry data is 2 bytes binary */
|
|
|
|
ElementWord = (PUSHORT)Element;
|
|
|
|
BcdBoolean = (PBOOLEAN)Data;
|
|
|
|
ReturnedLength = sizeof(ElementWord);
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the registry data makes sense */
|
|
|
|
if (DataLength != sizeof(*BcdBoolean))
|
|
|
|
{
|
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the caller has space */
|
|
|
|
if (*ElementSize < ReturnedLength)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Write the boolean result */
|
|
|
|
*ElementWord = 0;
|
|
|
|
*ElementWord = *BcdBoolean != 0;
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Integer list --stored as binary */
|
|
|
|
case BCD_TYPE_INTEGER_LIST:
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* BCD Data is n ULONGLONGs, registry data is n*8 bytes binary */
|
|
|
|
ReturnedLength = DataLength;
|
|
|
|
if (!(DataLength) || (DataLength & 7))
|
|
|
|
{
|
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the caller has space */
|
|
|
|
if (*ElementSize < ReturnedLength)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Write the integer list result */
|
|
|
|
RtlCopyMemory(Element, Data, DataLength);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Arbitrary data */
|
|
|
|
default:
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Registry data is copied binary as-is */
|
|
|
|
ReturnedLength = DataLength;
|
|
|
|
|
|
|
|
/* Make sure it's not empty */
|
|
|
|
if (!DataLength)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
2015-09-05 16:05:20 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Make sure the caller has space */
|
|
|
|
if (*ElementSize < ReturnedLength)
|
|
|
|
{
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
break;
|
|
|
|
}
|
2015-09-05 16:05:20 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Write the result */
|
|
|
|
RtlCopyMemory(Element, Data, DataLength);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
2015-09-05 16:05:20 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* If we got here due to success or space issues, write the size */
|
|
|
|
if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_TOO_SMALL))
|
|
|
|
{
|
|
|
|
*ElementSize = ReturnedLength;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* All done, return our conversion result */
|
|
|
|
return Status;
|
2015-09-05 16:05:20 +00:00
|
|
|
}
|
|
|
|
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
NTSTATUS
|
2016-01-05 06:09:22 +00:00
|
|
|
BiConvertBcdElements (
|
|
|
|
_In_ PBCD_PACKED_ELEMENT Elements,
|
|
|
|
_Out_opt_ PBCD_ELEMENT Buffer,
|
|
|
|
_Inout_ PULONG BufferSize,
|
|
|
|
_Inout_ PULONG ElementCount
|
2015-09-05 16:05:20 +00:00
|
|
|
)
|
|
|
|
{
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
NTSTATUS Status;
|
2016-01-05 06:09:22 +00:00
|
|
|
ULONG ElementSize, AlignedElementSize, AlignedDataSize;
|
|
|
|
PBCD_ELEMENT_HEADER Header;
|
|
|
|
PVOID Data;
|
|
|
|
BOOLEAN Exists;
|
|
|
|
ULONG i, j, Count;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Local variable to keep track of objects */
|
|
|
|
Count = 0;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely compute the element bytes needed */
|
|
|
|
Status = RtlULongMult(*ElementCount, sizeof(BCD_ELEMENT), &ElementSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely align the element size */
|
|
|
|
Status = RtlULongAdd(ElementSize,
|
|
|
|
sizeof(ULONG) - 1,
|
|
|
|
&AlignedElementSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
AlignedElementSize = ALIGN_DOWN(AlignedElementSize, ULONG);
|
2015-09-05 16:05:20 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Do a safe version of Add2Ptr to figure out where the headers will start */
|
|
|
|
Status = RtlULongPtrAdd((ULONG_PTR)Buffer,
|
|
|
|
AlignedElementSize,
|
|
|
|
(PULONG_PTR)&Header);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2015-09-05 16:05:20 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
return Status;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely compute the header bytes needed */
|
|
|
|
Status = RtlULongMult(*ElementCount,
|
|
|
|
sizeof(BCD_ELEMENT_HEADER),
|
|
|
|
&ElementSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely align the header size */
|
|
|
|
Status = RtlULongAdd(ElementSize,
|
|
|
|
AlignedElementSize + sizeof(ULONG) - 1,
|
|
|
|
&AlignedElementSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
AlignedElementSize = ALIGN_DOWN(AlignedElementSize, ULONG);
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Do a safe version of Add2Ptr */
|
|
|
|
Status = RtlULongPtrAdd((ULONG_PTR)Buffer,
|
|
|
|
AlignedElementSize,
|
|
|
|
(PULONG_PTR)&Data);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Iterate over every element */
|
|
|
|
for (i = 0; i < *ElementCount; i++)
|
|
|
|
{
|
|
|
|
/* Safely align the element size */
|
|
|
|
Status = RtlULongAdd(Elements->Size,
|
|
|
|
sizeof(ULONG) - 1,
|
|
|
|
&AlignedDataSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
2016-01-05 06:09:22 +00:00
|
|
|
AlignedDataSize = ALIGN_DOWN(AlignedDataSize, ULONG);
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely add the size of this data element */
|
|
|
|
Status = RtlULongAdd(AlignedElementSize,
|
|
|
|
AlignedDataSize,
|
|
|
|
&AlignedElementSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
break;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Do we have enough space left? */
|
|
|
|
if (*BufferSize >= AlignedElementSize)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Check if our root is an inherited object */
|
|
|
|
Exists = FALSE;
|
|
|
|
if (Elements->RootType.PackedValue == BcdLibraryObjectList_InheritedObjects)
|
|
|
|
{
|
|
|
|
/* Yes, scan for us in the current buffer */
|
|
|
|
for (j = 0; j < Count; j++)
|
|
|
|
{
|
|
|
|
/* Do we already exist? */
|
|
|
|
while (Buffer[j].Header->Type == Elements->RootType.PackedValue)
|
|
|
|
{
|
|
|
|
/* Yep */
|
|
|
|
Exists = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Have we already found ourselves? */
|
|
|
|
if (!Exists)
|
|
|
|
{
|
|
|
|
/* Nope, one more entry */
|
|
|
|
++Count;
|
|
|
|
|
|
|
|
/* Write out the unpacked object */
|
|
|
|
Buffer->Body = Data;
|
|
|
|
Buffer->Header = Header;
|
|
|
|
|
|
|
|
/* Fill out its header */
|
|
|
|
Header->Size = Elements->Size;
|
|
|
|
Header->Type = Elements->Type;
|
|
|
|
Header->Version = Elements->Version;
|
|
|
|
|
|
|
|
/* And copy the data */
|
|
|
|
RtlCopyMemory(Data, Elements->Data, Header->Size);
|
|
|
|
|
|
|
|
/* Move to the next unpacked object and header */
|
|
|
|
++Buffer;
|
|
|
|
++Header;
|
|
|
|
|
|
|
|
/* Move to the next data entry */
|
|
|
|
Data = (PVOID)((ULONG_PTR)Data + AlignedDataSize);
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Nope, set failure code, but keep going so we can return count */
|
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
2016-01-05 06:09:22 +00:00
|
|
|
|
|
|
|
/* Move to the next element entry */
|
|
|
|
Elements = Elements->NextEntry;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Return the new final buffer size and count */
|
|
|
|
*BufferSize = AlignedElementSize;
|
|
|
|
*ElementCount = Count;
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
BcdOpenObject (
|
|
|
|
_In_ HANDLE BcdHandle,
|
|
|
|
_In_ PGUID ObjectId,
|
|
|
|
_Out_ PHANDLE ObjectHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
GUID LocalGuid;
|
|
|
|
UNICODE_STRING GuidString;
|
|
|
|
HANDLE RootObjectHandle;
|
|
|
|
|
|
|
|
/* Assume failure */
|
|
|
|
*ObjectHandle = NULL;
|
|
|
|
|
|
|
|
/* Initialize GUID string */
|
|
|
|
GuidString.Buffer = NULL;
|
|
|
|
|
|
|
|
/* Open the root "Objects" handle */
|
|
|
|
RootObjectHandle = NULL;
|
|
|
|
Status = BiOpenKey(BcdHandle, L"Objects", &RootObjectHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Capture the object ID and convert it into a string */
|
|
|
|
LocalGuid = *ObjectId;
|
|
|
|
Status = RtlStringFromGUID(&LocalGuid, &GuidString);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
goto Quickie;
|
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Now open the key containing this object ID */
|
|
|
|
Status = BiOpenKey(RootObjectHandle, GuidString.Buffer, ObjectHandle);
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|
|
|
|
Quickie:
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Free the GUID string if we had one allocated */
|
|
|
|
if (GuidString.Buffer)
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
RtlFreeUnicodeString(&GuidString);
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Close the root handle if it was open */
|
|
|
|
if (RootObjectHandle)
|
|
|
|
{
|
|
|
|
BiCloseKey(RootObjectHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the final status */
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2016-01-17 21:48:00 +00:00
|
|
|
NTSTATUS
|
|
|
|
BcdDeleteElement (
|
|
|
|
_In_ HANDLE ObjectHandle,
|
|
|
|
_In_ ULONG Type
|
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE ElementsHandle, ElementHandle;
|
|
|
|
WCHAR TypeString[22];
|
|
|
|
|
|
|
|
/* Open the elements key */
|
|
|
|
Status = BiOpenKey(ObjectHandle, L"Elements", &ElementsHandle);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Convert the element ID into a string */
|
|
|
|
if (!_ultow(Type, TypeString, 16))
|
|
|
|
{
|
|
|
|
/* Failed to do so */
|
|
|
|
Status = STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Open the element specifically */
|
|
|
|
Status = BiOpenKey(ElementHandle, TypeString, &ElementHandle);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Delete it */
|
|
|
|
Status = BiDeleteKey(ElementHandle);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* No point in closing the handle anymore */
|
|
|
|
ElementHandle = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The element doesn't exist */
|
|
|
|
Status = STATUS_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we should close the key */
|
|
|
|
if (ElementHandle)
|
|
|
|
{
|
|
|
|
/* Do it */
|
|
|
|
BiCloseKey(ElementHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we should close the elements handle */
|
|
|
|
if (ElementsHandle)
|
|
|
|
{
|
|
|
|
/* Do it */
|
|
|
|
BiCloseKey(ElementsHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return whatever the result was */
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
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
|
2015-10-05 07:25:27 +00:00
|
|
|
)
|
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PBCD_PACKED_ELEMENT Element;
|
|
|
|
HANDLE ObjectHandle;
|
|
|
|
ULONG ParsedElements, RequiredSize;
|
|
|
|
|
|
|
|
/* Assume empty */
|
|
|
|
*ElementCount = 0;
|
|
|
|
RequiredSize = 0;
|
|
|
|
ParsedElements = 0;
|
|
|
|
|
|
|
|
/* Open the object */
|
|
|
|
Status = BcdOpenObject(BcdHandle, Object, &ObjectHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Read the first entry, and the size available */
|
|
|
|
Element = *Elements;
|
|
|
|
RequiredSize = *ElementSize;
|
|
|
|
|
|
|
|
/* Enumerate the object into the element array */
|
|
|
|
Status = BiEnumerateElements(BcdHandle,
|
|
|
|
ObjectHandle,
|
|
|
|
ElementType,
|
|
|
|
Flags,
|
|
|
|
Element,
|
|
|
|
&RequiredSize,
|
|
|
|
&ParsedElements);
|
|
|
|
|
|
|
|
/* Close the handle and bail out if we couldn't enumerate */
|
|
|
|
BiCloseKey(ObjectHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the and subelements were present */
|
|
|
|
if (ParsedElements)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Keep going until the last one */
|
|
|
|
while (Element->NextEntry)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
Element = Element->NextEntry;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
2016-01-05 06:09:22 +00:00
|
|
|
|
|
|
|
/* Set the new buffer location to the last element */
|
|
|
|
*Elements = Element;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
Quickie:
|
|
|
|
/* Return the number of sub-elements and their size */
|
|
|
|
*ElementCount = ParsedElements;
|
|
|
|
*ElementSize = RequiredSize;
|
|
|
|
return Status;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2016-01-05 06:09:22 +00:00
|
|
|
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
|
2015-10-05 07:25:27 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2016-01-05 06:09:22 +00:00
|
|
|
ULONG SubElementCount, TotalSize, RequiredSize, CurrentSize, i;
|
|
|
|
PBCD_PACKED_ELEMENT PreviousElement;
|
|
|
|
|
|
|
|
/* Assume empty list */
|
|
|
|
*ElementCount = 0;
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
/* Initialize variables */
|
|
|
|
TotalSize = 0;
|
|
|
|
PreviousElement = NULL;
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Set the currently remaining size based on caller's input */
|
|
|
|
CurrentSize = *ElementSize;
|
|
|
|
|
|
|
|
/* Iterate over every subje object */
|
|
|
|
for (i = 0; i < SubObjectCount; i++)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Set the currently remaining buffer space */
|
|
|
|
RequiredSize = CurrentSize;
|
|
|
|
|
|
|
|
/* Enumerate the inherited sub elements */
|
|
|
|
Status = BiEnumerateSubElements(BcdHandle,
|
|
|
|
&SubObjectList[i],
|
|
|
|
BcdLibraryObjectList_InheritedObjects,
|
|
|
|
Flags,
|
|
|
|
&Elements,
|
|
|
|
&RequiredSize,
|
|
|
|
&SubElementCount);
|
|
|
|
if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_TOO_SMALL))
|
|
|
|
{
|
|
|
|
/* Safely add the length of the sub elements */
|
|
|
|
Status = RtlULongAdd(TotalSize, RequiredSize, &TotalSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the sub elements to the total */
|
|
|
|
*ElementCount += SubElementCount;
|
|
|
|
|
|
|
|
/* See if we have enough space*/
|
|
|
|
if (*ElementSize >= TotalSize)
|
|
|
|
{
|
|
|
|
/* Were there any subelements? */
|
|
|
|
if (SubElementCount)
|
|
|
|
{
|
|
|
|
/* Update to keep track of these new subelements */
|
|
|
|
CurrentSize = *ElementSize - TotalSize;
|
|
|
|
|
|
|
|
/* Link the subelements into the chain */
|
|
|
|
PreviousElement = Elements;
|
|
|
|
PreviousElement->NextEntry =
|
|
|
|
(PBCD_PACKED_ELEMENT)((ULONG_PTR)Elements + TotalSize);
|
|
|
|
Elements = PreviousElement->NextEntry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We're out of space */
|
|
|
|
CurrentSize = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((Status != STATUS_NOT_FOUND) &&
|
|
|
|
(Status != STATUS_OBJECT_NAME_NOT_FOUND))
|
|
|
|
{
|
|
|
|
/* Some other fatal error, break out */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The sub element was not found, print a warning but keep going */
|
|
|
|
BlStatusPrint(L"Ignoring missing BCD inherit object: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
|
|
|
(&SubObjectList[i])->Data1,
|
|
|
|
(&SubObjectList[i])->Data2,
|
|
|
|
(&SubObjectList[i])->Data3,
|
|
|
|
(&SubObjectList[i])->Data4[0],
|
|
|
|
(&SubObjectList[i])->Data4[1],
|
|
|
|
(&SubObjectList[i])->Data4[2],
|
|
|
|
(&SubObjectList[i])->Data4[3],
|
|
|
|
(&SubObjectList[i])->Data4[4],
|
|
|
|
(&SubObjectList[i])->Data4[5],
|
|
|
|
(&SubObjectList[i])->Data4[6],
|
|
|
|
(&SubObjectList[i])->Data4[7],
|
|
|
|
(&SubObjectList[i])->Data4[8]);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Terminate the last element, if one was left */
|
|
|
|
if (PreviousElement)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
PreviousElement->NextEntry = NULL;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Set failure code if we ran out of space */
|
|
|
|
if (*ElementSize < TotalSize)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Return final length and status */
|
|
|
|
*ElementSize = TotalSize;
|
2015-10-05 07:25:27 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
NTSTATUS
|
2016-01-05 06:09:22 +00:00
|
|
|
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
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
)
|
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
HANDLE ElementsHandle, ElementHandle;
|
|
|
|
ULONG TotalLength, RegistryElementDataLength, RemainingLength;
|
2015-10-05 07:25:27 +00:00
|
|
|
NTSTATUS Status;
|
2016-01-05 06:09:22 +00:00
|
|
|
ULONG i;
|
|
|
|
PVOID ElementData, SubObjectList, RegistryElementData;
|
|
|
|
BcdElementType ElementType;
|
2016-01-18 04:18:12 +00:00
|
|
|
PBCD_PACKED_ELEMENT PreviousElement, ElementsStart;
|
2016-01-05 06:09:22 +00:00
|
|
|
ULONG SubElementCount, SubKeyCount, SubObjectCount, ElementDataLength;
|
|
|
|
PWCHAR ElementName;
|
|
|
|
PWCHAR* SubKeys;
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Assume failure */
|
|
|
|
*ElementCount = 0;
|
|
|
|
|
|
|
|
/* Initialize all locals that are checked at the end*/
|
|
|
|
SubKeys = NULL;
|
|
|
|
ElementsHandle = NULL;
|
|
|
|
ElementHandle = NULL;
|
|
|
|
ElementData = NULL;
|
|
|
|
RegistryElementData = NULL;
|
|
|
|
PreviousElement = NULL;
|
|
|
|
ElementName = NULL;
|
|
|
|
SubObjectList = NULL;
|
|
|
|
TotalLength = 0;
|
|
|
|
ElementDataLength = 0;
|
|
|
|
SubObjectCount = 0;
|
|
|
|
RemainingLength = 0;
|
2016-01-18 04:18:12 +00:00
|
|
|
ElementsStart = Elements;
|
2016-01-05 06:09:22 +00:00
|
|
|
|
|
|
|
/* Open the root object key's elements */
|
|
|
|
Status = BiOpenKey(ObjectHandle, L"Elements", &ElementsHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
goto Quickie;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Enumerate all elements */
|
|
|
|
Status = BiEnumerateSubKeys(ElementsHandle, &SubKeys, &SubKeyCount);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Iterate over each one */
|
|
|
|
for (i = 0; i < SubKeyCount; i++)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Open the element */
|
|
|
|
ElementName = SubKeys[i];
|
|
|
|
Status = BiOpenKey(ElementsHandle, ElementName, &ElementHandle);
|
2015-10-05 07:25:27 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2016-01-18 04:18:12 +00:00
|
|
|
EfiPrintf(L"ELEMENT ERROR: %lx\r\n", Status);
|
|
|
|
EfiStall(100000);
|
2016-01-05 06:09:22 +00:00
|
|
|
break;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* The name of the element is its data type */
|
|
|
|
ElementType.PackedValue = wcstoul(SubKeys[i], NULL, 16);
|
|
|
|
if (!(ElementType.PackedValue) || (ElementType.PackedValue == -1))
|
|
|
|
{
|
2016-01-18 04:18:12 +00:00
|
|
|
EfiPrintf(L"Value invalid\r\n");
|
2016-01-05 06:09:22 +00:00
|
|
|
BiCloseKey(ElementHandle);
|
|
|
|
ElementHandle = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Read the appropriate registry value type for this element */
|
|
|
|
Status = BiGetRegistryValue(ElementHandle,
|
|
|
|
L"Element",
|
|
|
|
BiConvertElementFormatToValueType(
|
|
|
|
ElementType.Format),
|
|
|
|
&RegistryElementData,
|
|
|
|
&RegistryElementDataLength);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2016-01-18 04:18:12 +00:00
|
|
|
EfiPrintf(L"Element invalid\r\n");
|
2016-01-05 06:09:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Now figure out how much space the converted element will need */
|
|
|
|
ElementDataLength = 0;
|
|
|
|
Status = BiConvertRegistryDataToElement(ObjectHandle,
|
|
|
|
RegistryElementData,
|
|
|
|
RegistryElementDataLength,
|
|
|
|
ElementType,
|
|
|
|
NULL,
|
|
|
|
&ElementDataLength);
|
|
|
|
if (Status != STATUS_BUFFER_TOO_SMALL)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Allocate a buffer big enough for the converted element */
|
|
|
|
ElementData = BlMmAllocateHeap(ElementDataLength);
|
|
|
|
if (!ElementData)
|
|
|
|
{
|
|
|
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
break;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* And actually convert it this time around */
|
|
|
|
Status = BiConvertRegistryDataToElement(ObjectHandle,
|
|
|
|
RegistryElementData,
|
|
|
|
RegistryElementDataLength,
|
|
|
|
ElementType,
|
|
|
|
ElementData,
|
|
|
|
&ElementDataLength);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely add space for the packed element header */
|
|
|
|
Status = RtlULongAdd(TotalLength,
|
|
|
|
FIELD_OFFSET(BCD_PACKED_ELEMENT, Data),
|
|
|
|
&TotalLength);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Safely add space for the data of the element itself */
|
|
|
|
Status = RtlULongAdd(TotalLength, ElementDataLength, &TotalLength);
|
2015-10-05 07:25:27 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
break;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* One more element */
|
|
|
|
++*ElementCount;
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* See how much space we were given */
|
|
|
|
RemainingLength = *ElementSize;
|
|
|
|
if (RemainingLength >= TotalLength)
|
|
|
|
{
|
|
|
|
/* Set the next pointer */
|
2016-01-18 04:18:12 +00:00
|
|
|
Elements->NextEntry = (PBCD_PACKED_ELEMENT)((ULONG_PTR)ElementsStart + TotalLength);
|
2016-01-05 06:09:22 +00:00
|
|
|
|
|
|
|
/* Fill this one out */
|
|
|
|
Elements->RootType.PackedValue = RootElementType;
|
|
|
|
Elements->Version = 1;
|
|
|
|
Elements->Type = ElementType.PackedValue;
|
|
|
|
Elements->Size = ElementDataLength;
|
|
|
|
|
|
|
|
/* Add the data */
|
|
|
|
RtlCopyMemory(Elements->Data, ElementData, ElementDataLength);
|
|
|
|
RemainingLength -= TotalLength;
|
|
|
|
|
|
|
|
/* Move to the next element on the next pass */
|
|
|
|
PreviousElement = Elements;
|
|
|
|
Elements = Elements->NextEntry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We're out of space */
|
|
|
|
RemainingLength = 0;
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Are we enumerating devices, and is this a device? */
|
|
|
|
if ((Flags & BCD_ENUMERATE_FLAG_DEVICES) &&
|
|
|
|
(ElementType.Format == BCD_TYPE_DEVICE))
|
|
|
|
{
|
|
|
|
/* Yep, so go inside to enumerate it */
|
|
|
|
Status = BiEnumerateSubElements(BcdHandle,
|
|
|
|
ElementData,
|
|
|
|
ElementType.PackedValue,
|
|
|
|
Flags,
|
|
|
|
&Elements,
|
|
|
|
&ElementDataLength,
|
|
|
|
&SubElementCount);
|
|
|
|
if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_TOO_SMALL))
|
|
|
|
{
|
|
|
|
/* Safely add the length of the sub elements */
|
|
|
|
Status = RtlULongAdd(TotalLength,
|
|
|
|
ElementDataLength,
|
|
|
|
&TotalLength);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the sub elements to the total */
|
|
|
|
*ElementCount += SubElementCount;
|
|
|
|
|
|
|
|
/* See if we have enough space*/
|
|
|
|
if (*ElementSize >= TotalLength)
|
|
|
|
{
|
|
|
|
/* Were there any subelements? */
|
|
|
|
if (SubElementCount)
|
|
|
|
{
|
|
|
|
/* Update to keep track of these new subelements */
|
|
|
|
ElementDataLength = *ElementSize - TotalLength;
|
|
|
|
|
|
|
|
/* Link the subelements into the chain */
|
|
|
|
PreviousElement = Elements;
|
|
|
|
PreviousElement->NextEntry =
|
2016-01-18 04:18:12 +00:00
|
|
|
(PBCD_PACKED_ELEMENT)((ULONG_PTR)ElementsStart +
|
2016-01-05 06:09:22 +00:00
|
|
|
TotalLength);
|
|
|
|
Elements = PreviousElement->NextEntry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We're out of space */
|
|
|
|
ElementDataLength = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((Status != STATUS_NOT_FOUND) &&
|
|
|
|
(Status != STATUS_OBJECT_NAME_NOT_FOUND))
|
|
|
|
{
|
|
|
|
/* Fatal error trying to read the data, so fail */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((Flags & BCD_ENUMERATE_FLAG_DEEP) &&
|
|
|
|
(ElementType.PackedValue == BcdLibraryObjectList_InheritedObjects))
|
|
|
|
{
|
|
|
|
/* Inherited objects are requsted, so allocate a buffer for them */
|
|
|
|
SubObjectList = BlMmAllocateHeap(ElementDataLength);
|
|
|
|
if (!SubObjectList)
|
|
|
|
{
|
|
|
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the elements into the list. They are arrays of GUIDs */
|
|
|
|
RtlCopyMemory(SubObjectList, ElementData, ElementDataLength);
|
|
|
|
SubObjectCount = ElementDataLength / sizeof(GUID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free our local buffers */
|
|
|
|
BlMmFreeHeap(ElementData);
|
|
|
|
BlMmFreeHeap(RegistryElementData);
|
|
|
|
ElementData = NULL;
|
|
|
|
RegistryElementData = NULL;
|
|
|
|
|
|
|
|
/* Close the key */
|
|
|
|
BiCloseKey(ElementHandle);
|
|
|
|
ElementHandle = NULL;
|
|
|
|
ElementName = NULL;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Did we end up here with a sub object list after successful loop parsing? */
|
|
|
|
if ((i != 0) && (i == SubKeyCount) && (SubObjectList))
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
/* We will actually enumerate it now, at the end */
|
|
|
|
Status = BiEnumerateSubObjectElements(BcdHandle,
|
|
|
|
SubObjectList,
|
|
|
|
SubObjectCount,
|
|
|
|
Flags,
|
|
|
|
Elements,
|
|
|
|
&RemainingLength,
|
|
|
|
&SubElementCount);
|
|
|
|
if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_TOO_SMALL))
|
|
|
|
{
|
|
|
|
/* Safely add the length of the sub elements */
|
|
|
|
Status = RtlULongAdd(TotalLength, RemainingLength, &TotalLength);
|
|
|
|
if ((NT_SUCCESS(Status)) && (SubElementCount))
|
|
|
|
{
|
|
|
|
/* Add the sub elements to the total */
|
|
|
|
*ElementCount += SubElementCount;
|
|
|
|
|
|
|
|
/* Don't touch PreviousElement anymore */
|
|
|
|
PreviousElement = NULL;
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
Quickie:
|
|
|
|
/* Free the sub object list, if any */
|
|
|
|
if (SubObjectList)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
BlMmFreeHeap(SubObjectList);
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Free any local element data */
|
|
|
|
if (ElementData)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
BlMmFreeHeap(ElementData);
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Free any local registry data */
|
|
|
|
if (RegistryElementData)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
BlMmFreeHeap(RegistryElementData);
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Close the handle if still opened */
|
|
|
|
if (ElementHandle)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
BiCloseKey(ElementHandle);
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Terminate the last element, if any */
|
|
|
|
if (PreviousElement)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
PreviousElement->NextEntry = NULL;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Close the root handle if still opened */
|
|
|
|
if (ElementsHandle)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
BiCloseKey(ElementsHandle);
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Set failure code if out of space */
|
|
|
|
if (*ElementSize < TotalLength)
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
Status = STATUS_BUFFER_TOO_SMALL;
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Other errors will send a notification error */
|
|
|
|
if (!(NT_SUCCESS(Status)) && (Status != STATUS_BUFFER_TOO_SMALL))
|
2015-10-05 07:25:27 +00:00
|
|
|
{
|
2016-01-05 06:09:22 +00:00
|
|
|
BiNotifyEnumerationError(ObjectHandle, ElementName, Status);
|
|
|
|
}
|
2015-10-05 07:25:27 +00:00
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* Finally free the subkeys array */
|
|
|
|
if (SubKeys)
|
|
|
|
{
|
|
|
|
BlMmFreeHeap(SubKeys);
|
2015-10-05 07:25:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
/* And return the required, final length and status */
|
|
|
|
*ElementSize = TotalLength;
|
2015-10-05 07:25:27 +00:00
|
|
|
return Status;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
BiAddStoreFromFile (
|
|
|
|
_In_ PBL_FILE_PATH_DESCRIPTOR FilePath,
|
|
|
|
_Out_ PHANDLE StoreHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE HiveHandle, KeyHandle;
|
|
|
|
|
|
|
|
/* Load the specified hive */
|
|
|
|
Status = BiLoadHive(FilePath, &HiveHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open the description key to make sure this is really a BCD */
|
|
|
|
Status = BiOpenKey(HiveHandle, L"Description", &KeyHandle);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* It is -- close the key as we don't need it */
|
|
|
|
BiCloseKey(KeyHandle);
|
|
|
|
*StoreHandle = HiveHandle;
|
2015-09-05 16:05:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
/* Failure, drop a reference on the hive and close the key */
|
|
|
|
BiDereferenceHive(HiveHandle);
|
|
|
|
BiCloseKey(HiveHandle);
|
2015-09-05 16:05:20 +00:00
|
|
|
}
|
|
|
|
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
/* Return the status */
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2016-01-18 16:54:44 +00:00
|
|
|
NTSTATUS
|
|
|
|
BiGetObjectDescription (
|
|
|
|
_In_ HANDLE ObjectHandle,
|
|
|
|
_Out_ PBCD_OBJECT_DESCRIPTION Description
|
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE DescriptionHandle;
|
|
|
|
PULONG Data;
|
|
|
|
ULONG Length;
|
|
|
|
|
|
|
|
/* Initialize locals */
|
|
|
|
Data = NULL;
|
|
|
|
DescriptionHandle = NULL;
|
|
|
|
|
|
|
|
/* Open the description key */
|
|
|
|
Status = BiOpenKey(ObjectHandle, L"Description", &DescriptionHandle);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* It exists */
|
|
|
|
Description->Valid = TRUE;
|
|
|
|
|
|
|
|
/* Read the type */
|
|
|
|
Length = 0;
|
|
|
|
Status = BiGetRegistryValue(DescriptionHandle,
|
|
|
|
L"Type",
|
|
|
|
REG_DWORD,
|
|
|
|
(PVOID*)&Data,
|
|
|
|
&Length);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Make sure it's the length we expected it to be */
|
|
|
|
if (Length == sizeof(Data))
|
|
|
|
{
|
|
|
|
/* Return the type that is stored there */
|
|
|
|
Description->Type = *Data;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Invalid type value */
|
|
|
|
Status = STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Did we have a handle open? */
|
|
|
|
if (DescriptionHandle)
|
|
|
|
{
|
|
|
|
/* Close it */
|
|
|
|
BiCloseKey(DescriptionHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Did we have data allocated? */
|
|
|
|
if (Data)
|
|
|
|
{
|
|
|
|
/* Free it */
|
|
|
|
BlMmFreeHeap(Data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return back to caller */
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2016-01-05 06:09:22 +00:00
|
|
|
NTSTATUS
|
|
|
|
BcdEnumerateAndUnpackElements (
|
|
|
|
_In_ HANDLE BcdHandle,
|
|
|
|
_In_ HANDLE ObjectHandle,
|
|
|
|
_Out_opt_ PBCD_ELEMENT Elements,
|
|
|
|
_Inout_ PULONG ElementSize,
|
|
|
|
_Out_ PULONG ElementCount
|
|
|
|
)
|
|
|
|
{
|
|
|
|
PVOID LocalElements;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG LocalElementCount, LocalElementSize;
|
|
|
|
|
|
|
|
/* Make sure required parameters are there */
|
|
|
|
if (!(ElementSize) || !(ElementCount) || ((Elements) && (!*ElementSize)))
|
|
|
|
{
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set initial count to zero */
|
|
|
|
*ElementCount = 0;
|
|
|
|
|
|
|
|
/* Do the initial enumeration to figure out the size required */
|
|
|
|
LocalElementSize = 0;
|
|
|
|
LocalElementCount = 0;
|
|
|
|
Status = BiEnumerateElements(BcdHandle,
|
|
|
|
ObjectHandle,
|
|
|
|
0,
|
|
|
|
BCD_ENUMERATE_FLAG_IN_ORDER |
|
|
|
|
BCD_ENUMERATE_FLAG_DEVICES |
|
|
|
|
BCD_ENUMERATE_FLAG_DEEP,
|
|
|
|
NULL,
|
|
|
|
&LocalElementSize,
|
|
|
|
&LocalElementCount);
|
|
|
|
if (Status != STATUS_BUFFER_TOO_SMALL)
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now allocate a buffer large enough to hold them */
|
|
|
|
LocalElements = BlMmAllocateHeap(LocalElementSize);
|
|
|
|
if (!LocalElements)
|
|
|
|
{
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Zero out the array and do the real enumeration this time around */
|
|
|
|
RtlZeroMemory(LocalElements, LocalElementSize);
|
|
|
|
Status = BiEnumerateElements(BcdHandle,
|
|
|
|
ObjectHandle,
|
|
|
|
0,
|
|
|
|
BCD_ENUMERATE_FLAG_IN_ORDER |
|
|
|
|
BCD_ENUMERATE_FLAG_DEVICES |
|
|
|
|
BCD_ENUMERATE_FLAG_DEEP,
|
|
|
|
LocalElements,
|
|
|
|
&LocalElementSize,
|
|
|
|
&LocalElementCount);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now we know the real count */
|
|
|
|
*ElementCount = LocalElementCount;
|
|
|
|
|
|
|
|
/* Now unpack the data */
|
|
|
|
Status = BiConvertBcdElements(LocalElements,
|
|
|
|
Elements,
|
|
|
|
ElementSize,
|
|
|
|
&LocalElementCount);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Not all elements may have been converted */
|
|
|
|
*ElementCount = LocalElementCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the local (unpacked) buffer and return status */
|
|
|
|
BlMmFreeHeap(LocalElements);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
NTSTATUS
|
|
|
|
BcdOpenStoreFromFile (
|
|
|
|
_In_ PUNICODE_STRING FileName,
|
2016-01-05 06:09:22 +00:00
|
|
|
_In_ PHANDLE BcdHandle
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ULONG Length;
|
|
|
|
PBL_FILE_PATH_DESCRIPTOR FilePath;
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE LocalHandle;
|
|
|
|
|
|
|
|
/* Assume failure */
|
|
|
|
LocalHandle = NULL;
|
|
|
|
|
|
|
|
/* Allocate a path descriptor */
|
|
|
|
Length = FileName->Length + sizeof(*FilePath);
|
|
|
|
FilePath = BlMmAllocateHeap(Length);
|
|
|
|
if (!FilePath)
|
2015-09-05 16:05:20 +00:00
|
|
|
{
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
return STATUS_NO_MEMORY;
|
2015-09-05 16:05:20 +00:00
|
|
|
}
|
|
|
|
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
/* Initialize it */
|
|
|
|
FilePath->Version = 1;
|
|
|
|
FilePath->PathType = InternalPath;
|
|
|
|
FilePath->Length = Length;
|
|
|
|
|
|
|
|
/* Copy the name and NULL-terminate it */
|
|
|
|
RtlCopyMemory(FilePath->Path, FileName->Buffer, Length);
|
|
|
|
FilePath->Path[Length / sizeof(WCHAR)] = UNICODE_NULL;
|
|
|
|
|
|
|
|
/* Open the BCD */
|
|
|
|
Status = BiAddStoreFromFile(FilePath, &LocalHandle);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Return the handle on success */
|
2016-01-05 06:09:22 +00:00
|
|
|
*BcdHandle = LocalHandle;
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the descriptor and return the status */
|
|
|
|
BlMmFreeHeap(FilePath);
|
|
|
|
return Status;
|
2015-09-05 16:05:20 +00:00
|
|
|
}
|
[BOOTLIB]:
- WIP work to begin reading, parsing, mounting and loading the BCD hive into a data store. Untested, has missing pieces.
- Implement BlFileSet/GetInformation, BlFileReadEx, BlFileReadAtOffsetEx and helper structures/functions. Document multiple previously unknown/magic flags.
- Implement BlMmAllocatePhysicalPages. Stub BlMmFreePhysicalPages.
- Implement MmUnmapVirtualAddress, BlMmUnmapVirtualAddressEx when operating in real mode.
- Implement ImgpGetFileSize, ImgpReadFileAtOffset, ImgpOpenFile, ImgpCloseFile, BlImgAllocateImageBuffer, BlImgLoadImageWithProgress2.
- Implement BdDebuggerInitialized, BlBdDebuggerEnabled, BlStatusPrint, BlStatuserror. Stub BlBdPullRemoteFile.
- Implement BlGetBootOptionDevice.
- Implement BiReferenceHive, BiDereferenceHive, BiCloseKey, BiOpenKey. Stub BiFlushKey, BiLoadHive.
- Implement BiAddStoreFromFile, BcdOpenStoreFromFile.
- Stub BlUtlUpdateProcess and BlResourceFindMessage.
- Other misc. cleanups.
[BOOTMGR]:
- Implement BmpFatalErrorMessageFilter, BmErrorPurge, BmpErrorLog, BmFatalErrorEx.
- Implement BmpFwGetFullPath.
- Implement BmOpenDataStore.
- Stub BmOpenBootIni
svn path=/trunk/; revision=69447
2015-10-04 21:07:12 +00:00
|
|
|
|