Version 0.9.0

- fixed all interaction with file state
- added application meny
- added actions for changing compression method for selected compressed
section
This commit is contained in:
Nikolaj Schlej 2013-11-18 16:23:59 +01:00
parent a858cc23f5
commit bfd8edcdf9
11 changed files with 640 additions and 243 deletions

View File

@ -106,6 +106,11 @@ typedef uint16_t CHAR16;
#define INSERT_MODE_BEFORE 2
#define INSERT_MODE_AFTER 3
// Erase polarity types
#define ERASE_POLARITY_FALSE 0
#define ERASE_POLARITY_TRUE 1
#define ERASE_POLARITY_UNKNOWN 0xFF
// EFI GUID
typedef struct{
UINT8 Data[16];

1
ffs.h
View File

@ -296,6 +296,7 @@ extern const UINT8 ffsAlignmentTable[];
#define EFI_FILE_MARKED_FOR_UPDATE 0x08
#define EFI_FILE_DELETED 0x10
#define EFI_FILE_HEADER_INVALID 0x20
#define EFI_FILE_ERASE_POLARITY 0x80
// Volume top file
const QByteArray EFI_FFS_VOLUME_TOP_FILE_GUID

File diff suppressed because it is too large Load Diff

View File

@ -52,10 +52,10 @@ public:
UINT8 getVolumeSize(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize);
UINT8 parseVolume(const QByteArray & volume, const QModelIndex & parent = QModelIndex(), const UINT8 mode = INSERT_MODE_APPEND);
UINT8 getFileSize(const QByteArray & volume, const UINT32 fileOffset, UINT32 & fileSize);
UINT8 parseFile(const QByteArray & file, const UINT8 revision, const char empty = '\xFF', const QModelIndex & parent = QModelIndex(), const UINT8 mode = INSERT_MODE_APPEND);
UINT8 parseFile(const QByteArray & file, const UINT8 revision, const UINT8 erasePolarity = ERASE_POLARITY_UNKNOWN, const QModelIndex & parent = QModelIndex(), const UINT8 mode = INSERT_MODE_APPEND);
UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize);
UINT8 parseSections(const QByteArray & body, const UINT8 revision, const char empty = '\xFF', const QModelIndex & parent = QModelIndex());
UINT8 parseSection(const QByteArray & section, const UINT8 revision, const char empty = '\xFF', const QModelIndex & parent = QModelIndex(), const UINT8 mode = INSERT_MODE_APPEND);
UINT8 parseSections(const QByteArray & body, const QModelIndex & parent = QModelIndex());
UINT8 parseSection(const QByteArray & section, const QModelIndex & parent = QModelIndex(), const UINT8 mode = INSERT_MODE_APPEND);
// Compression routines
UINT8 decompress(const QByteArray & compressed, const UINT8 compressionType, QByteArray & decompressedData, UINT8 * algorithm = NULL);
@ -63,14 +63,16 @@ public:
// Construction routines
UINT8 reconstructImage(QByteArray & reconstructed);
UINT8 constructPadFile(const UINT32 size, const UINT8 revision, const char empty, QByteArray & pad);
UINT8 reconstruct(const QModelIndex & index, QQueue<QByteArray> & queue, const UINT8 revision = 2, char empty = '\xFF');
UINT8 constructPadFile(const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad);
UINT8 reconstruct(const QModelIndex & index, QQueue<QByteArray> & queue, const UINT8 revision = 2, const UINT8 erasePolarity = ERASE_POLARITY_UNKNOWN);
UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize);
// Operations on tree items
UINT8 extract(const QModelIndex & index, QByteArray & extracted, const UINT8 mode);
UINT8 insert(const QModelIndex & index, const QByteArray & object, const UINT8 objectType, const UINT8 mode);
UINT8 remove(const QModelIndex & index);
UINT8 rebuild(const QModelIndex & index);
UINT8 changeCompression(const QModelIndex & index, const UINT8 algorithm);
private:
TreeItem *rootItem;

View File

