mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-13 14:44:47 -04:00
fixed rebase PEI files with nonstandard alignment
This commit is contained in:
parent
341ee144f9
commit
ea5ae2f2c8
3 changed files with 19 additions and 7 deletions
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[])
|
||||||
result = w.patchFromFile(a.arguments().at(1));
|
result = w.patchFromFile(a.arguments().at(1));
|
||||||
}
|
}
|
||||||
else {
|
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 <<
|
"Usage: UEFIPatch image_file" << std::endl << std::endl <<
|
||||||
"Patches will be read from patches.txt file\n";
|
"Patches will be read from patches.txt file\n";
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
|
|
|
@ -3405,11 +3405,9 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
|
||||||
|
|
||||||
// Normal file
|
// Normal file
|
||||||
// Ensure correct alignment
|
// Ensure correct alignment
|
||||||
UINT8 alignmentPower;
|
UINT8 alignmentPower = ffsAlignmentTable[(fileHeader->Attributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3];
|
||||||
UINT32 alignmentBase;
|
|
||||||
alignmentPower = ffsAlignmentTable[(fileHeader->Attributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3];
|
|
||||||
alignment = (UINT32)(1UL <<alignmentPower);
|
alignment = (UINT32)(1UL <<alignmentPower);
|
||||||
alignmentBase = header.size() + offset + fileHeaderSize;
|
UINT32 alignmentBase = header.size() + offset + fileHeaderSize;
|
||||||
if (alignmentBase % alignment) {
|
if (alignmentBase % alignment) {
|
||||||
// File will be unaligned if added as is, so we must add pad file before it
|
// File will be unaligned if added as is, so we must add pad file before it
|
||||||
// Determine pad file size
|
// Determine pad file size
|
||||||
|
@ -3706,6 +3704,20 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
|
||||||
|
|
||||||
// Calculate section base
|
// Calculate section base
|
||||||
UINT32 sectionBase = base ? base + headerSize + offset : 0;
|
UINT32 sectionBase = base ? base + headerSize + offset : 0;
|
||||||
|
UINT8 alignmentPower = ffsAlignmentTable[(fileHeader->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
|
// Reconstruct section
|
||||||
QByteArray section;
|
QByteArray section;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
UEFITool::UEFITool(QWidget *parent) :
|
UEFITool::UEFITool(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::UEFITool),
|
ui(new Ui::UEFITool),
|
||||||
version(tr("0.22.3"))
|
version(tr("0.22.4"))
|
||||||
{
|
{
|
||||||
clipboard = QApplication::clipboard();
|
clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue