diff --git a/ffsengine.cpp b/ffsengine.cpp
index 5556ae0..6848c3c 100644
--- a/ffsengine.cpp
+++ b/ffsengine.cpp
@@ -2093,6 +2093,18 @@ UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByte
// Set action
model->setAction(fileIndex, action);
}
+ else if (type == Types::Padding) {
+ // Get info
+ QString name = tr("Padding");
+ QString info = tr("Full size: %1h (%2)")
+ .hexarg(body.size()).arg(body.size());
+
+ // Add tree item
+ QModelIndex fileIndex = model->addItem(Types::Padding, getPaddingType(body), COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), body, index, mode);
+
+ // Set action
+ model->setAction(fileIndex, action);
+ }
else if (type == Types::Volume) {
QByteArray volume;
if (header.isEmpty()) // Whole volume
@@ -2351,6 +2363,12 @@ UINT8 FfsEngine::replace(const QModelIndex & index, const QByteArray & object, c
else
return ERR_NOT_IMPLEMENTED;
}
+ else if (model->type(index) == Types::Padding) {
+ if (mode == REPLACE_MODE_AS_IS)
+ result = create(index, Types::Padding, QByteArray(), object, CREATE_MODE_AFTER, Actions::Replace);
+ else
+ return ERR_NOT_IMPLEMENTED;
+ }
else if (model->type(index) == Types::Volume) {
if (mode == REPLACE_MODE_AS_IS) {
result = create(index, Types::Volume, QByteArray(), object, CREATE_MODE_AFTER, Actions::Replace);
@@ -2973,14 +2991,14 @@ UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconst
if (reconstructed.size() > model->body(index).size()) {
msg(tr("reconstructRegion: reconstructed region size %1h (%2) is bigger then original %3h (%4)")
.hexarg(reconstructed.size()).arg(reconstructed.size())
- .hexarg(model->body(index).size()).arg(reconstructed.size()),
+ .hexarg(model->body(index).size()).arg(model->body(index).size()),
index);
return ERR_INVALID_PARAMETER;
}
else if (reconstructed.size() < model->body(index).size()) {
msg(tr("reconstructRegion: reconstructed region size %1h (%2) is smaller then original %3h (%4)")
.hexarg(reconstructed.size()).arg(reconstructed.size())
- .hexarg(model->body(index).size()).arg(reconstructed.size()),
+ .hexarg(model->body(index).size()).arg(model->body(index).size()),
index);
return ERR_INVALID_PARAMETER;
}
@@ -2995,6 +3013,49 @@ UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconst
return ERR_NOT_IMPLEMENTED;
}
+UINT8 FfsEngine::reconstructPadding(const QModelIndex& index, QByteArray& reconstructed)
+{
+ if (!index.isValid())
+ return ERR_SUCCESS;
+
+ // No action
+ if (model->action(index) == Actions::NoAction) {
+ reconstructed = model->body(index);
+ return ERR_SUCCESS;
+ }
+ else if (model->action(index) == Actions::Remove) {
+ reconstructed.clear();
+ return ERR_SUCCESS;
+ }
+ else if (model->action(index) == Actions::Rebuild ||
+ model->action(index) == Actions::Replace) {
+ // Use stored item body
+ reconstructed = model->body(index);
+
+ // Check size of reconstructed region, it must be same
+ if (reconstructed.size() > model->body(index).size()) {
+ msg(tr("reconstructPadding: reconstructed padding size %1h (%2) is bigger then original %3h (%4)")
+ .hexarg(reconstructed.size()).arg(reconstructed.size())
+ .hexarg(model->body(index).size()).arg(model->body(index).size()),
+ index);
+ return ERR_INVALID_PARAMETER;
+ }
+ else if (reconstructed.size() < model->body(index).size()) {
+ msg(tr("reconstructPadding: reconstructed padding size %1h (%2) is smaller then original %3h (%4)")
+ .hexarg(reconstructed.size()).arg(reconstructed.size())
+ .hexarg(model->body(index).size()).arg(model->body(index).size()),
+ index);
+ return ERR_INVALID_PARAMETER;
+ }
+
+ // Reconstruction successful
+ return ERR_SUCCESS;
+ }
+
+ // All other actions are not supported
+ return ERR_NOT_IMPLEMENTED;
+}
+
UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & reconstructed)
{
if (!index.isValid())
@@ -3710,9 +3771,9 @@ UINT8 FfsEngine::reconstruct(const QModelIndex &index, QByteArray& reconstructed
break;
case Types::Padding:
- // No reconstruction needed
- reconstructed = model->header(index).append(model->body(index));
- return ERR_SUCCESS;
+ result = reconstructPadding(index, reconstructed);
+ if (result)
+ return result;
break;
case Types::Volume:
diff --git a/ffsengine.h b/ffsengine.h
index c565921..4fe5223 100644
--- a/ffsengine.h
+++ b/ffsengine.h
@@ -83,6 +83,7 @@ public:
UINT8 reconstruct(const QModelIndex &index, QByteArray & reconstructed);
UINT8 reconstructIntelImage(const QModelIndex& index, QByteArray & reconstructed);
UINT8 reconstructRegion(const QModelIndex& index, QByteArray & reconstructed, bool includeHeader = true);
+ UINT8 reconstructPadding(const QModelIndex& index, QByteArray & reconstructed);
UINT8 reconstructBios(const QModelIndex& index, QByteArray & reconstructed);
UINT8 reconstructVolume(const QModelIndex& index, QByteArray & reconstructed);
UINT8 reconstructFile(const QModelIndex& index, const UINT8 revision, const UINT8 erasePolarity, const UINT32 base, QByteArray& reconstructed);
diff --git a/uefitool.cpp b/uefitool.cpp
index 39d77ce..1689387 100644
--- a/uefitool.cpp
+++ b/uefitool.cpp
@@ -153,7 +153,7 @@ void UEFITool::populateUi(const QModelIndex ¤t)
(type == Types::Section && (subtype == EFI_SECTION_COMPRESSION || subtype == EFI_SECTION_GUID_DEFINED || subtype == EFI_SECTION_DISPOSABLE)));
ui->actionInsertBefore->setEnabled(type == Types::File || type == Types::Section);
ui->actionInsertAfter->setEnabled(type == Types::File || type == Types::Section);
- ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::Volume || type == Types::File || type == Types::Section);
+ ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::Padding || type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionReplaceBody->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionMessagesCopy->setEnabled(false);
}
@@ -327,6 +327,13 @@ void UEFITool::replace(const UINT8 mode)
else
return;
}
+ else if (model->type(index) == Types::Padding) {
+ if (mode == REPLACE_MODE_AS_IS) {
+ path = QFileDialog::getOpenFileName(this, tr("Select padding file to replace selected object"), currentDir, "Padding files (*.pad *.bin);;All files (*)");
+ }
+ else
+ return;
+ }
else if (model->type(index) == Types::Volume) {
if (mode == REPLACE_MODE_AS_IS) {
path = QFileDialog::getOpenFileName(this, tr("Select volume file to replace selected object"), currentDir, "Volume files (*.vol *.bin);;All files (*)");
diff --git a/uefitool.ui b/uefitool.ui
index 5b5953a..8e0a19d 100644
--- a/uefitool.ui
+++ b/uefitool.ui
@@ -232,6 +232,8 @@
&Padding
+
+