Add Insyde FDC parser

This commit is contained in:
Nikolaj Schlej 2025-02-23 07:14:02 +07:00
parent 0710ec1686
commit e00fc916bb
14 changed files with 326 additions and 92 deletions

View file

@ -1,9 +1,9 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "phoenix_vss2.h"
#include "edk2_vss2.h"
#include "../kaitai/exceptions.h"
phoenix_vss2_t::phoenix_vss2_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, phoenix_vss2_t* p__root) : kaitai::kstruct(p__io) {
edk2_vss2_t::edk2_vss2_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, edk2_vss2_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = this; (void)p__root;
m_body = nullptr;
@ -12,11 +12,11 @@ phoenix_vss2_t::phoenix_vss2_t(kaitai::kstream* p__io, kaitai::kstruct* p__paren
_read();
}
void phoenix_vss2_t::_read() {
void edk2_vss2_t::_read() {
m_signature = m__io->read_u4le();
{
uint32_t _ = signature();
if (!( ((_ == 3721344535UL) || (_ == 2868063352UL)) )) {
if (!( ((_ == 3721344534UL) || (_ == 3721344535UL) || (_ == 2868063352UL)) )) {
throw kaitai::validation_expr_error<uint32_t>(signature(), _io(), std::string("/seq/0"));
}
}
@ -36,18 +36,26 @@ void phoenix_vss2_t::_read() {
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_vss2_size = m__io->read_u4le();
{
uint32_t _ = vss2_size();
if (!( ((_ > len_vss2_store_header()) && (_ < 4294967295UL)) )) {
throw kaitai::validation_expr_error<uint32_t>(vss2_size(), _io(), std::string("/seq/3"));
throw kaitai::validation_expr_error<uint32_t>(vss2_size(), _io(), std::string("/seq/4"));
}
}
m_format = m__io->read_u1();
{
uint8_t _ = format();
if (!(_ == 90)) {
throw kaitai::validation_expr_error<uint8_t>(format(), _io(), std::string("/seq/4"));
throw kaitai::validation_expr_error<uint8_t>(format(), _io(), std::string("/seq/5"));
}
}
m_state = m__io->read_u1();
@ -58,25 +66,27 @@ void phoenix_vss2_t::_read() {
m_body = std::unique_ptr<vss2_store_body_t>(new vss2_store_body_t(m__io__raw_body.get(), this, m__root));
}
phoenix_vss2_t::~phoenix_vss2_t() {
edk2_vss2_t::~edk2_vss2_t() {
_clean_up();
}
void phoenix_vss2_t::_clean_up() {
void edk2_vss2_t::_clean_up() {
if (!n_signature_auth_var_key_db) {
}
if (!n_signature_vss2_store) {
}
if (!n_signature_fdc_store) {
}
}
phoenix_vss2_t::vss2_store_body_t::vss2_store_body_t(kaitai::kstream* p__io, phoenix_vss2_t* p__parent, phoenix_vss2_t* p__root) : kaitai::kstruct(p__io) {
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) {
m__parent = p__parent;
m__root = p__root;
m_variables = nullptr;
_read();
}
void phoenix_vss2_t::vss2_store_body_t::_read() {
void edk2_vss2_t::vss2_store_body_t::_read() {
m_variables = std::unique_ptr<std::vector<std::unique_ptr<vss2_variable_t>>>(new std::vector<std::unique_ptr<vss2_variable_t>>());
{
int i = 0;
@ -89,20 +99,20 @@ void phoenix_vss2_t::vss2_store_body_t::_read() {
}
}
phoenix_vss2_t::vss2_store_body_t::~vss2_store_body_t() {
edk2_vss2_t::vss2_store_body_t::~vss2_store_body_t() {
_clean_up();
}
void phoenix_vss2_t::vss2_store_body_t::_clean_up() {
void edk2_vss2_t::vss2_store_body_t::_clean_up() {
}
phoenix_vss2_t::vss2_variable_attributes_t::vss2_variable_attributes_t(kaitai::kstream* p__io, phoenix_vss2_t::vss2_variable_t* p__parent, phoenix_vss2_t* p__root) : kaitai::kstruct(p__io) {
edk2_vss2_t::vss2_variable_attributes_t::vss2_variable_attributes_t(kaitai::kstream* p__io, edk2_vss2_t::vss2_variable_t* p__parent, edk2_vss2_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = p__root;
_read();
}
void phoenix_vss2_t::vss2_variable_attributes_t::_read() {
void edk2_vss2_t::vss2_variable_attributes_t::_read() {
m_non_volatile = m__io->read_bits_int_le(1);
m_boot_service = m__io->read_bits_int_le(1);
m_runtime = m__io->read_bits_int_le(1);
@ -113,14 +123,14 @@ void phoenix_vss2_t::vss2_variable_attributes_t::_read() {
m_reserved = m__io->read_bits_int_le(25);
}
phoenix_vss2_t::vss2_variable_attributes_t::~vss2_variable_attributes_t() {
edk2_vss2_t::vss2_variable_attributes_t::~vss2_variable_attributes_t() {
_clean_up();
}
void phoenix_vss2_t::vss2_variable_attributes_t::_clean_up() {
void edk2_vss2_t::vss2_variable_attributes_t::_clean_up() {
}
phoenix_vss2_t::vss2_variable_t::vss2_variable_t(kaitai::kstream* p__io, phoenix_vss2_t::vss2_store_body_t* p__parent, phoenix_vss2_t* p__root) : kaitai::kstruct(p__io) {
edk2_vss2_t::vss2_variable_t::vss2_variable_t(kaitai::kstream* p__io, edk2_vss2_t::vss2_store_body_t* p__parent, edk2_vss2_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = p__root;
m_attributes = nullptr;
@ -136,7 +146,7 @@ phoenix_vss2_t::vss2_variable_t::vss2_variable_t(kaitai::kstream* p__io, phoenix
_read();
}
void phoenix_vss2_t::vss2_variable_t::_read() {
void edk2_vss2_t::vss2_variable_t::_read() {
n_invoke_offset = true;
if (offset() >= 0) {
n_invoke_offset = false;
@ -246,11 +256,11 @@ void phoenix_vss2_t::vss2_variable_t::_read() {
}
}
phoenix_vss2_t::vss2_variable_t::~vss2_variable_t() {
edk2_vss2_t::vss2_variable_t::~vss2_variable_t() {
_clean_up();
}
void phoenix_vss2_t::vss2_variable_t::_clean_up() {
void edk2_vss2_t::vss2_variable_t::_clean_up() {
if (!n_invoke_offset) {
}
if (!n_signature_last) {
@ -293,7 +303,7 @@ void phoenix_vss2_t::vss2_variable_t::_clean_up() {
}
}
bool phoenix_vss2_t::vss2_variable_t::is_auth() {
bool edk2_vss2_t::vss2_variable_t::is_auth() {
if (f_is_auth)
return m_is_auth;
m_is_auth = (( ((attributes()->auth_write()) || (attributes()->time_based_auth()) || (attributes()->append_write())) ) || ( ((len_name() == 0) || (len_data() == 0)) )) ;
@ -301,7 +311,7 @@ bool phoenix_vss2_t::vss2_variable_t::is_auth() {
return m_is_auth;
}
int8_t phoenix_vss2_t::vss2_variable_t::len_standard_header() {
int8_t edk2_vss2_t::vss2_variable_t::len_standard_header() {
if (f_len_standard_header)
return m_len_standard_header;
m_len_standard_header = 32;
@ -309,7 +319,7 @@ int8_t phoenix_vss2_t::vss2_variable_t::len_standard_header() {
return m_len_standard_header;
}
int32_t phoenix_vss2_t::vss2_variable_t::end_offset_auth() {
int32_t edk2_vss2_t::vss2_variable_t::end_offset_auth() {
if (f_end_offset_auth)
return m_end_offset_auth;
m_end_offset_auth = (int32_t)_io()->pos();
@ -317,7 +327,7 @@ int32_t phoenix_vss2_t::vss2_variable_t::end_offset_auth() {
return m_end_offset_auth;
}
int32_t phoenix_vss2_t::vss2_variable_t::len_alignment_padding() {
int32_t edk2_vss2_t::vss2_variable_t::len_alignment_padding() {
if (f_len_alignment_padding)
return m_len_alignment_padding;
m_len_alignment_padding = ((((end_offset() - offset()) + 3) & ~3) - (end_offset() - offset()));
@ -325,7 +335,7 @@ int32_t phoenix_vss2_t::vss2_variable_t::len_alignment_padding() {
return m_len_alignment_padding;
}
int8_t phoenix_vss2_t::vss2_variable_t::len_auth_header() {
int8_t edk2_vss2_t::vss2_variable_t::len_auth_header() {
if (f_len_auth_header)
return m_len_auth_header;
m_len_auth_header = 60;
@ -333,7 +343,7 @@ int8_t phoenix_vss2_t::vss2_variable_t::len_auth_header() {
return m_len_auth_header;
}
int32_t phoenix_vss2_t::vss2_variable_t::end_offset() {
int32_t edk2_vss2_t::vss2_variable_t::end_offset() {
if (f_end_offset)
return m_end_offset;
m_end_offset = (int32_t)_io()->pos();
@ -341,7 +351,7 @@ int32_t phoenix_vss2_t::vss2_variable_t::end_offset() {
return m_end_offset;
}
int32_t phoenix_vss2_t::vss2_variable_t::len_alignment_padding_auth() {
int32_t edk2_vss2_t::vss2_variable_t::len_alignment_padding_auth() {
if (f_len_alignment_padding_auth)
return m_len_alignment_padding_auth;
m_len_alignment_padding_auth = ((((end_offset_auth() - offset()) + 3) & ~3) - (end_offset() - offset()));
@ -349,7 +359,7 @@ int32_t phoenix_vss2_t::vss2_variable_t::len_alignment_padding_auth() {
return m_len_alignment_padding_auth;
}
bool phoenix_vss2_t::vss2_variable_t::is_valid() {
bool edk2_vss2_t::vss2_variable_t::is_valid() {
if (f_is_valid)
return m_is_valid;
m_is_valid = ((state() == 127) || (state() == 63)) ;
@ -357,7 +367,7 @@ bool phoenix_vss2_t::vss2_variable_t::is_valid() {
return m_is_valid;
}
int32_t phoenix_vss2_t::vss2_variable_t::offset() {
int32_t edk2_vss2_t::vss2_variable_t::offset() {
if (f_offset)
return m_offset;
m_offset = (int32_t)_io()->pos();
@ -365,7 +375,7 @@ int32_t phoenix_vss2_t::vss2_variable_t::offset() {
return m_offset;
}
int32_t phoenix_vss2_t::len_vss2_store_header() {
int32_t edk2_vss2_t::len_vss2_store_header() {
if (f_len_vss2_store_header)
return m_len_vss2_store_header;
m_len_vss2_store_header = (7 * 4);

View file

@ -11,27 +11,27 @@
#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required"
#endif
class phoenix_vss2_t : public kaitai::kstruct {
class edk2_vss2_t : public kaitai::kstruct {
public:
class vss2_store_body_t;
class vss2_variable_attributes_t;
class vss2_variable_t;
phoenix_vss2_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, phoenix_vss2_t* p__root = nullptr);
edk2_vss2_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, edk2_vss2_t* p__root = nullptr);
private:
void _read();
void _clean_up();
public:
~phoenix_vss2_t();
~edk2_vss2_t();
class vss2_store_body_t : public kaitai::kstruct {
public:
vss2_store_body_t(kaitai::kstream* p__io, phoenix_vss2_t* p__parent = nullptr, phoenix_vss2_t* p__root = nullptr);
vss2_store_body_t(kaitai::kstream* p__io, edk2_vss2_t* p__parent = nullptr, edk2_vss2_t* p__root = nullptr);
private:
void _read();
@ -42,20 +42,20 @@ public:
private:
std::unique_ptr<std::vector<std::unique_ptr<vss2_variable_t>>> m_variables;
phoenix_vss2_t* m__root;
phoenix_vss2_t* m__parent;
edk2_vss2_t* m__root;
edk2_vss2_t* m__parent;
public:
std::vector<std::unique_ptr<vss2_variable_t>>* variables() const { return m_variables.get(); }
phoenix_vss2_t* _root() const { return m__root; }
phoenix_vss2_t* _parent() const { return m__parent; }
edk2_vss2_t* _root() const { return m__root; }
edk2_vss2_t* _parent() const { return m__parent; }
};
class vss2_variable_attributes_t : public kaitai::kstruct {
public:
vss2_variable_attributes_t(kaitai::kstream* p__io, phoenix_vss2_t::vss2_variable_t* p__parent = nullptr, phoenix_vss2_t* p__root = nullptr);
vss2_variable_attributes_t(kaitai::kstream* p__io, edk2_vss2_t::vss2_variable_t* p__parent = nullptr, edk2_vss2_t* p__root = nullptr);
private:
void _read();
@ -73,8 +73,8 @@ public:
bool m_time_based_auth;
bool m_append_write;
uint64_t m_reserved;
phoenix_vss2_t* m__root;
phoenix_vss2_t::vss2_variable_t* m__parent;
edk2_vss2_t* m__root;
edk2_vss2_t::vss2_variable_t* m__parent;
public:
bool non_volatile() const { return m_non_volatile; }
@ -85,15 +85,15 @@ public:
bool time_based_auth() const { return m_time_based_auth; }
bool append_write() const { return m_append_write; }
uint64_t reserved() const { return m_reserved; }
phoenix_vss2_t* _root() const { return m__root; }
phoenix_vss2_t::vss2_variable_t* _parent() const { return m__parent; }
edk2_vss2_t* _root() const { return m__root; }
edk2_vss2_t::vss2_variable_t* _parent() const { return m__parent; }
};
class vss2_variable_t : public kaitai::kstruct {
public:
vss2_variable_t(kaitai::kstream* p__io, phoenix_vss2_t::vss2_store_body_t* p__parent = nullptr, phoenix_vss2_t* p__root = nullptr);
vss2_variable_t(kaitai::kstream* p__io, edk2_vss2_t::vss2_store_body_t* p__parent = nullptr, edk2_vss2_t* p__root = nullptr);
private:
void _read();
@ -307,8 +307,8 @@ public:
bool _is_null_alignment_padding() { alignment_padding(); return n_alignment_padding; };
private:
phoenix_vss2_t* m__root;
phoenix_vss2_t::vss2_store_body_t* m__parent;
edk2_vss2_t* m__root;
edk2_vss2_t::vss2_store_body_t* m__parent;
public:
std::string invoke_offset() const { return m_invoke_offset; }
@ -332,8 +332,8 @@ public:
std::string data() const { return m_data; }
std::string invoke_end_offset() const { return m_invoke_end_offset; }
std::string alignment_padding() const { return m_alignment_padding; }
phoenix_vss2_t* _root() const { return m__root; }
phoenix_vss2_t::vss2_store_body_t* _parent() const { return m__parent; }
edk2_vss2_t* _root() const { return m__root; }
edk2_vss2_t::vss2_store_body_t* _parent() const { return m__parent; }
};
private:
@ -358,6 +358,13 @@ private:
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:
uint32_t m_vss2_size;
uint8_t m_format;
@ -365,7 +372,7 @@ private:
uint16_t m_reserved;
uint32_t m_reserved1;
std::unique_ptr<vss2_store_body_t> m_body;
phoenix_vss2_t* m__root;
edk2_vss2_t* m__root;
kaitai::kstruct* m__parent;
std::string m__raw_body;
std::unique_ptr<kaitai::kstream> m__io__raw_body;
@ -374,13 +381,14 @@ 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; }
uint32_t vss2_size() const { return m_vss2_size; }
uint8_t format() const { return m_format; }
uint8_t state() const { return m_state; }
uint16_t reserved() const { return m_reserved; }
uint32_t reserved1() const { return m_reserved1; }
vss2_store_body_t* body() const { return m_body.get(); }
phoenix_vss2_t* _root() const { return m__root; }
edk2_vss2_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; }
std::string _raw_body() const { return m__raw_body; }
kaitai::kstream* _io__raw_body() const { return m__io__raw_body.get(); }

View file

@ -0,0 +1,44 @@
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "insyde_fdc.h"
#include "../kaitai/exceptions.h"
insyde_fdc_t::insyde_fdc_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, insyde_fdc_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent;
m__root = this; (void)p__root;
f_len_fdc_store_header = false;
_read();
}
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();
if (!( ((_ > len_fdc_store_header()) && (_ < 4294967295UL)) )) {
throw kaitai::validation_expr_error<uint32_t>(fdc_size(), _io(), std::string("/seq/1"));
}
}
m_body = m__io->read_bytes((fdc_size() - len_fdc_store_header()));
}
insyde_fdc_t::~insyde_fdc_t() {
_clean_up();
}
void insyde_fdc_t::_clean_up() {
}
int8_t insyde_fdc_t::len_fdc_store_header() {
if (f_len_fdc_store_header)
return m_len_fdc_store_header;
m_len_fdc_store_header = 80;
f_len_fdc_store_header = true;
return m_len_fdc_store_header;
}

View file

@ -0,0 +1,46 @@
#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 insyde_fdc_t : public kaitai::kstruct {
public:
insyde_fdc_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, insyde_fdc_t* p__root = nullptr);
private:
void _read();
void _clean_up();
public:
~insyde_fdc_t();
private:
bool f_len_fdc_store_header;
int8_t m_len_fdc_store_header;
public:
int8_t len_fdc_store_header();
private:
uint32_t m_signature;
uint32_t m_fdc_size;
std::string m_body;
insyde_fdc_t* m__root;
kaitai::kstruct* m__parent;
public:
uint32_t signature() const { return m_signature; }
uint32_t fdc_size() const { return m_fdc_size; }
std::string body() const { return m_body; }
insyde_fdc_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; }
};