diff --git a/UEFIPatch/uefipatch_main.cpp b/UEFIPatch/uefipatch_main.cpp index 9c2af76..1b3063f 100644 --- a/UEFIPatch/uefipatch_main.cpp +++ b/UEFIPatch/uefipatch_main.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) result = w.patchFromFile(a.arguments().at(1)); } else { - std::cout << "UEFIPatch 0.3.12 - UEFI image file patching utility" << std::endl << std::endl << + std::cout << "UEFIPatch 0.3.13 - UEFI image file patching utility" << std::endl << std::endl << "Usage: UEFIPatch image_file" << std::endl << std::endl << "Patches will be read from patches.txt file\n"; return ERR_SUCCESS; diff --git a/ffsengine.cpp b/ffsengine.cpp index f9c319d..539d2d9 100644 --- a/ffsengine.cpp +++ b/ffsengine.cpp @@ -3405,11 +3405,9 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon // Normal file // Ensure correct alignment - UINT8 alignmentPower; - UINT32 alignmentBase; - alignmentPower = ffsAlignmentTable[(fileHeader->Attributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3]; + UINT8 alignmentPower = ffsAlignmentTable[(fileHeader->Attributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3]; alignment = (UINT32)(1UL <Attributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3]; + UINT32 fileAlignment = (UINT32)(1UL << alignmentPower); + UINT32 alignmentBase = base + headerSize; + if (alignmentBase % fileAlignment) { + // File will be unaligned if added as is, so we must add pad file before it + // Determine pad file size + UINT32 size = fileAlignment - (alignmentBase % fileAlignment); + // Required padding is smaller then minimal pad file size + while (size < sizeof(EFI_FFS_FILE_HEADER)) { + size += fileAlignment; + } + // Adjust file base to incorporate pad file that will be added to align it + sectionBase += size; + } + // Reconstruct section QByteArray section; result = reconstructSection(index.child(i, 0), sectionBase, section); diff --git a/uefitool.cpp b/uefitool.cpp index 3e9166c..fbdc029 100644 --- a/uefitool.cpp +++ b/uefitool.cpp @@ -17,7 +17,7 @@ UEFITool::UEFITool(QWidget *parent) : QMainWindow(parent), ui(new Ui::UEFITool), -version(tr("0.22.3")) +version(tr("0.22.4")) { clipboard = QApplication::clipboard();