@ -174,7 +174,7 @@ QVariant TreeItem::data(int column) const
case 1: //Action
if (itemAction == TreeItem::Remove)
return "X";
if (itemAction == TreeItem::Reconstruct)
if (itemAction == TreeItem::Rebuild)
return "R";
return QVariant();
case 2: //Type
@ -261,7 +261,6 @@ QByteArray TreeItem::tail() const
return itemTail;
}
bool TreeItem::hasEmptyHeader() const
{
return itemHeader.isEmpty();
@ -281,7 +280,20 @@ UINT8 TreeItem::action() const
{
return itemAction;
}
void TreeItem::setAction(const UINT8 action)
{
itemAction = action;
// Set rebuild action for parent
if (parentItem)
parentItem->setAction(TreeItem::Rebuild);
}
void TreeItem::setCompression(const UINT8 algorithm)
{
itemCompression = algorithm;
// Set rebuild action
setAction(TreeItem::Rebuild);
}

View File

@ -32,7 +32,7 @@ public:
enum ActionTypes {
NoAction = 50,
Remove,
Reconstruct
Rebuild
};
// Item types
@ -100,11 +100,13 @@ public:
QByteArray tail() const;
bool hasEmptyTail() const;
QString info() const;
UINT8 action() const;
UINT8 compression() const;
// Actions can also be changed
UINT8 action() const;
// Action can be changed
void setAction(const UINT8 action);
// Compression can be changed
void setCompression(const UINT8 algorithm);
// Text values can be changed after item construction
void setTypeName(const QString &text);
@ -123,6 +125,7 @@ private:
UINT8 itemType;
UINT8 itemSubtype;
UINT8 itemCompression;
UINT8 itemNewCompression;
QByteArray itemHeader;
QByteArray itemBody;
QByteArray itemTail;

View File

@ -148,7 +148,18 @@ UINT8 TreeModel::setItemAction(const UINT8 action, const QModelIndex &index)
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
item->setAction(action);
emit dataChanged(index, index);
emit dataChanged(this->index(0,0), index);
return ERR_SUCCESS;
}
UINT8 TreeModel::setItemCompression(const UINT8 algorithm, const QModelIndex &index)
{
if(!index.isValid())
return ERR_INVALID_PARAMETER;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
item->setCompression(algorithm);
emit dataChanged(this->index(0,0), index);
return ERR_SUCCESS;
}

View File

@ -44,7 +44,8 @@ public:
UINT8 setItemName(const QString &data, const QModelIndex &index);
UINT8 setItemText(const QString &data, const QModelIndex &index);
UINT8 setItemAction(const UINT8 action, const QModelIndex &index);
UINT8 setItemCompression(const UINT8 algorithm, const QModelIndex &index);
QModelIndex addItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString & name = QString(), const QString & text = QString(), const QString & info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),

View File

@ -31,8 +31,14 @@ UEFITool::UEFITool(QWidget *parent) :
connect(ui->actionInsertAfter, SIGNAL(triggered()), this, SLOT(insertAfter()));
connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(replace()));
connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile()));
connect(ui->actionChangeToEfi11, SIGNAL(triggered()), this, SLOT(changeToEfi11()));
connect(ui->actionChangeToTiano, SIGNAL(triggered()), this, SLOT(changeToTiano()));
connect(ui->actionChangeToLzma, SIGNAL(triggered()), this, SLOT(changeToLzma()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit()));
// Enable Drag-and-Drop actions
this->setAcceptDrops(true);
@ -58,6 +64,7 @@ void UEFITool::init()
ui->actionExtractUncompressed->setDisabled(true);
ui->actionReplace->setDisabled(true);
ui->actionRemove->setDisabled(true);
ui->actionRebuild->setDisabled(true);
ui->actionInsertInto->setDisabled(true);
ui->actionInsertBefore->setDisabled(true);
ui->actionInsertAfter->setDisabled(true);
@ -87,9 +94,11 @@ void UEFITool::populateUi(const QModelIndex &current)
TreeItem* item = static_cast<TreeItem*>(current.internalPointer());
UINT8 type = item->type();
UINT8 subtype = item->subtype();
UINT8 algorithm = item->compression();
ui->infoEdit->setPlainText(item->info());
ui->actionExtract->setDisabled(item->hasEmptyHeader() && item->hasEmptyBody() && item->hasEmptyTail());
ui->actionRebuild->setDisabled(item->hasEmptyHeader() && item->hasEmptyBody() && item->hasEmptyTail());
ui->actionExtractBody->setDisabled(item->hasEmptyHeader());
//ui->actionExtractUncompressed->setEnabled(ffsEngine->isCompressedFile(current));
ui->actionRemove->setEnabled(type == TreeItem::Volume || type == TreeItem::File || type == TreeItem::Section);
@ -98,6 +107,26 @@ void UEFITool::populateUi(const QModelIndex &current)
ui->actionInsertBefore->setEnabled(type == TreeItem::File || type == TreeItem::Section);
ui->actionInsertAfter->setEnabled(type == TreeItem::File || type == TreeItem::Section);
//ui->actionReplace->setEnabled(ffsEngine->isOfType(TreeItem::File, current));
ui->actionChangeToEfi11->setEnabled(type == TreeItem::Section && subtype == EFI_SECTION_COMPRESSION &&
(algorithm == COMPRESSION_ALGORITHM_NONE || algorithm == COMPRESSION_ALGORITHM_TIANO || algorithm == COMPRESSION_ALGORITHM_LZMA));
ui->actionChangeToTiano->setEnabled(type == TreeItem::Section && subtype == EFI_SECTION_COMPRESSION &&
(algorithm == COMPRESSION_ALGORITHM_NONE || algorithm == COMPRESSION_ALGORITHM_EFI11 || algorithm == COMPRESSION_ALGORITHM_LZMA));
ui->actionChangeToLzma->setEnabled(type == TreeItem::Section && subtype == EFI_SECTION_COMPRESSION &&
(algorithm == COMPRESSION_ALGORITHM_NONE || algorithm == COMPRESSION_ALGORITHM_EFI11 || algorithm == COMPRESSION_ALGORITHM_TIANO));
ui->menuChangeCompressionTo->setEnabled(ui->actionChangeToEfi11->isEnabled() ||
ui->actionChangeToTiano->isEnabled() || ui->actionChangeToLzma->isEnabled());
}
void UEFITool::rebuild()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
UINT8 result = ffsEngine->rebuild(index);
if (result == ERR_SUCCESS)
ui->actionSaveImageFile->setEnabled(true);
}
void UEFITool::remove()
@ -188,6 +217,58 @@ void UEFITool::replace()
}
void UEFITool::changeToEfi11()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
UINT8 result = ffsEngine->changeCompression(index, COMPRESSION_ALGORITHM_EFI11);
if (result == ERR_SUCCESS)
ui->actionSaveImageFile->setEnabled(true);
}
void UEFITool::changeToTiano()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
UINT8 result = ffsEngine->changeCompression(index, COMPRESSION_ALGORITHM_TIANO);
if (result == ERR_SUCCESS)
ui->actionSaveImageFile->setEnabled(true);
}
void UEFITool::changeToLzma()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
UINT8 result = ffsEngine->changeCompression(index, COMPRESSION_ALGORITHM_LZMA);
if (result == ERR_SUCCESS)
ui->actionSaveImageFile->setEnabled(true);
}
void UEFITool::about()
{
QMessageBox::about(this, tr("About UEFITool"), tr(
"Copyright (c) 2013, Nikolaj Schlej aka CodeRush.\n\n"
"The program is dedicated to RevoGirl. Rest in peace, young genius.\n\n"
"The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.\n"
"The full text of the license may be found at\nhttp://opensource.org/licenses/bsd-license.php\n\n"
"THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS,\n"
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,\n"
"EITHER EXPRESS OR IMPLIED."
));
}
void UEFITool::aboutQt()
{
QMessageBox::aboutQt(this, tr("About Qt"));
}
void UEFITool::saveImageFile()
{
QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"),".","BIOS image file (*.rom *.bin *.cap *.fd *.wph *.efi);;All files (*.*)");

View File

@ -60,6 +60,12 @@ private slots:
void insertAfter();
void replace();
void remove();
void rebuild();
void changeToEfi11();
void changeToTiano();
void changeToLzma();
void about();
void aboutQt();
void scrollTreeView(QListWidgetItem* item);
private:

View File

@ -20,7 +20,7 @@
<bool>true</bool>
</property>
<property name="windowTitle">
<string>UEFITool 0.8.1</string>
<string>UEFITool 0.9.0</string>
</property>
<widget class="QWidget" name="centralWidget">
<property name="sizePolicy">
@ -183,6 +183,10 @@
<addaction name="actionOpenImageFile"/>
<addaction name="actionSaveImageFile"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
<addaction name="actionExtractUncompressed"/>
@ -192,22 +196,79 @@
<addaction name="actionInsertAfter"/>
<addaction name="separator"/>
<addaction name="actionReplace"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
<addaction name="separator"/>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1100</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="actionOpenImageFile"/>
<addaction name="actionSaveImageFile"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuAction">
<property name="title">
<string>A&amp;ction</string>
</property>
<widget class="QMenu" name="menuChangeCompressionTo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Change &amp;compression to</string>
</property>
<addaction name="actionChangeToTiano"/>
<addaction name="actionChangeToEfi11"/>
<addaction name="actionChangeToLzma"/>
</widget>
<addaction name="actionRebuild"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
<addaction name="actionExtractUncompressed"/>
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
<addaction name="actionInsertAfter"/>
<addaction name="actionInsertBefore"/>
<addaction name="separator"/>
<addaction name="actionReplace"/>
<addaction name="separator"/>
<addaction name="menuChangeCompressionTo"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>H&amp;elp</string>
</property>
<addaction name="actionAbout"/>
<addaction name="actionAboutQt"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuAction"/>
<addaction name="menuHelp"/>
</widget>
<action name="actionInsertAfter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Insert object after...</string>
<string>Insert &amp;after...</string>
</property>
<property name="toolTip">
<string>Insert an object from file after selected object</string>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
<string>Ctrl+Shift+I</string>
</property>
</action>
<action name="actionInsertBefore">
@ -215,13 +276,13 @@
<bool>false</bool>
</property>
<property name="text">
<string>Insert object before...</string>
<string>Insert &amp;before...</string>
</property>
<property name="toolTip">
<string>Insert object from file before selected object</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+I</string>
<string>Ctrl+Alt+I</string>
</property>
</action>
<action name="actionReplace">
@ -229,7 +290,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Replace</string>
<string>Rep&amp;lace</string>
</property>
<property name="toolTip">
<string>Replace selected object with an object from file</string>
@ -243,7 +304,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Extract as is...</string>
<string>E&amp;xtract as is...</string>
</property>
<property name="toolTip">
<string>Extract selected object as is to file</string>
@ -257,7 +318,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Extract without header...</string>
<string>Extract &amp;without header...</string>
</property>
<property name="toolTip">
<string>Extract selected object without header to file</string>
@ -271,7 +332,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Extract uncompressed...</string>
<string>Extract &amp;uncompressed...</string>
</property>
<property name="toolTip">
<string>Extract selected FFS file uncompressing it </string>
@ -285,7 +346,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Remove</string>
<string>Re&amp;move</string>
</property>
<property name="toolTip">
<string>Remove selected object</string>
@ -296,7 +357,7 @@
</action>
<action name="actionOpenImageFile">
<property name="text">
<string>Open image file...</string>
<string>&amp;Open image file...</string>
</property>
<property name="toolTip">
<string>Open image file</string>
@ -310,13 +371,13 @@
<bool>false</bool>
</property>
<property name="text">
<string>Insert object into...</string>
<string>Insert &amp;into...</string>
</property>
<property name="toolTip">
<string>Insert object from file into selected object</string>
</property>
<property name="shortcut">
<string>Ctrl+Ins</string>
<string>Ctrl+I</string>
</property>
</action>
<action name="actionSaveImageFile">
@ -324,7 +385,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Save image file...</string>
<string>&amp;Save image file...</string>
</property>
<property name="toolTip">
<string>Save modified image file</string>
@ -333,6 +394,71 @@
<string>Ctrl+S</string>
</property>
</action>
<action name="actionRebuild">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Rebuild</string>
</property>
<property name="toolTip">
<string>Rebuild selected object</string>
</property>
<property name="shortcut">
<string>Ctrl+Space</string>
</property>
</action>
<action name="actionChangeToTiano">
<property name="text">
<string>&amp;Tiano</string>
</property>
<property name="shortcut">
<string>Ctrl+T</string>
</property>
</action>
<action name="actionChangeToEfi11">
<property name="text">
<string>&amp;EFI 1.1</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+T</string>
</property>
</action>
<action name="actionChangeToLzma">
<property name="text">
<string>&amp;LZMA</string>
</property>
<property name="shortcut">
<string>Ctrl+L</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>&amp;About UEFITool</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
<property name="menuRole">
<enum>QAction::AboutRole</enum>
</property>
</action>
<action name="actionAboutQt">
<property name="text">
<string>About &amp;Qt</string>
</property>
<property name="menuRole">
<enum>QAction::AboutQtRole</enum>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>&amp;Quit</string>
</property>
<property name="menuRole">
<enum>QAction::QuitRole</enum>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>