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
|
// Set action
|
||||||
model->setAction(fileIndex, 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) {
|
else if (type == Types::Volume) {
|
||||||
QByteArray volume;
|
QByteArray volume;
|
||||||
if (header.isEmpty()) // Whole volume
|
if (header.isEmpty()) // Whole volume
|
||||||
|
@ -2351,6 +2363,12 @@ UINT8 FfsEngine::replace(const QModelIndex & index, const QByteArray & object, c
|
||||||
else
|
else
|
||||||
return ERR_NOT_IMPLEMENTED;
|
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) {
|
else if (model->type(index) == Types::Volume) {
|
||||||
if (mode == REPLACE_MODE_AS_IS) {
|
if (mode == REPLACE_MODE_AS_IS) {
|
||||||
result = create(index, Types::Volume, QByteArray(), object, CREATE_MODE_AFTER, Actions::Replace);
|
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()) {
|
if (reconstructed.size() > model->body(index).size()) {
|
||||||
msg(tr("reconstructRegion: reconstructed region size %1h (%2) is bigger then original %3h (%4)")
|
msg(tr("reconstructRegion: reconstructed region size %1h (%2) is bigger then original %3h (%4)")
|
||||||
.hexarg(reconstructed.size()).arg(reconstructed.size())
|
.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);
|
index);
|
||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
else if (reconstructed.size() < model->body(index).size()) {
|
else if (reconstructed.size() < model->body(index).size()) {
|
||||||
msg(tr("reconstructRegion: reconstructed region size %1h (%2) is smaller then original %3h (%4)")
|
msg(tr("reconstructRegion: reconstructed region size %1h (%2) is smaller then original %3h (%4)")
|
||||||
.hexarg(reconstructed.size()).arg(reconstructed.size())
|
.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);
|
index);
|
||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -2995,6 +3013,49 @@ UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconst
|
||||||
return ERR_NOT_IMPLEMENTED;
|
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)
|
UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & reconstructed)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
@ -3710,9 +3771,9 @@ UINT8 FfsEngine::reconstruct(const QModelIndex &index, QByteArray& reconstructed
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Types::Padding:
|
case Types::Padding:
|
||||||
// No reconstruction needed
|
result = reconstructPadding(index, reconstructed);
|
||||||
reconstructed = model->header(index).append(model->body(index));
|
if (result)
|
||||||
return ERR_SUCCESS;
|
return result;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Types::Volume:
|
case Types::Volume:
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
UINT8 reconstruct(const QModelIndex &index, QByteArray & reconstructed);
|
UINT8 reconstruct(const QModelIndex &index, QByteArray & reconstructed);
|
||||||
UINT8 reconstructIntelImage(const QModelIndex& index, QByteArray & reconstructed);
|
UINT8 reconstructIntelImage(const QModelIndex& index, QByteArray & reconstructed);
|
||||||
UINT8 reconstructRegion(const QModelIndex& index, QByteArray & reconstructed, bool includeHeader = true);
|
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 reconstructBios(const QModelIndex& index, QByteArray & reconstructed);
|
||||||
UINT8 reconstructVolume(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);
|
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)));
|
(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->actionInsertBefore->setEnabled(type == Types::File || type == Types::Section);
|
||||||
ui->actionInsertAfter->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->actionReplaceBody->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
|
||||||
ui->actionMessagesCopy->setEnabled(false);
|
ui->actionMessagesCopy->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -327,6 +327,13 @@ void UEFITool::replace(const UINT8 mode)
|
||||||
else
|
else
|
||||||
return;
|
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) {
|
else if (model->type(index) == Types::Volume) {
|
||||||
if (mode == REPLACE_MODE_AS_IS) {
|
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 (*)");
|
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>
|
<string>&Padding</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionExtract"/>
|
<addaction name="actionExtract"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionReplace"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuVolumeActions">
|
<widget class="QMenu" name="menuVolumeActions">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue