mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 16:08:23 +08:00
Remove legacy UEFIFind and UEFIExtract in favour of new_engine branch
This commit is contained in:
parent
dff0142d6e
commit
46443370f2
@ -1,49 +0,0 @@
|
||||
/* uefiextract.cpp
|
||||
|
||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
|
||||
#include "uefiextract.h"
|
||||
|
||||
UEFIExtract::UEFIExtract(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
ffsEngine = new FfsEngine(this);
|
||||
}
|
||||
|
||||
UEFIExtract::~UEFIExtract()
|
||||
{
|
||||
delete ffsEngine;
|
||||
}
|
||||
|
||||
UINT8 UEFIExtract::init(const QString & path)
|
||||
{
|
||||
fileInfo = QFileInfo(path);
|
||||
|
||||
if (!fileInfo.exists())
|
||||
return ERR_FILE_OPEN;
|
||||
|
||||
QFile inputFile;
|
||||
inputFile.setFileName(path);
|
||||
|
||||
if (!inputFile.open(QFile::ReadOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
|
||||
QByteArray buffer = inputFile.readAll();
|
||||
inputFile.close();
|
||||
|
||||
return ffsEngine->parseImageFile(buffer);
|
||||
}
|
||||
|
||||
UINT8 UEFIExtract::extract(QString guid)
|
||||
{
|
||||
return ffsEngine->dump(ffsEngine->treeModel()->index(0, 0), fileInfo.fileName().append(".dump"), guid);
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/* uefiextract.h
|
||||
|
||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __UEFIEXTRACT_H__
|
||||
#define __UEFIEXTRACT_H__
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "../basetypes.h"
|
||||
#include "../ffsengine.h"
|
||||
|
||||
class UEFIExtract : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UEFIExtract(QObject *parent = 0);
|
||||
~UEFIExtract();
|
||||
|
||||
UINT8 init(const QString & path);
|
||||
UINT8 extract(QString guid = QString());
|
||||
|
||||
private:
|
||||
FfsEngine* ffsEngine;
|
||||
QFileInfo fileInfo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,43 +0,0 @@
|
||||
QT += core
|
||||
QT -= gui
|
||||
|
||||
TARGET = UEFIExtract
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
DEFINES += _CONSOLE
|
||||
|
||||
SOURCES += uefiextract_main.cpp \
|
||||
uefiextract.cpp \
|
||||
../types.cpp \
|
||||
../descriptor.cpp \
|
||||
../ffs.cpp \
|
||||
../ffsengine.cpp \
|
||||
../peimage.cpp \
|
||||
../treeitem.cpp \
|
||||
../treemodel.cpp \
|
||||
../LZMA/LzmaCompress.c \
|
||||
../LZMA/LzmaDecompress.c \
|
||||
../LZMA/SDK/C/LzFind.c \
|
||||
../LZMA/SDK/C/LzmaDec.c \
|
||||
../LZMA/SDK/C/LzmaEnc.c \
|
||||
../Tiano/EfiTianoDecompress.c \
|
||||
../Tiano/EfiTianoCompress.c \
|
||||
../Tiano/EfiTianoCompressLegacy.c
|
||||
|
||||
HEADERS += uefiextract.h \
|
||||
../basetypes.h \
|
||||
../descriptor.h \
|
||||
../gbe.h \
|
||||
../me.h \
|
||||
../ffs.h \
|
||||
../peimage.h \
|
||||
../types.h \
|
||||
../ffsengine.h \
|
||||
../treeitem.h \
|
||||
../treemodel.h \
|
||||
../LZMA/LzmaCompress.h \
|
||||
../LZMA/LzmaDecompress.h \
|
||||
../Tiano/EfiTianoDecompress.h \
|
||||
../Tiano/EfiTianoCompress.h
|
||||
|
@ -1,60 +0,0 @@
|
||||
/* uefiextract_main.cpp
|
||||
|
||||
Copyright (c) 2018, LongSoft. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <iostream>
|
||||
#include "uefiextract.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
a.setOrganizationName("LongSoft");
|
||||
a.setOrganizationDomain("longsoft.me");
|
||||
a.setApplicationName("UEFIExtract");
|
||||
|
||||
UEFIExtract w;
|
||||
UINT8 result = ERR_SUCCESS;
|
||||
UINT32 returned = 0;
|
||||
|
||||
if (a.arguments().length() > 32) {
|
||||
std::cout << "Too many arguments" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.arguments().length() > 1 ) {
|
||||
if (w.init(a.arguments().at(1)))
|
||||
return 1;
|
||||
|
||||
if (a.arguments().length() == 2) {
|
||||
result = w.extract();
|
||||
if (result)
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
for (int i = 2; i < a.arguments().length(); i++) {
|
||||
result = w.extract(a.arguments().at(i));
|
||||
if (result)
|
||||
returned |= (1 << (i - 1));
|
||||
}
|
||||
return returned;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
std::cout << "UEFIExtract 0.4.5" << std::endl << std::endl <<
|
||||
"Usage: uefiextract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl <<
|
||||
"Returned value is a bit mask where 0 on position N meant File with GUID_N was found and unpacked, 1 otherwise" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/* uefifind.cpp
|
||||
|
||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
|
||||
#include "uefifind.h"
|
||||
|
||||
UEFIFind::UEFIFind(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
ffsEngine = new FfsEngine(this);
|
||||
model = ffsEngine->treeModel();
|
||||
initDone = false;
|
||||
}
|
||||
|
||||
UEFIFind::~UEFIFind()
|
||||
{
|
||||
model = NULL;
|
||||
delete ffsEngine;
|
||||
}
|
||||
|
||||
UINT8 UEFIFind::init(const QString & path)
|
||||
{
|
||||
UINT8 result;
|
||||
|
||||
fileInfo = QFileInfo(path);
|
||||
|
||||
if (!fileInfo.exists())
|
||||
return ERR_FILE_OPEN;
|
||||
|
||||
QFile inputFile;
|
||||
inputFile.setFileName(path);
|
||||
|
||||
if (!inputFile.open(QFile::ReadOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
|
||||
QByteArray buffer = inputFile.readAll();
|
||||
inputFile.close();
|
||||
|
||||
result = ffsEngine->parseImageFile(buffer);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
initDone = true;
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
QString UEFIFind::guidToQString(const UINT8* guid)
|
||||
{
|
||||
const UINT32 u32 = *(const UINT32*)guid;
|
||||
const UINT16 u16_1 = *(const UINT16*)(guid + 4);
|
||||
const UINT16 u16_2 = *(const UINT16*)(guid + 6);
|
||||
const UINT8 u8_1 = *(const UINT8*)(guid + 8);
|
||||
const UINT8 u8_2 = *(const UINT8*)(guid + 9);
|
||||
const UINT8 u8_3 = *(const UINT8*)(guid + 10);
|
||||
const UINT8 u8_4 = *(const UINT8*)(guid + 11);
|
||||
const UINT8 u8_5 = *(const UINT8*)(guid + 12);
|
||||
const UINT8 u8_6 = *(const UINT8*)(guid + 13);
|
||||
const UINT8 u8_7 = *(const UINT8*)(guid + 14);
|
||||
const UINT8 u8_8 = *(const UINT8*)(guid + 15);
|
||||
|
||||
return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11").hexarg2(u32, 8).hexarg2(u16_1, 4).hexarg2(u16_2, 4).hexarg2(u8_1, 2).hexarg2(u8_2, 2)
|
||||
.hexarg2(u8_3, 2).hexarg2(u8_4, 2).hexarg2(u8_5, 2).hexarg2(u8_6, 2).hexarg2(u8_7, 2).hexarg2(u8_8, 2);
|
||||
}
|
||||
|
||||
UINT8 UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result)
|
||||
{
|
||||
QModelIndex root = model->index(0, 0);
|
||||
QSet<QPair<QModelIndex, QModelIndex> > files;
|
||||
|
||||
result.clear();
|
||||
|
||||
UINT8 returned = findFileRecursive(root, hexPattern, mode, files);
|
||||
if (returned)
|
||||
return returned;
|
||||
|
||||
if (count) {
|
||||
if (files.count())
|
||||
result.append(QString("%1\n").arg(files.count()));
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
QPair<QModelIndex, QModelIndex> indexes;
|
||||
Q_FOREACH(indexes, files) {
|
||||
QByteArray data = model->header(indexes.first).left(16);
|
||||
result.append(guidToQString((const UINT8*)data.constData()));
|
||||
|
||||
// Special case of freeform subtype GUID files
|
||||
if (indexes.second.isValid() && model->subtype(indexes.second) == EFI_SECTION_FREEFORM_SUBTYPE_GUID) {
|
||||
data = model->header(indexes.second).left(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
|
||||
result.append(" ").append(guidToQString((const UINT8*)data.constData() + sizeof(EFI_COMMON_SECTION_HEADER)));
|
||||
}
|
||||
|
||||
result.append("\n");
|
||||
|
||||
}
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT8 UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, QSet<QPair<QModelIndex, QModelIndex> > & files)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return ERR_SUCCESS;
|
||||
|
||||
if (hexPattern.isEmpty())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
|
||||
// Check for "all substrings" pattern
|
||||
if (hexPattern.count('.') == hexPattern.length())
|
||||
return ERR_SUCCESS;
|
||||
|
||||
bool hasChildren = (model->rowCount(index) > 0);
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
findFileRecursive(index.child(i, index.column()), hexPattern, mode, files);
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
if (hasChildren) {
|
||||
if (mode == SEARCH_MODE_HEADER || mode == SEARCH_MODE_ALL)
|
||||
data.append(model->header(index));
|
||||
}
|
||||
else {
|
||||
if (mode == SEARCH_MODE_HEADER)
|
||||
data.append(model->header(index));
|
||||
else if (mode == SEARCH_MODE_BODY)
|
||||
data.append(model->body(index));
|
||||
else
|
||||
data.append(model->header(index)).append(model->body(index));
|
||||
}
|
||||
|
||||
QString hexBody = QString(data.toHex());
|
||||
QRegExp regexp = QRegExp(QString(hexPattern), Qt::CaseInsensitive);
|
||||
INT32 offset = regexp.indexIn(hexBody);
|
||||
while (offset >= 0) {
|
||||
if (offset % 2 == 0) {
|
||||
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));
|
||||
else
|
||||
files.insert(QPair<QModelIndex, QModelIndex>(ffs, QModelIndex()));
|
||||
}
|
||||
else
|
||||
files.insert(QPair<QModelIndex, QModelIndex>(index, QModelIndex()));
|
||||
|
||||
break;
|
||||
}
|
||||
offset = regexp.indexIn(hexBody, offset + 1);
|
||||
}
|
||||
|
||||
return ERR_SUCCESS;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/* uefifind.h
|
||||
|
||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __UEFIFIND_H__
|
||||
#define __UEFIFIND_H__
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
#include "../basetypes.h"
|
||||
#include "../ffsengine.h"
|
||||
#include "../ffs.h"
|
||||
|
||||
class UEFIFind : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UEFIFind(QObject *parent = 0);
|
||||
~UEFIFind();
|
||||
|
||||
UINT8 init(const QString & path);
|
||||
UINT8 find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result);
|
||||
|
||||
private:
|
||||
UINT8 findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, QSet<QPair<QModelIndex, QModelIndex> > & files);
|
||||
QString guidToQString(const UINT8* guid);
|
||||
|
||||
FfsEngine* ffsEngine;
|
||||
TreeModel* model;
|
||||
QFileInfo fileInfo;
|
||||
bool initDone;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,43 +0,0 @@
|
||||
QT += core
|
||||
QT -= gui
|
||||
|
||||
TARGET = UEFIFind
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
DEFINES += _CONSOLE _DISABLE_ENGINE_MESSAGES
|
||||
|
||||
SOURCES += uefifind_main.cpp \
|
||||
uefifind.cpp \
|
||||
../types.cpp \
|
||||
../descriptor.cpp \
|
||||
../ffs.cpp \
|
||||
../ffsengine.cpp \
|
||||
../peimage.cpp \
|
||||
../treeitem.cpp \
|
||||
../treemodel.cpp \
|
||||
../LZMA/LzmaCompress.c \
|
||||
../LZMA/LzmaDecompress.c \
|
||||
../LZMA/SDK/C/LzFind.c \
|
||||
../LZMA/SDK/C/LzmaDec.c \
|
||||
../LZMA/SDK/C/LzmaEnc.c \
|
||||
../Tiano/EfiTianoDecompress.c \
|
||||
../Tiano/EfiTianoCompress.c \
|
||||
../Tiano/EfiTianoCompressLegacy.c
|
||||
|
||||
HEADERS += uefifind.h \
|
||||
../basetypes.h \
|
||||
../descriptor.h \
|
||||
../gbe.h \
|
||||
../me.h \
|
||||
../ffs.h \
|
||||
../peimage.h \
|
||||
../types.h \
|
||||
../ffsengine.h \
|
||||
../treeitem.h \
|
||||
../treemodel.h \
|
||||
../LZMA/LzmaCompress.h \
|
||||
../LZMA/LzmaDecompress.h \
|
||||
../Tiano/EfiTianoDecompress.h \
|
||||
../Tiano/EfiTianoCompress.h
|
||||
|
@ -1,72 +0,0 @@
|
||||
/* uefifind_main.cpp
|
||||
|
||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
#include <QCoreApplication>
|
||||
#include <iostream>
|
||||
#include "uefifind.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
a.setOrganizationName("CodeRush");
|
||||
a.setOrganizationDomain("coderush.me");
|
||||
a.setApplicationName("UEFIFind");
|
||||
|
||||
UEFIFind w;
|
||||
UINT8 result;
|
||||
|
||||
if (a.arguments().length() == 5) {
|
||||
result = w.init(a.arguments().at(4));
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
// Get search mode
|
||||
UINT8 mode;
|
||||
if (a.arguments().at(1) == QString("header"))
|
||||
mode = SEARCH_MODE_HEADER;
|
||||
else if (a.arguments().at(1) == QString("body"))
|
||||
mode = SEARCH_MODE_BODY;
|
||||
else if (a.arguments().at(1) == QString("all"))
|
||||
mode = SEARCH_MODE_ALL;
|
||||
else
|
||||
return ERR_INVALID_PARAMETER;
|
||||
|
||||
// Get result type
|
||||
bool count;
|
||||
if (a.arguments().at(2) == QString("list"))
|
||||
count = false;
|
||||
else if (a.arguments().at(2) == QString("count"))
|
||||
count = true;
|
||||
else
|
||||
return ERR_INVALID_PARAMETER;
|
||||
|
||||
// Go find the supplied pattern
|
||||
QString found;
|
||||
result = w.find(mode, count, a.arguments().at(3), found);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
// Nothing was found
|
||||
if (found.isEmpty())
|
||||
return ERR_ITEM_NOT_FOUND;
|
||||
|
||||
// Print result
|
||||
std::cout << found.toStdString();
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
else {
|
||||
std::cout << "UEFIFind 0.3.4" << std::endl << std::endl <<
|
||||
"Usage: uefifind {header | body | all} {list | count} pattern imagefile\n";
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ export PATH="/opt/qt56sm/bin:$PATH"
|
||||
echo "Attempting to build UEFITool for macOS..."
|
||||
|
||||
UEFITOOL_VER=$(cat uefitool.cpp | grep ^version | cut -d'"' -f2)
|
||||
UEFIEXTRACT_VER=$(cat UEFIExtract/uefiextract_main.cpp | grep '"UEFIExtract [0-9]' | cut -d'"' -f2 | cut -d' ' -f2)
|
||||
UEFIFIND_VER=$(cat UEFIFind/uefifind_main.cpp | grep '"UEFIFind [0-9]' | cut -d'"' -f2 | cut -d' ' -f2)
|
||||
UEFIPATCH_VER=$(cat UEFIPatch/uefipatch_main.cpp | grep '"UEFIPatch [0-9]' | cut -d'"' -f2 | cut -d' ' -f2)
|
||||
UEFIREPLACE_VER=$(cat UEFIReplace/uefireplace_main.cpp | grep '"UEFIReplace [0-9]' | cut -d'"' -f2 | cut -d' ' -f2)
|
||||
|
||||
@ -59,8 +57,6 @@ rm -rf dist
|
||||
mkdir -p dist || exit 1
|
||||
|
||||
build_tool UEFITool "$UEFITOOL_VER" uefitool.pro
|
||||
build_tool UEFIExtract "$UEFIEXTRACT_VER" uefiextract.pro
|
||||
build_tool UEFIFind "$UEFIFIND_VER" uefifind.pro
|
||||
build_tool UEFIPatch "$UEFIPATCH_VER" uefipatch.pro patches.txt
|
||||
build_tool UEFIReplace "$UEFIREPLACE_VER" uefireplace.pro
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user