mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-13 06:34:42 -04:00
Version 0.16.5
- solved a bug in reconstructFile while reconstructing raw files with volumes inside - solved a bug in reconstructRegion, UEFI 2.0 capsule header was lost during reconstruction
This commit is contained in:
parent
e660b7ecea
commit
f65bebb398
2 changed files with 43 additions and 69 deletions
|
@ -1927,6 +1927,7 @@ UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconst
|
|||
}
|
||||
|
||||
// Reconstruction successful
|
||||
reconstructed = model->header(index).append(reconstructed);
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2272,35 +2273,44 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
|
|||
if (model->rowCount(index)) {
|
||||
reconstructed.clear();
|
||||
// Construct new file body
|
||||
UINT32 offset = 0;
|
||||
// File contains raw data, must be parsed as region
|
||||
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW) {
|
||||
result = reconstructRegion(index, reconstructed);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
// File contains sections
|
||||
else {
|
||||
UINT32 offset = 0;
|
||||
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
// Align to 4 byte boundary
|
||||
UINT8 alignment = offset % 4;
|
||||
if (alignment) {
|
||||
alignment = 4 - alignment;
|
||||
offset += alignment;
|
||||
reconstructed.append(QByteArray(alignment, '\x00'));
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
// Align to 4 byte boundary
|
||||
UINT8 alignment = offset % 4;
|
||||
if (alignment) {
|
||||
alignment = 4 - alignment;
|
||||
offset += alignment;
|
||||
reconstructed.append(QByteArray(alignment, '\x00'));
|
||||
}
|
||||
|
||||
// Calculate section base
|
||||
UINT32 sectionBase = base ? base + sizeof(EFI_FFS_FILE_HEADER) + offset : 0;
|
||||
|
||||
// Reconstruct section
|
||||
QByteArray section;
|
||||
result = reconstructSection(index.child(i, 0), sectionBase, section);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
// Check for empty section
|
||||
if (section.isEmpty())
|
||||
continue;
|
||||
|
||||
// Append current section to new file body
|
||||
reconstructed.append(section);
|
||||
|
||||
// Change current file offset
|
||||
offset += section.size();
|
||||
}
|
||||
|
||||
// Calculate section base
|
||||
UINT32 sectionBase = base ? base + sizeof(EFI_FFS_FILE_HEADER) + offset : 0;
|
||||
|
||||
// Reconstruct section
|
||||
QByteArray section;
|
||||
result = reconstructSection(index.child(i, 0), sectionBase, section);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
// Check for empty section
|
||||
if (section.isEmpty())
|
||||
continue;
|
||||
|
||||
// Append current section to new file body
|
||||
reconstructed.append(section);
|
||||
|
||||
// Change current file offset
|
||||
offset += section.size();
|
||||
}
|
||||
|
||||
// Correct file size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue