UE 0.10.8 / UF 0.10.6

- removed usage of QSet, QPair and Q_FOREACH
- removed dependency from QObject for FfsDumper and UEFIFind classes
This commit is contained in:
Nikolaj Schlej 2016-03-01 09:12:37 +01:00
parent 4a7bacb270
commit f729dd58b7
6 changed files with 30 additions and 39 deletions

View File

@ -13,8 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "ffsdumper.h"
FfsDumper::FfsDumper(TreeModel* treeModel, QObject *parent)
: QObject(parent), model(treeModel), dumped(false)
FfsDumper::FfsDumper(TreeModel* treeModel)
: model(treeModel), dumped(false)
{
}
@ -51,7 +51,7 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
QFile file;
if (!model->header(index).isEmpty()) {
file.setFileName(tr("%1/header.bin").arg(path));
file.setFileName(QObject::tr("%1/header.bin").arg(path));
if (!file.open(QFile::WriteOnly))
return ERR_FILE_OPEN;
@ -60,7 +60,7 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
}
if (!model->body(index).isEmpty()) {
file.setFileName(tr("%1/body.bin").arg(path));
file.setFileName(QObject::tr("%1/body.bin").arg(path));
if (!file.open(QFile::WriteOnly))
return ERR_FILE_OPEN;
@ -68,12 +68,12 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
file.close();
}
QString info = tr("Type: %1\nSubtype: %2\n%3%4")
QString info = QObject::tr("Type: %1\nSubtype: %2\n%3%4")
.arg(itemTypeToQString(model->type(index)))
.arg(itemSubtypeToQString(model->type(index), model->subtype(index)))
.arg(model->text(index).isEmpty() ? tr("") : tr("Text: %1\n").arg(model->text(index)))
.arg(model->text(index).isEmpty() ? QObject::tr("") : QObject::tr("Text: %1\n").arg(model->text(index)))
.arg(model->info(index));
file.setFileName(tr("%1/info.txt").arg(path));
file.setFileName(QObject::tr("%1/info.txt").arg(path));
if (!file.open(QFile::Text | QFile::WriteOnly))
return ERR_FILE_OPEN;

View File

