mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-12 22:26:13 -04:00
Replace action for paddings
- and a very small visual bugfix
This commit is contained in:
parent
e5cf61f89a
commit
9c7c94702d
4 changed files with 77 additions and 6 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 (*)");
|
||||
|
|
|
@ -232,6 +232,8 @@
|
|||
<string>&Padding</string>
|
||||
</property>
|
||||
<addaction name="actionExtract"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReplace"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuVolumeActions">
|
||||
<property name="title">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue