mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-13 06:34:42 -04:00
Switch to C++11 for Kaitai-generated parsers
This commit is contained in:
parent
255742f371
commit
75bf036137
15 changed files with 316 additions and 745 deletions
|
@ -6,38 +6,32 @@
|
|||
intel_keym_v2_t::intel_keym_v2_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, intel_keym_v2_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = this; (void)p__root;
|
||||
m_header = 0;
|
||||
m_reserved = 0;
|
||||
m_km_hashes = 0;
|
||||
m_key_signature = 0;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
m_header = nullptr;
|
||||
m_reserved = nullptr;
|
||||
m_km_hashes = nullptr;
|
||||
m_key_signature = nullptr;
|
||||
_read();
|
||||
}
|
||||
|
||||
void intel_keym_v2_t::_read() {
|
||||
m_header = new header_t(m__io, this, m__root);
|
||||
m_header = std::unique_ptr<header_t>(new header_t(m__io, this, m__root));
|
||||
m_key_signature_offset = m__io->read_u2le();
|
||||
m_reserved = new std::vector<uint8_t>();
|
||||
m_reserved = std::unique_ptr<std::vector<uint8_t>>(new std::vector<uint8_t>());
|
||||
const int l_reserved = 3;
|
||||
for (int i = 0; i < l_reserved; i++) {
|
||||
m_reserved->push_back(m__io->read_u1());
|
||||
m_reserved->push_back(std::move(m__io->read_u1()));
|
||||
}
|
||||
m_km_version = m__io->read_u1();
|
||||
m_km_svn = m__io->read_u1();
|
||||
m_km_id = m__io->read_u1();
|
||||
m_fpf_hash_algorithm_id = m__io->read_u2le();
|
||||
m_num_km_hashes = m__io->read_u2le();
|
||||
m_km_hashes = new std::vector<km_hash_t*>();
|
||||
m_km_hashes = std::unique_ptr<std::vector<std::unique_ptr<km_hash_t>>>(new std::vector<std::unique_ptr<km_hash_t>>());
|
||||
const int l_km_hashes = num_km_hashes();
|
||||
for (int i = 0; i < l_km_hashes; i++) {
|
||||
m_km_hashes->push_back(new km_hash_t(m__io, this, m__root));
|
||||
m_km_hashes->push_back(std::move(std::unique_ptr<km_hash_t>(new km_hash_t(m__io, this, m__root))));
|
||||
}
|
||||
m_key_signature = new key_signature_t(m__io, this, m__root);
|
||||
m_key_signature = std::unique_ptr<key_signature_t>(new key_signature_t(m__io, this, m__root));
|
||||
}
|
||||
|
||||
intel_keym_v2_t::~intel_keym_v2_t() {
|
||||
|
@ -45,43 +39,22 @@ intel_keym_v2_t::~intel_keym_v2_t() {
|
|||
}
|
||||
|
||||
void intel_keym_v2_t::_clean_up() {
|
||||
if (m_header) {
|
||||
delete m_header; m_header = 0;
|
||||
}
|
||||
if (m_reserved) {
|
||||
delete m_reserved; m_reserved = 0;
|
||||
}
|
||||
if (m_km_hashes) {
|
||||
for (std::vector<km_hash_t*>::iterator it = m_km_hashes->begin(); it != m_km_hashes->end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
delete m_km_hashes; m_km_hashes = 0;
|
||||
}
|
||||
if (m_key_signature) {
|
||||
delete m_key_signature; m_key_signature = 0;
|
||||
}
|
||||
}
|
||||
|
||||
intel_keym_v2_t::key_signature_t::key_signature_t(kaitai::kstream* p__io, intel_keym_v2_t* p__parent, intel_keym_v2_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
m_public_key = 0;
|
||||
m_signature = 0;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
m_public_key = nullptr;
|
||||
m_signature = nullptr;
|
||||
_read();
|
||||
}
|
||||
|
||||
void intel_keym_v2_t::key_signature_t::_read() {
|
||||
m_version = m__io->read_u1();
|
||||
m_key_id = m__io->read_u2le();
|
||||
m_public_key = new public_key_t(m__io, this, m__root);
|
||||
m_public_key = std::unique_ptr<public_key_t>(new public_key_t(m__io, this, m__root));
|
||||
m_sig_scheme = m__io->read_u2le();
|
||||
m_signature = new signature_t(m__io, this, m__root);
|
||||
m_signature = std::unique_ptr<signature_t>(new signature_t(m__io, this, m__root));
|
||||
}
|
||||
|
||||
intel_keym_v2_t::key_signature_t::~key_signature_t() {
|
||||
|
@ -89,24 +62,12 @@ intel_keym_v2_t::key_signature_t::~key_signature_t() {
|
|||
}
|
||||
|
||||
void intel_keym_v2_t::key_signature_t::_clean_up() {
|
||||
if (m_public_key) {
|
||||
delete m_public_key; m_public_key = 0;
|
||||
}
|
||||
if (m_signature) {
|
||||
delete m_signature; m_signature = 0;
|
||||
}
|
||||
}
|
||||
|
||||
intel_keym_v2_t::km_hash_t::km_hash_t(kaitai::kstream* p__io, intel_keym_v2_t* p__parent, intel_keym_v2_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
_read();
|
||||
}
|
||||
|
||||
void intel_keym_v2_t::km_hash_t::_read() {
|
||||
|
@ -126,13 +87,7 @@ void intel_keym_v2_t::km_hash_t::_clean_up() {
|
|||
intel_keym_v2_t::signature_t::signature_t(kaitai::kstream* p__io, intel_keym_v2_t::key_signature_t* p__parent, intel_keym_v2_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
_read();
|
||||
}
|
||||
|
||||
void intel_keym_v2_t::signature_t::_read() {
|
||||
|
@ -152,13 +107,7 @@ void intel_keym_v2_t::signature_t::_clean_up() {
|
|||
intel_keym_v2_t::public_key_t::public_key_t(kaitai::kstream* p__io, intel_keym_v2_t::key_signature_t* p__parent, intel_keym_v2_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
_read();
|
||||
}
|
||||
|
||||
void intel_keym_v2_t::public_key_t::_read() {
|
||||
|
@ -178,13 +127,7 @@ void intel_keym_v2_t::public_key_t::_clean_up() {
|
|||
intel_keym_v2_t::header_t::header_t(kaitai::kstream* p__io, intel_keym_v2_t* p__parent, intel_keym_v2_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
_read();
|
||||
}
|
||||
|
||||
void intel_keym_v2_t::header_t::_read() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue