Add SLIC pubkey and marker parsers

This commit is contained in:
Nikolaj Schlej 2025-03-08 09:26:48 +07:00
parent fd0faea9ea
commit 3cb5dc0165
34 changed files with 657 additions and 425 deletions

View file

@ -41,6 +41,8 @@ SET(PROJECT_SOURCES
../common/generated/edk2_ftw.cpp
../common/generated/insyde_fdc.cpp
../common/generated/insyde_fdm.cpp
../common/generated/ms_slic_marker.cpp
../common/generated/ms_slic_pubkey.cpp
../common/generated/phoenix_flm.cpp
../common/generated/phoenix_evsa.cpp
../common/generated/intel_acbp_v1.cpp

View file

@ -38,6 +38,8 @@ SET(PROJECT_SOURCES
../common/generated/edk2_ftw.cpp
../common/generated/insyde_fdc.cpp
../common/generated/insyde_fdm.cpp
../common/generated/ms_slic_marker.cpp
../common/generated/ms_slic_pubkey.cpp
../common/generated/phoenix_flm.cpp
../common/generated/phoenix_evsa.cpp
../common/generated/intel_acbp_v1.cpp

View file

@ -74,6 +74,8 @@ SET(PROJECT_SOURCES
../common/generated/edk2_ftw.cpp
../common/generated/insyde_fdc.cpp
../common/generated/insyde_fdm.cpp
../common/generated/ms_slic_marker.cpp
../common/generated/ms_slic_pubkey.cpp
../common/generated/phoenix_evsa.cpp
../common/generated/phoenix_flm.cpp
../common/generated/intel_acbp_v1.cpp

View file

@ -57,6 +57,8 @@ HEADERS += uefitool.h \
../common/generated/edk2_ftw.h \
../common/generated/insyde_fdc.h \
../common/generated/insyde_fdm.h \
../common/generated/ms_slic_marker.h \
../common/generated/ms_slic_pubkey.h \
../common/generated/phoenix_flm.h \
../common/generated/phoenix_evsa.h \
../common/generated/intel_acbp_v1.h \
@ -132,6 +134,8 @@ SOURCES += uefitool_main.cpp \
../common/generated/edk2_ftw.cpp \
../common/generated/insyde_fdc.cpp \
../common/generated/insyde_fdm.cpp \
../common/generated/ms_slic_marker.cpp \
../common/generated/ms_slic_pubkey.cpp \
../common/generated/phoenix_flm.cpp \
../common/generated/phoenix_evsa.cpp \
../common/generated/intel_acbp_v1.cpp \

View file

@ -992,7 +992,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
}
// Add board IDs
if (parsed.revision() == 3) {
if (!parsed._is_null_board_ids()) {
info += usprintf("\nRegion index: %Xh\nBoardId Count: %u",
parsed.board_ids()->region_index(),
parsed.board_ids()->num_board_ids());

View file

@ -1,7 +1,6 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "apple_sysf.h"
#include "../kaitai/exceptions.h"
apple_sysf_t::apple_sysf_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, apple_sysf_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
@ -14,12 +13,6 @@ apple_sysf_t::apple_sysf_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, a
void apple_sysf_t::_read() {
m_signature = m__io->read_u4le();
{
uint32_t _ = signature();
if (!( ((_ == 1937339206) || (_ == 1684627783)) )) {
throw kaitai::validation_expr_error<uint32_t>(signature(), _io(), std::string("/seq/0"));
}
}
m_unknown = m__io->read_u1();
m_unknown1 = m__io->read_u4le();
m_sysf_size = m__io->read_u2le();

View file

@ -1,7 +1,6 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "edk2_ftw.h"
#include "../kaitai/exceptions.h"
edk2_ftw_t::edk2_ftw_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, edk2_ftw_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
@ -13,12 +12,6 @@ edk2_ftw_t::edk2_ftw_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, edk2_
void edk2_ftw_t::_read() {
m_signature = m__io->read_bytes(16);
{
std::string _ = signature();
if (!( ((_ == std::string("\x8D\x2B\xF1\xFF\x96\x76\x8B\x4C\xA9\x85\x27\x47\x07\x5B\x4F\x50", 16)) || (_ == std::string("\x2B\x29\x58\x9E\x68\x7C\x7D\x49\x0A\xCE\x65\x00\xFD\x9F\x1B\x95", 16)) || (_ == std::string("\x2B\x29\x58\x9E\x68\x7C\x7D\x49\xA0\xCE\x65\x00\xFD\x9F\x1B\x95", 16))) )) {
throw kaitai::validation_expr_error<std::string>(signature(), _io(), std::string("/seq/0"));
}
}
m_crc = m__io->read_u4le();
m_state = m__io->read_u1();
m_reserved = m__io->read_bytes(3);

View file

@ -14,12 +14,6 @@ edk2_vss_t::edk2_vss_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, edk2_
void edk2_vss_t::_read() {
m_signature = m__io->read_u4le();
{
uint32_t _ = signature();
if (!( ((_ == 1397970468) || (_ == 1398166308) || (_ == 1397968420)) )) {
throw kaitai::validation_expr_error<uint32_t>(signature(), _io(), std::string("/seq/0"));
}
}
m_vss_size = m__io->read_u4le();
{
uint32_t _ = vss_size();
@ -28,12 +22,6 @@ void edk2_vss_t::_read() {
}
}
m_format = m__io->read_u1();
{
uint8_t _ = format();
if (!(_ == 90)) {
throw kaitai::validation_expr_error<uint8_t>(format(), _io(), std::string("/seq/2"));
}
}
m_state = m__io->read_u1();
m_reserved = m__io->read_u2le();
m_reserved1 = m__io->read_u4le();

View file

@ -13,51 +13,15 @@ edk2_vss2_t::edk2_vss2_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, edk
}
void edk2_vss2_t::_read() {
m_signature = m__io->read_u4le();
{
uint32_t _ = signature();
if (!( ((_ == 3721344534UL) || (_ == 3721344535UL) || (_ == 2868063352UL)) )) {
throw kaitai::validation_expr_error<uint32_t>(signature(), _io(), std::string("/seq/0"));
}
}
n_signature_auth_var_key_db = true;
if (signature() == 2868063352UL) {
n_signature_auth_var_key_db = false;
m_signature_auth_var_key_db = m__io->read_bytes(12);
if (!(signature_auth_var_key_db() == std::string("\x7B\x94\x9A\x43\xA1\x80\x2E\x14\x4E\xC3\x77\x92", 12))) {
throw kaitai::validation_not_equal_error<std::string>(std::string("\x7B\x94\x9A\x43\xA1\x80\x2E\x14\x4E\xC3\x77\x92", 12), signature_auth_var_key_db(), _io(), std::string("/seq/1"));
}
}
n_signature_vss2_store = true;
if (signature() == 3721344535UL) {
n_signature_vss2_store = false;
m_signature_vss2_store = m__io->read_bytes(12);
if (!(signature_vss2_store() == std::string("\x75\x32\x64\x41\x98\xB6\xFE\x85\x70\x7F\xFE\x7D", 12))) {
throw kaitai::validation_not_equal_error<std::string>(std::string("\x75\x32\x64\x41\x98\xB6\xFE\x85\x70\x7F\xFE\x7D", 12), signature_vss2_store(), _io(), std::string("/seq/2"));
}
}
n_signature_fdc_store = true;
if (signature() == 3721344534UL) {
n_signature_fdc_store = false;
m_signature_fdc_store = m__io->read_bytes(12);
if (!(signature_fdc_store() == std::string("\x75\x32\x64\x41\x98\xB6\xFE\x85\x70\x7F\xFE\x7D", 12))) {
throw kaitai::validation_not_equal_error<std::string>(std::string("\x75\x32\x64\x41\x98\xB6\xFE\x85\x70\x7F\xFE\x7D", 12), signature_fdc_store(), _io(), std::string("/seq/3"));
}
}
m_signature = m__io->read_bytes(16);
m_vss2_size = m__io->read_u4le();
{
uint32_t _ = vss2_size();
if (!( ((_ > static_cast<uint32_t>(len_vss2_store_header())) && (_ < 4294967295UL)) )) {
throw kaitai::validation_expr_error<uint32_t>(vss2_size(), _io(), std::string("/seq/4"));
throw kaitai::validation_expr_error<uint32_t>(vss2_size(), _io(), std::string("/seq/1"));
}
}
m_format = m__io->read_u1();
{
uint8_t _ = format();
if (!(_ == 90)) {
throw kaitai::validation_expr_error<uint8_t>(format(), _io(), std::string("/seq/5"));
}
}
m_state = m__io->read_u1();
m_reserved = m__io->read_u2le();
m_reserved1 = m__io->read_u4le();
@ -71,12 +35,6 @@ edk2_vss2_t::~edk2_vss2_t() {
}
void edk2_vss2_t::_clean_up() {
if (!n_signature_auth_var_key_db) {
}
if (!n_signature_vss2_store) {
}
if (!n_signature_fdc_store) {
}
}
edk2_vss2_t::vss2_store_body_t::vss2_store_body_t(kaitai::kstream* p__io, edk2_vss2_t* p__parent, edk2_vss2_t* p__root) : kaitai::kstruct(p__io) {

View file

@ -344,28 +344,7 @@ public:
int32_t len_vss2_store_header();
private:
uint32_t m_signature;
std::string m_signature_auth_var_key_db;
bool n_signature_auth_var_key_db;
public:
bool _is_null_signature_auth_var_key_db() { signature_auth_var_key_db(); return n_signature_auth_var_key_db; };
private:
std::string m_signature_vss2_store;
bool n_signature_vss2_store;
public:
bool _is_null_signature_vss2_store() { signature_vss2_store(); return n_signature_vss2_store; };
private:
std::string m_signature_fdc_store;
bool n_signature_fdc_store;
public:
bool _is_null_signature_fdc_store() { signature_fdc_store(); return n_signature_fdc_store; };
private:
std::string m_signature;
uint32_t m_vss2_size;
uint8_t m_format;
uint8_t m_state;
@ -378,10 +357,7 @@ private:
std::unique_ptr<kaitai::kstream> m__io__raw_body;
public:
uint32_t signature() const { return m_signature; }
std::string signature_auth_var_key_db() const { return m_signature_auth_var_key_db; }
std::string signature_vss2_store() const { return m_signature_vss2_store; }
std::string signature_fdc_store() const { return m_signature_fdc_store; }
std::string signature() const { return m_signature; }
uint32_t vss2_size() const { return m_vss2_size; }
uint8_t format() const { return m_format; }
uint8_t state() const { return m_state; }

View file

@ -12,12 +12,6 @@ insyde_fdc_t::insyde_fdc_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, i
void insyde_fdc_t::_read() {
m_signature = m__io->read_u4le();
{
uint32_t _ = signature();
if (!(_ == 1128547935)) {
throw kaitai::validation_expr_error<uint32_t>(signature(), _io(), std::string("/seq/0"));
}
}
m_fdc_size = m__io->read_u4le();
{
uint32_t _ = fdc_size();

View file

@ -24,6 +24,9 @@ void insyde_fdm_t::_read() {
m_entry_size = m__io->read_u4le();
m_entry_format = m__io->read_u1();
m_revision = m__io->read_u1();
if (!( ((revision() == 1) || (revision() == 2) || (revision() == 3)) )) {
throw kaitai::validation_not_any_of_error<uint8_t>(revision(), _io(), std::string("/seq/5"));
}
m_num_extensions = m__io->read_u1();
m_checksum = m__io->read_u1();
m_fd_base_address = m__io->read_u8le();
@ -35,7 +38,7 @@ void insyde_fdm_t::_read() {
m_extensions = std::unique_ptr<fdm_extensions_t>(new fdm_extensions_t(m__io__raw_extensions.get(), this, m__root));
}
n_board_ids = true;
if (revision() == 3) {
if ( ((revision() == 3) && (extensions()->extensions()->at(1)->count() > 0)) ) {
n_board_ids = false;
m_board_ids = std::unique_ptr<fdm_board_ids_t>(new fdm_board_ids_t(m__io, this, m__root));
}

View file

@ -0,0 +1,28 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "ms_slic_marker.h"
ms_slic_marker_t::ms_slic_marker_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, ms_slic_marker_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = this; (void)p__root;
_read();
}
void ms_slic_marker_t::_read() {
m_type = m__io->read_u4le();
m_len_marker = m__io->read_u4le();
m_version = m__io->read_u4le();
m_oem_id = m__io->read_bytes(6);
m_oem_table_id = m__io->read_bytes(8);
m_windows_flag = m__io->read_u8le();
m_slic_version = m__io->read_u4le();
m_reserved = m__io->read_bytes(16);
m_signature = m__io->read_bytes(128);
}
ms_slic_marker_t::~ms_slic_marker_t() {
_clean_up();
}
void ms_slic_marker_t::_clean_up() {
}

View file

@ -0,0 +1,51 @@
#pragma once
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "../kaitai/kaitaistruct.h"
#include <stdint.h>
#include <memory>
#if KAITAI_STRUCT_VERSION < 9000L
#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required"
#endif
class ms_slic_marker_t : public kaitai::kstruct {
public:
ms_slic_marker_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, ms_slic_marker_t* p__root = nullptr);
private:
void _read();
void _clean_up();
public:
~ms_slic_marker_t();
private:
uint32_t m_type;
uint32_t m_len_marker;
uint32_t m_version;
std::string m_oem_id;
std::string m_oem_table_id;
uint64_t m_windows_flag;
uint32_t m_slic_version;
std::string m_reserved;
std::string m_signature;
ms_slic_marker_t* m__root;
kaitai::kstruct* m__parent;
public:
uint32_t type() const { return m_type; }
uint32_t len_marker() const { return m_len_marker; }
uint32_t version() const { return m_version; }
std::string oem_id() const { return m_oem_id; }
std::string oem_table_id() const { return m_oem_table_id; }
uint64_t windows_flag() const { return m_windows_flag; }
uint32_t slic_version() const { return m_slic_version; }
std::string reserved() const { return m_reserved; }
std::string signature() const { return m_signature; }
ms_slic_marker_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; }
};

View file

@ -0,0 +1,29 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "ms_slic_pubkey.h"
ms_slic_pubkey_t::ms_slic_pubkey_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, ms_slic_pubkey_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = this; (void)p__root;
_read();
}
void ms_slic_pubkey_t::_read() {
m_type = m__io->read_u4le();
m_len_pubkey = m__io->read_u4le();
m_key_type = m__io->read_u1();
m_version = m__io->read_u1();
m_reserved = m__io->read_u2le();
m_algorithm = m__io->read_u4le();
m_magic = m__io->read_u4le();
m_bit_length = m__io->read_u4le();
m_exponent = m__io->read_u4le();
m_modulus = m__io->read_bytes(128);
}
ms_slic_pubkey_t::~ms_slic_pubkey_t() {
_clean_up();
}
void ms_slic_pubkey_t::_clean_up() {
}

View file

@ -0,0 +1,53 @@
#pragma once
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "../kaitai/kaitaistruct.h"
#include <stdint.h>
#include <memory>
#if KAITAI_STRUCT_VERSION < 9000L
#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required"
#endif
class ms_slic_pubkey_t : public kaitai::kstruct {
public:
ms_slic_pubkey_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, ms_slic_pubkey_t* p__root = nullptr);
private:
void _read();
void _clean_up();
public:
~ms_slic_pubkey_t();
private:
uint32_t m_type;
uint32_t m_len_pubkey;
uint8_t m_key_type;
uint8_t m_version;
uint16_t m_reserved;
uint32_t m_algorithm;
uint32_t m_magic;
uint32_t m_bit_length;
uint32_t m_exponent;
std::string m_modulus;
ms_slic_pubkey_t* m__root;
kaitai::kstruct* m__parent;
public:
uint32_t type() const { return m_type; }
uint32_t len_pubkey() const { return m_len_pubkey; }
uint8_t key_type() const { return m_key_type; }
uint8_t version() const { return m_version; }
uint16_t reserved() const { return m_reserved; }
uint32_t algorithm() const { return m_algorithm; }
uint32_t magic() const { return m_magic; }
uint32_t bit_length() const { return m_bit_length; }
uint32_t exponent() const { return m_exponent; }
std::string modulus() const { return m_modulus; }
ms_slic_pubkey_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; }
};

View file

@ -13,18 +13,9 @@ phoenix_evsa_t::phoenix_evsa_t(kaitai::kstream* p__io, kaitai::kstruct* p__paren
void phoenix_evsa_t::_read() {
m_type = m__io->read_u1();
if (!(type() == 236)) {
throw kaitai::validation_not_equal_error<uint8_t>(236, type(), _io(), std::string("/seq/0"));
}
m_checksum = m__io->read_u1();
m_len_evsa_store_header = m__io->read_u2le();
if (!(len_evsa_store_header() == 20)) {
throw kaitai::validation_not_equal_error<uint16_t>(20, len_evsa_store_header(), _io(), std::string("/seq/2"));
}
m_signature = m__io->read_u4le();
if (!(signature() == 1095980613)) {
throw kaitai::validation_not_equal_error<uint32_t>(1095980613, signature(), _io(), std::string("/seq/3"));
}
m_attributes = m__io->read_u4le();
m_len_evsa_store = m__io->read_u4le();
m_reserved = m__io->read_u4le();

View file

@ -1,14 +1,11 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "phoenix_flm.h"
#include "../kaitai/exceptions.h"
phoenix_flm_t::phoenix_flm_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, phoenix_flm_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = this; (void)p__root;
m_entries = nullptr;
m_free_space = nullptr;
f_len_flm_store = false;
f_len_flm_store_header = false;
f_len_flm_entry = false;
_read();
@ -16,27 +13,13 @@ phoenix_flm_t::phoenix_flm_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent,
void phoenix_flm_t::_read() {
m_signature = m__io->read_bytes(10);
if (!(signature() == std::string("\x5F\x46\x4C\x41\x53\x48\x5F\x4D\x41\x50", 10))) {
throw kaitai::validation_not_equal_error<std::string>(std::string("\x5F\x46\x4C\x41\x53\x48\x5F\x4D\x41\x50", 10), signature(), _io(), std::string("/seq/0"));
}
m_num_entries = m__io->read_u2le();
{
uint16_t _ = num_entries();
if (!(_ <= 113)) {
throw kaitai::validation_expr_error<uint16_t>(num_entries(), _io(), std::string("/seq/1"));
}
}
m_reserved = m__io->read_u4le();
m_entries = std::unique_ptr<std::vector<std::unique_ptr<flm_entry_t>>>(new std::vector<std::unique_ptr<flm_entry_t>>());
const int l_entries = num_entries();
for (int i = 0; i < l_entries; i++) {
m_entries->push_back(std::move(std::unique_ptr<flm_entry_t>(new flm_entry_t(m__io, this, m__root))));
}
m_free_space = std::unique_ptr<std::vector<uint8_t>>(new std::vector<uint8_t>());
const int l_free_space = ((len_flm_store() - len_flm_store_header()) - (len_flm_entry() * num_entries()));
for (int i = 0; i < l_free_space; i++) {
m_free_space->push_back(std::move(m__io->read_u1()));
}
}
phoenix_flm_t::~phoenix_flm_t() {
@ -68,14 +51,6 @@ phoenix_flm_t::flm_entry_t::~flm_entry_t() {
void phoenix_flm_t::flm_entry_t::_clean_up() {
}
int32_t phoenix_flm_t::len_flm_store() {
if (f_len_flm_store)
return m_len_flm_store;
m_len_flm_store = 4096;
f_len_flm_store = true;
return m_len_flm_store;
}
int8_t phoenix_flm_t::len_flm_store_header() {
if (f_len_flm_store_header)
return m_len_flm_store_header;

View file

@ -59,13 +59,6 @@ public:
phoenix_flm_t* _parent() const { return m__parent; }
};
private:
bool f_len_flm_store;
int32_t m_len_flm_store;
public:
int32_t len_flm_store();
private:
bool f_len_flm_store_header;
int8_t m_len_flm_store_header;
@ -85,7 +78,6 @@ private:
uint16_t m_num_entries;
uint32_t m_reserved;
std::unique_ptr<std::vector<std::unique_ptr<flm_entry_t>>> m_entries;
std::unique_ptr<std::vector<uint8_t>> m_free_space;
phoenix_flm_t* m__root;
kaitai::kstruct* m__parent;
@ -94,7 +86,6 @@ public:
uint16_t num_entries() const { return m_num_entries; }
uint32_t reserved() const { return m_reserved; }
std::vector<std::unique_ptr<flm_entry_t>>* entries() const { return m_entries.get(); }
std::vector<uint8_t>* free_space() const { return m_free_space.get(); }
phoenix_flm_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; }
};

View file

@ -1,6 +1,6 @@
meta:
id: apple_sysf
title: Apple system variable store
title: Apple System Flags store
application: Apple MacEFI-based UEFI firmware
file-extension: sysf
tags:
@ -12,8 +12,6 @@ meta:
seq:
- id: signature
type: u4
valid:
expr: _ == 0x73797346 or _ == 0x64696147 # Fsys/Gaid
- id: unknown
type: u1
- id: unknown1

View file

@ -12,10 +12,6 @@ meta:
seq:
- id: signature
size: 16
valid:
expr: _ == [0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C, 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50]
or _ == [0x2B, 0x29, 0x58, 0x9E, 0x68, 0x7C, 0x7D, 0x49, 0x0A, 0xCE, 0x65, 0x00, 0xFD, 0x9F, 0x1B, 0x95]
or _ == [0x2B, 0x29, 0x58, 0x9E, 0x68, 0x7C, 0x7D, 0x49, 0xA0, 0xCE, 0x65, 0x00, 0xFD, 0x9F, 0x1B, 0x95]
- id: crc
type: u4
- id: state

View file

@ -12,16 +12,12 @@ meta:
seq:
- id: signature
type: u4
valid:
expr: _ == 0x53535624 or _ == 0x53565324 or _ == 0x53534E24 # $VSS/$SVS/$NSS
- id: vss_size
type: u4
valid:
expr: _ > len_vss_store_header.as<u4> and _ < 0xFFFFFFFF
- id: format
type: u1
valid:
expr: _ == 0x5a # Formatted
- id: state
type: u1
- id: reserved

View file

@ -11,26 +11,13 @@ meta:
seq:
- id: signature
type: u4
valid:
expr: _ == 0xDDCF3616 or _ == 0xDDCF3617 or _ == 0xAAF32C78 # Beginning of known store GUIDs for VSS2
- id: signature_auth_var_key_db
contents: [0x7B, 0x94, 0x9A, 0x43, 0xA1, 0x80, 0x2E, 0x14, 0x4E, 0xC3, 0x77, 0x92] # AAF32C78-947B-439A-A180-2E144EC37792
if: signature == 0xAAF32C78
- id: signature_vss2_store
contents: [0x75, 0x32, 0x64, 0x41, 0x98, 0xB6, 0xFE, 0x85, 0x70, 0x7F, 0xFE, 0x7D] # DDCF3617-3275-4164-98B6-FE85707FFE7D
if: signature == 0xDDCF3617
- id: signature_fdc_store
contents: [0x75, 0x32, 0x64, 0x41, 0x98, 0xB6, 0xFE, 0x85, 0x70, 0x7F, 0xFE, 0x7D] # DDCF3616-3275-4164-98B6-FE85707FFE7D
if: signature == 0xDDCF3616
size: 16
- id: vss2_size
type: u4
valid:
expr: _ > len_vss2_store_header.as<u4> and _ < 0xFFFFFFFF
- id: format
type: u1
valid:
expr: _ == 0x5a # Formatted
- id: state
type: u1
- id: reserved

View file

@ -12,8 +12,6 @@ meta:
seq:
- id: signature
type: u4
valid:
expr: _ == 0x4344465F # _FDC
- id: fdc_size
type: u4
valid:

View file

@ -1,6 +1,6 @@
meta:
id: insyde_fdm
title: Insyde Flash Device
title: Insyde Flash Device Map
application: Insyde-based UEFI firmware
file-extension: fdm
tags:
@ -23,6 +23,8 @@ seq:
type: u1
- id: revision
type: u1
valid:
any-of: [1, 2, 3]
- id: num_extensions
type: u1
- id: checksum
@ -35,7 +37,7 @@ seq:
if: revision == 3
- id: board_ids
type: fdm_board_ids
if: revision == 3
if: revision == 3 and extensions.extensions[1].count > 0
- id: entries
type: fdm_entries
size: store_size - data_offset

View file

@ -0,0 +1,30 @@
meta:
id: ms_slic_marker
title: Microsoft SLIC Marker
application: Phoenix-based UEFI firmware
file-extension: slmr
tags:
- firmware
license: CC0-1.0
ks-version: 0.9
endian: le
seq:
- id: type
type: u4
- id: len_marker
type: u4
- id: version
type: u4
- id: oem_id
size: 6
- id: oem_table_id
size: 8
- id: windows_flag
type: u8
- id: slic_version
type: u4
- id: reserved
size: 16
- id: signature
size: 128

View file

@ -0,0 +1,32 @@
meta:
id: ms_slic_pubkey
title: Microsoft SLIC Public Key
application: Phoenix-based UEFI firmware
file-extension: slpk
tags:
- firmware
license: CC0-1.0
ks-version: 0.9
endian: le
seq:
- id: type
type: u4
- id: len_pubkey
type: u4
- id: key_type
type: u1
- id: version
type: u1
- id: reserved
type: u2
- id: algorithm
type: u4
- id: magic
type: u4
- id: bit_length
type: u4
- id: exponent
type: u4
- id: modulus
size: 128

View file

@ -12,15 +12,12 @@ meta:
seq:
- id: type
type: u1
valid: 0xEC
- id: checksum
type: u1
- id: len_evsa_store_header
type: u2
valid: 20
- id: signature
type: u4
valid: 0x41535645 #EVSA
- id: attributes
type: u4
- id: len_evsa_store

View file

@ -1,6 +1,6 @@
meta:
id: phoenix_flm
title: Phoenix flash map
title: Phoenix Flash Map
application: Phoenix-based UEFI firmware
file-extension: flm
tags:
@ -11,25 +11,17 @@ meta:
seq:
- id: signature
contents: [0x5F, 0x46, 0x4C, 0x41, 0x53, 0x48, 0x5F, 0x4D, 0x41, 0x50] # _FLASH_MAP
size: 10
- id: num_entries
type: u2
valid:
expr: _ <= 113 # Needs to fit into the last 0x1000 bytes of the NVRAM volume
- id: reserved
type: u4
- id: entries
type: flm_entry
repeat: expr
repeat-expr: num_entries
- id: free_space
type: u1
repeat: expr
repeat-expr: len_flm_store - len_flm_store_header - len_flm_entry * num_entries
instances:
len_flm_store:
value: 0x1000
len_flm_store_header:
value: 16
len_flm_entry:
@ -50,5 +42,4 @@ types:
type: u4
- id: offset
type: u4

View file

@ -39,6 +39,8 @@ uefitoolcommon = static_library('uefitoolcommon',
'generated/edk2_ftw.cpp',
'generated/insyde_fdc.cpp',
'generated/insyde_fdm.cpp',
'generated/ms_slic_marker.cpp',
'generated/ms_slic_pubkey.cpp',
'generated/phoenix_flm.cpp',
'generated/phoenix_evsa.cpp',
'generated/intel_acbp_v1.cpp',

View file

@ -70,8 +70,6 @@ extern const UByteArray NVRAM_ADDITIONAL_STORE_VOLUME_GUID; // 00504624-8A59-4EE
#define NVRAM_VSS_STORE_SIGNATURE 0x53535624 // $VSS
#define NVRAM_APPLE_SVS_STORE_SIGNATURE 0x53565324 // $SVS
#define NVRAM_APPLE_NSS_STORE_SIGNATURE 0x53534E24 // $NSS
#define NVRAM_APPLE_SYSF_STORE_SIGNATURE 0x73797346 // Fsys
#define NVRAM_APPLE_DIAG_STORE_SIGNATURE 0x64696147 // Gaid
#define NVRAM_VSS_VARIABLE_START_ID 0x55AA
// Variable store header flags
@ -86,12 +84,12 @@ extern const UByteArray NVRAM_ADDITIONAL_STORE_VOLUME_GUID; // 00504624-8A59-4EE
// Variable store header
typedef struct VSS_VARIABLE_STORE_HEADER_ {
UINT32 Signature; // $VSS signature
UINT32 Size; // Size of variable store, including store header
UINT8 Format; // Store format state
UINT8 State; // Store health state
UINT16 Unknown; // Used in Apple $SVS varstores
UINT32 : 32;
UINT32 Signature; // Signature
UINT32 Size; // Size of variable store, including store header
UINT8 Format; // Store format state
UINT8 State; // Store health state
UINT16 Reserved; // Used in Apple $SVS varstores
UINT32 Reserved1; // Reserved
} VSS_VARIABLE_STORE_HEADER;
// Normal variable header
@ -142,12 +140,12 @@ typedef struct VSS_AUTH_VARIABLE_HEADER_ {
} VSS_AUTH_VARIABLE_HEADER;
// VSS variable states
#define NVRAM_VSS_VARIABLE_IN_DELETED_TRANSITION 0xfe // Variable is in obsolete transistion
#define NVRAM_VSS_VARIABLE_DELETED 0xfd // Variable is obsolete
#define NVRAM_VSS_VARIABLE_HEADER_VALID 0x7f // Variable has valid header
#define NVRAM_VSS_VARIABLE_ADDED 0x3f // Variable has been completely added
#define NVRAM_VSS_INTEL_VARIABLE_VALID 0xfc // Intel special variable valid
#define NVRAM_VSS_INTEL_VARIABLE_INVALID 0xf8 // Intel special variable invalid
#define NVRAM_VSS_VARIABLE_IN_DELETED_TRANSITION 0xfe // Variable is in obsolete transistion
#define NVRAM_VSS_VARIABLE_DELETED 0xfd // Variable is obsolete
#define NVRAM_VSS_VARIABLE_HEADER_VALID 0x7f // Variable has valid header
#define NVRAM_VSS_VARIABLE_ADDED 0x3f // Variable has been completely added
#define NVRAM_VSS_INTEL_VARIABLE_VALID 0xfc // Intel special variable valid
#define NVRAM_VSS_INTEL_VARIABLE_INVALID 0xf8 // Intel special variable invalid
// VSS variable attributes
#define NVRAM_VSS_VARIABLE_NON_VOLATILE 0x00000001
@ -165,13 +163,8 @@ extern UString vssAttributesToUString(const UINT32 attributes);
//
// VSS2 variables
//
#define NVRAM_VSS2_AUTH_VAR_KEY_DATABASE_GUID_PART1 0xaaf32c78
extern const UByteArray NVRAM_VSS2_AUTH_VAR_KEY_DATABASE_GUID; // AAF32C78-947B-439A-A180-2E144EC37792
#define NVRAM_VSS2_STORE_GUID_PART1 0xddcf3617
extern const UByteArray NVRAM_VSS2_STORE_GUID; // DDCF3617-3275-4164-98B6-FE85707FFE7D
#define NVRAM_FDC_STORE_GUID_PART1 0xddcf3616
extern const UByteArray NVRAM_FDC_STORE_GUID; // DDCF3616-3275-4164-98B6-FE85707FFE7D
// Variable store header
@ -180,24 +173,23 @@ typedef struct VSS2_VARIABLE_STORE_HEADER_ {
UINT32 Size; // Size of variable store, including store header
UINT8 Format; // Store format state
UINT8 State; // Store health state
UINT16 Unknown;
UINT32 : 32;
UINT16 Reserved;
UINT32 Reserved1;
} VSS2_VARIABLE_STORE_HEADER;
// VSS2 entries are 4-bytes aligned in VSS2 stores
//
// _FDC region
// Insyde Factory Data Copy store
//
#define INSYDE_FDC_STORE_SIGNATURE 0x4344465F
#define NVRAM_FDC_VOLUME_SIGNATURE 0x4344465F
typedef struct FDC_VOLUME_HEADER_ {
typedef struct INSYDE_FDC_STORE_HEADER_ {
UINT32 Signature; //_FDC signature
UINT32 Size; // Size of the whole region
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
EFI_FV_BLOCK_MAP_ENTRY FvBlockMap[2];
} FDC_VOLUME_HEADER;
} INSYDE_FDC_STORE_HEADER;
//
// FTW block
@ -207,11 +199,8 @@ typedef struct FDC_VOLUME_HEADER_ {
extern const UByteArray EDKII_WORKING_BLOCK_SIGNATURE_GUID; // 9E58292B-7C68-497D-0ACE-6500FD9F1B95
extern const UByteArray VSS2_WORKING_BLOCK_SIGNATURE_GUID; // 9E58292B-7C68-497D-A0CE-6500FD9F1B95
#define NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 0xFFF12B8D
#define EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1 0x9E58292B
typedef struct EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER32_ {
EFI_GUID Signature; // NVRAM_MAIN_STORE_VOLUME_GUID
EFI_GUID Signature;
UINT32 Crc; // Crc32 of the header with empty Crc and State fields
UINT8 State;
UINT8 Reserved[3];
@ -220,7 +209,7 @@ typedef struct EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER32_ {
} EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER32;
typedef struct EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER64_ {
EFI_GUID Signature; // NVRAM_MAIN_STORE_VOLUME_GUID or EDKII_WORKING_BLOCK_SIGNATURE_GUID
EFI_GUID Signature;
UINT32 Crc; // Crc32 of the header with empty Crc and State fields
UINT8 State;
UINT8 Reserved[3];
@ -231,15 +220,16 @@ typedef struct EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER64_ {
//
// Apple System Flags store
//
#define NVRAM_APPLE_SYSF_STORE_SIGNATURE 0x73797346 // Fsys
#define NVRAM_APPLE_DIAG_STORE_SIGNATURE 0x64696147 // Gaid
typedef struct APPLE_SYSF_STORE_HEADER_ {
UINT32 Signature; // Fsys or Gaid signature
UINT8 Unknown0; // Still unknown
UINT8 Unknown; // Still unknown
UINT32 Unknown1; // Still unknown
UINT16 Size; // Size of variable store
} APPLE_SYSF_STORE_HEADER;
// Apple Fsys entry format
// Apple SysF entry format
// UINT8 NameLength;
// CHAR8 Name[];
// UINT16 DataLength;
@ -322,12 +312,8 @@ extern UString evsaAttributesToUString(const UINT32 attributes);
//
// Phoenix SCT Flash Map
//
#define NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_PART1 0x414C465F
#define NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_LENGTH 10
// _FLASH_MAP
extern const UByteArray NVRAM_PHOENIX_FLASH_MAP_SIGNATURE;
extern const UByteArray NVRAM_PHOENIX_FLASH_MAP_SIGNATURE; // _FLASH_MAP
typedef struct PHOENIX_FLASH_MAP_HEADER_ {
UINT8 Signature[10]; // _FLASH_MAP signature
@ -396,10 +382,9 @@ typedef struct OEM_ACTIVATION_MARKER_ {
UINT8 Signature[128];
} OEM_ACTIVATION_MARKER;
#define OEM_ACTIVATION_MARKER_TYPE 0x00000001
#define OEM_ACTIVATION_MARKER_WINDOWS_FLAG_PART1 0x444E4957
#define OEM_ACTIVATION_MARKER_WINDOWS_FLAG 0x2053574F444E4957UL
#define OEM_ACTIVATION_MARKER_RESERVED_BYTE 0x00
#define OEM_ACTIVATION_MARKER_TYPE 0x00000001
#define OEM_ACTIVATION_MARKER_WINDOWS_FLAG 0x2053574F444E4957UL // WINDOWS
#define OEM_ACTIVATION_MARKER_RESERVED_BYTE 0x00
//
// Phoenix CMDB, no londer used, requires no parsing

File diff suppressed because it is too large Load diff

View file

@ -194,7 +194,6 @@ public:
UByteArray body(const UModelIndex &index) const;
bool hasEmptyBody(const UModelIndex &index) const;
void setBody(const UModelIndex &index, const UByteArray &body);
UByteArray tail(const UModelIndex &index) const;
bool hasEmptyTail(const UModelIndex &index) const;

View file

@ -38,6 +38,8 @@ SET(PROJECT_SOURCES
../common/generated/edk2_ftw.cpp
../common/generated/insyde_fdc.cpp
../common/generated/insyde_fdm.cpp
../common/generated/ms_slic_marker.cpp
../common/generated/ms_slic_pubkey.cpp
../common/generated/phoenix_flm.cpp
../common/generated/phoenix_evsa.cpp
../common/generated/intel_acbp_v1.cpp