Kaitai-based Intel ACM and BootGuard parsers

As the first step towards automated parsing, this change set replaces outdated BootGuard-related parsers with shiny new KaitaiStruct-based ones.
It also does the following:
- improves Intel FIT definitions by using the relevant specification
- adds sha1, sha384, sha512 and sm3 digest implementations
- updates LZMA SDK to v22.01
- moves GUIDs out of include files to prevent multiple instantiations
- enforces C++11
- adds Kaitai-based parsers for Intel FIT, BootGuard v1 and BootGuard v2 structures
- makes many small refactorings here, there and everywhere
This commit is contained in:
Nikolaj Schlej 2022-08-29 08:23:38 +02:00
parent 8600bc3ab3
commit 934ce1f3f8
81 changed files with 15212 additions and 5279 deletions

View file

@ -19,7 +19,6 @@
#include "meparser.h"
#include "parsingdata.h"
#include "utility.h"
#include "uinttypes.h"
#ifdef U_ENABLE_ME_PARSING_SUPPORT
@ -54,7 +53,7 @@ USTATUS MeParser::parseMeRegionBody(const UModelIndex & index)
// Check ME signature to determine it's version
// ME v11 and older layout
if (meRegion.left(sizeof(UINT32)) == FPT_HEADER_SIGNATURE || meRegion.mid(ME_ROM_BYPASS_VECTOR_SIZE, sizeof(UINT32)) == FPT_HEADER_SIGNATURE) {
if (*(UINT32*)meRegion.constData() == FPT_HEADER_SIGNATURE || *(UINT32*)(meRegion.constData() + ME_ROM_BYPASS_VECTOR_SIZE) == FPT_HEADER_SIGNATURE) {
UModelIndex ptIndex;
return parseFptRegion(meRegion, index, ptIndex);
}
@ -73,7 +72,7 @@ USTATUS MeParser::parseMeRegionBody(const UModelIndex & index)
return U_INVALID_ME_PARTITION_TABLE;
}
// Data partition always points to FPT header
if (meRegion.mid(ifwi16Header->DataPartition.Offset, sizeof(UINT32)) == FPT_HEADER_SIGNATURE) {
if (*(UINT32*)(meRegion.constData() + ifwi16Header->DataPartition.Offset) == FPT_HEADER_SIGNATURE) {
UModelIndex ptIndex;
return parseIfwi16Region(meRegion, index, ptIndex);
}
@ -91,7 +90,7 @@ USTATUS MeParser::parseMeRegionBody(const UModelIndex & index)
return U_INVALID_ME_PARTITION_TABLE;
}
// Data partition always points to FPT header
if (meRegion.mid(ifwi17Header->DataPartition.Offset, sizeof(UINT32)) == FPT_HEADER_SIGNATURE) {
if (*(UINT32*)(meRegion.constData() + ifwi17Header->DataPartition.Offset)== FPT_HEADER_SIGNATURE) {
UModelIndex ptIndex;
return parseIfwi17Region(meRegion, index, ptIndex);
}
@ -112,7 +111,7 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
// Populate partition table header
const FPT_HEADER* ptHeader = (const FPT_HEADER*)region.constData();
UINT32 romBypassVectorSize = 0;
if (region.left(sizeof(UINT32)) != FPT_HEADER_SIGNATURE) {
if (*(UINT32*)region.constData() != FPT_HEADER_SIGNATURE) {
// Adjust the header to skip ROM bypass vector
romBypassVectorSize = ME_ROM_BYPASS_VECTOR_SIZE;
ptHeader = (const FPT_HEADER*)(region.constData() + romBypassVectorSize);