@ -19,18 +19,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <QByteArray>
#include <QString>
#include <QModelIndex>
#include <QFileInfo>
#include "../common/basetypes.h"
#include "../common/treemodel.h"
#include "../common/ffs.h"
class FfsDumper : public QObject
class FfsDumper
{
Q_OBJECT
public:
explicit FfsDumper(TreeModel * treeModel, QObject *parent = 0);
explicit FfsDumper(TreeModel * treeModel);
~FfsDumper();
STATUS dump(const QModelIndex & root, const QString & path, const QString & guid = QString());

View File

@ -11,8 +11,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include <QCoreApplication>
#include <QVector>
#include <QPair>
#include <QString>
#include <QFileInfo>
@ -53,10 +51,9 @@ int main(int argc, char *argv[])
if (result)
return result;
QVector<QPair<QString, QModelIndex> > messages = ffsParser.getMessages();
QPair<QString, QModelIndex> msg;
foreach(msg, messages) {
std::cout << msg.first.toLatin1().constData() << std::endl;
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser.getMessages();
for (size_t i = 0; i < messages.size(); i++) {
std::cout << messages[i].first.toLatin1().constData() << std::endl;
}
FfsDumper ffsDumper(&model);
@ -75,7 +72,7 @@ int main(int argc, char *argv[])
}
}
else {
std::cout << "UEFIExtract 0.10.7" << std::endl << std::endl
std::cout << "UEFIExtract 0.10.8" << std::endl << std::endl
<< "Usage: UEFIExtract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl
<< "Return value is a bit mask where 0 at position N means that file with GUID_N was found and unpacked, 1 otherwise" << std::endl;
return 1;

View File

@ -13,11 +13,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "uefifind.h"
UEFIFind::UEFIFind(QObject *parent) :
QObject(parent)
UEFIFind::UEFIFind()
{
model = new TreeModel();
ffsParser = new FfsParser(model, this);
ffsParser = new FfsParser(model);
initDone = false;
}
@ -75,7 +74,7 @@ QString UEFIFind::guidToQString(const UINT8* guid)
STATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result)
{
QModelIndex root = model->index(0, 0);
QSet<QPair<QModelIndex, QModelIndex> > files;
std::set<std::pair<QModelIndex, QModelIndex> > files;
result.clear();
@ -84,14 +83,14 @@ STATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPat
return returned;
if (count) {
if (files.count())
result.append(QString("%1\n").arg(files.count()));
if (!files.empty())
result.append(QString("%1\n").arg(files.size()));
return ERR_SUCCESS;
}
QPair<QModelIndex, QModelIndex> indexes;
Q_FOREACH(indexes, files) {
for (std::set<std::pair<QModelIndex, QModelIndex> >::const_iterator citer = files.cbegin(); citer != files.cend(); ++citer) {
QByteArray data(16, '\x00');
std::pair<QModelIndex, QModelIndex> indexes = *citer;
if (!model->hasEmptyHeader(indexes.first))
data = model->header(indexes.first).left(16);
result.append(guidToQString((const UINT8*)data.constData()));
@ -107,7 +106,7 @@ STATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPat
return ERR_SUCCESS;
}
STATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, QSet<QPair<QModelIndex, QModelIndex> > & files)
STATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set<std::pair<QModelIndex, QModelIndex> > & files)
{
if (!index.isValid())
return ERR_SUCCESS;
@ -146,12 +145,12 @@ STATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexP
if (model->type(index) != Types::File) {
QModelIndex ffs = model->findParentOfType(index, Types::File);
if (model->type(index) == Types::Section && model->subtype(index) == EFI_SECTION_FREEFORM_SUBTYPE_GUID)
files.insert(QPair<QModelIndex, QModelIndex>(ffs, index));
files.insert(std::pair<QModelIndex, QModelIndex>(ffs, index));
else
files.insert(QPair<QModelIndex, QModelIndex>(ffs, QModelIndex()));
files.insert(std::pair<QModelIndex, QModelIndex>(ffs, QModelIndex()));
}
else
files.insert(QPair<QModelIndex, QModelIndex>(index, QModelIndex()));
files.insert(std::pair<QModelIndex, QModelIndex>(index, QModelIndex()));
break;
}

View File

@ -14,13 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef __UEFIFIND_H__
#define __UEFIFIND_H__
#include <set>
#include <QObject>
#include <QByteArray>
#include <QString>
#include <QDir>
#include <QFileInfo>
#include <QPair>
#include <QSet>
#include <QString>
#include <QUuid>
@ -28,19 +28,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "../common/ffsparser.h"
#include "../common/ffs.h"
class UEFIFind : public QObject
class UEFIFind
{
Q_OBJECT
public:
explicit UEFIFind(QObject *parent = 0);
explicit UEFIFind();
~UEFIFind();
STATUS init(const QString & path);
STATUS find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result);
private:
STATUS findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, QSet<QPair<QModelIndex, QModelIndex> > & files);
STATUS findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set<std::pair<QModelIndex, QModelIndex> > & files);
QString guidToQString(const UINT8* guid);
FfsParser* ffsParser;

View File

@ -148,7 +148,7 @@ int main(int argc, char *argv[])
return ERR_SUCCESS;
}
else {
std::cout << "UEFIFind 0.10.5" << std::endl << std::endl <<
std::cout << "UEFIFind 0.10.6" << std::endl << std::endl <<
"Usage: UEFIFind {header | body | all} {list | count} pattern imagefile" << std::endl <<
" or UEFIFind file patternsfile imagefile" << std::endl;
return ERR_INVALID_PARAMETER;