From f729dd58b7cf0414f51ccbdadd8b95fddd8ac314 Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Tue, 1 Mar 2016 09:12:37 +0100 Subject: [PATCH] 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 --- UEFIExtract/ffsdumper.cpp | 14 +++++++------- UEFIExtract/ffsdumper.h | 7 ++----- UEFIExtract/uefiextract_main.cpp | 11 ++++------- UEFIFind/uefifind.cpp | 23 +++++++++++------------ UEFIFind/uefifind.h | 12 +++++------- UEFIFind/uefifind_main.cpp | 2 +- 6 files changed, 30 insertions(+), 39 deletions(-) diff --git a/UEFIExtract/ffsdumper.cpp b/UEFIExtract/ffsdumper.cpp index 4069e0f..4acf9d2 100644 --- a/UEFIExtract/ffsdumper.cpp +++ b/UEFIExtract/ffsdumper.cpp @@ -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; diff --git a/UEFIExtract/ffsdumper.h b/UEFIExtract/ffsdumper.h index 817a9bd..4d2cd55 100644 --- a/UEFIExtract/ffsdumper.h +++ b/UEFIExtract/ffsdumper.h @@ -19,18 +19,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #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()); diff --git a/UEFIExtract/uefiextract_main.cpp b/UEFIExtract/uefiextract_main.cpp index dd361fa..1f23735 100644 --- a/UEFIExtract/uefiextract_main.cpp +++ b/UEFIExtract/uefiextract_main.cpp @@ -11,8 +11,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. */ #include -#include -#include #include #include @@ -53,10 +51,9 @@ int main(int argc, char *argv[]) if (result) return result; - QVector > messages = ffsParser.getMessages(); - QPair msg; - foreach(msg, messages) { - std::cout << msg.first.toLatin1().constData() << std::endl; + std::vector > 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; diff --git a/UEFIFind/uefifind.cpp b/UEFIFind/uefifind.cpp index 9f8467b..91eec33 100644 --- a/UEFIFind/uefifind.cpp +++ b/UEFIFind/uefifind.cpp @@ -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 > files; + std::set > 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 indexes; - Q_FOREACH(indexes, files) { + for (std::set >::const_iterator citer = files.cbegin(); citer != files.cend(); ++citer) { QByteArray data(16, '\x00'); + std::pair 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 > & files) +STATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set > & 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(ffs, index)); + files.insert(std::pair(ffs, index)); else - files.insert(QPair(ffs, QModelIndex())); + files.insert(std::pair(ffs, QModelIndex())); } else - files.insert(QPair(index, QModelIndex())); + files.insert(std::pair(index, QModelIndex())); break; } diff --git a/UEFIFind/uefifind.h b/UEFIFind/uefifind.h index bf50d57..7f222f6 100644 --- a/UEFIFind/uefifind.h +++ b/UEFIFind/uefifind.h @@ -14,13 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __UEFIFIND_H__ #define __UEFIFIND_H__ +#include + #include #include #include #include #include -#include -#include #include #include @@ -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 > & files); + STATUS findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set > & files); QString guidToQString(const UINT8* guid); FfsParser* ffsParser; diff --git a/UEFIFind/uefifind_main.cpp b/UEFIFind/uefifind_main.cpp index 3c99391..079e8d2 100644 --- a/UEFIFind/uefifind_main.cpp +++ b/UEFIFind/uefifind_main.cpp @@ -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;