mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 17:38:22 +08:00
UE 0.10.1
- Extract only by listed file GUIDs is now possible for UE - Postcodes must be hexadecimal
This commit is contained in:
parent
8f7cc0d20e
commit
6a63d1f431
@ -22,10 +22,10 @@ FfsDumper::~FfsDumper()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS FfsDumper::dump(const QModelIndex & root, const QString & path)
|
STATUS FfsDumper::dump(const QModelIndex & root, const QString & path, const QString & guid)
|
||||||
{
|
{
|
||||||
dumped = false;
|
dumped = false;
|
||||||
UINT8 result = recursiveDump(root, path);
|
UINT8 result = recursiveDump(root, path, guid);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
else if (!dumped)
|
else if (!dumped)
|
||||||
@ -33,12 +33,15 @@ STATUS FfsDumper::dump(const QModelIndex & root, const QString & path)
|
|||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path)
|
STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path, const QString & guid)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
|
if (guid.isEmpty() ||
|
||||||
|
guidToQString(*(const EFI_GUID*)model->header(index).constData()) == guid ||
|
||||||
|
guidToQString(*(const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData()) == guid) {
|
||||||
|
|
||||||
if (dir.cd(path))
|
if (dir.cd(path))
|
||||||
return ERR_DIR_ALREADY_EXIST;
|
return ERR_DIR_ALREADY_EXIST;
|
||||||
@ -77,12 +80,13 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path)
|
|||||||
file.write(info.toLatin1());
|
file.write(info.toLatin1());
|
||||||
file.close();
|
file.close();
|
||||||
dumped = true;
|
dumped = true;
|
||||||
|
}
|
||||||
|
|
||||||
UINT8 result;
|
UINT8 result;
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
QModelIndex childIndex = index.child(i, 0);
|
QModelIndex childIndex = index.child(i, 0);
|
||||||
QString childPath = QString("%1/%2 %3").arg(path).arg(i).arg(model->text(childIndex).isEmpty() ? model->name(childIndex) : model->text(childIndex));
|
QString childPath = QString("%1/%2 %3").arg(path).arg(i).arg(model->text(childIndex).isEmpty() ? model->name(childIndex) : model->text(childIndex));
|
||||||
result = recursiveDump(childIndex, childPath);
|
result = recursiveDump(childIndex, childPath, guid);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include "../common/basetypes.h"
|
#include "../common/basetypes.h"
|
||||||
#include "../common/treemodel.h"
|
#include "../common/treemodel.h"
|
||||||
|
#include "../common/ffs.h"
|
||||||
|
|
||||||
class FfsDumper : public QObject
|
class FfsDumper : public QObject
|
||||||
{
|
{
|
||||||
@ -32,10 +33,10 @@ public:
|
|||||||
explicit FfsDumper(TreeModel * treeModel, QObject *parent = 0);
|
explicit FfsDumper(TreeModel * treeModel, QObject *parent = 0);
|
||||||
~FfsDumper();
|
~FfsDumper();
|
||||||
|
|
||||||
STATUS dump(const QModelIndex & root, const QString & path);
|
STATUS dump(const QModelIndex & root, const QString & path, const QString & guid = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
STATUS recursiveDump(const QModelIndex & root, const QString & path);
|
STATUS recursiveDump(const QModelIndex & root, const QString & path, const QString & guid);
|
||||||
TreeModel* model;
|
TreeModel* model;
|
||||||
bool dumped;
|
bool dumped;
|
||||||
};
|
};
|
||||||
|
@ -28,6 +28,11 @@ int main(int argc, char *argv[])
|
|||||||
a.setOrganizationDomain("coderush.me");
|
a.setOrganizationDomain("coderush.me");
|
||||||
a.setApplicationName("UEFIExtract");
|
a.setApplicationName("UEFIExtract");
|
||||||
|
|
||||||
|
if (a.arguments().length() > 32) {
|
||||||
|
std::cout << "Too many arguments" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (a.arguments().length() > 1) {
|
if (a.arguments().length() > 1) {
|
||||||
QString path = a.arguments().at(1);
|
QString path = a.arguments().at(1);
|
||||||
QFileInfo fileInfo(path);
|
QFileInfo fileInfo(path);
|
||||||
@ -55,11 +60,24 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
FfsDumper ffsDumper(&model);
|
FfsDumper ffsDumper(&model);
|
||||||
return ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"));
|
|
||||||
|
if (a.arguments().length() == 2) {
|
||||||
|
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump")) != ERR_SUCCESS);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "UEFIExtract 0.10.0" << std::endl << std::endl
|
UINT32 returned = 0;
|
||||||
<< "Usage: uefiextract imagefile" << std::endl;
|
for (int i = 2; i < a.arguments().length(); i++) {
|
||||||
|
result = ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"), a.arguments().at(i));
|
||||||
|
if (result)
|
||||||
|
returned |= (1 << (i - 1));
|
||||||
|
}
|
||||||
|
return returned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "UEFIExtract 0.10.1" << 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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1715,12 +1715,12 @@ STATUS FfsParser::parsePostcodeSectionHeader(const QByteArray & section, const U
|
|||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
QString name = sectionTypeToQString(sectionHeader->Type) + tr(" section");
|
QString name = sectionTypeToQString(sectionHeader->Type) + tr(" section");
|
||||||
QString info = tr("Type: %1h\nFull size: %2h (%3)\nHeader size: %4h (%5)\nBody size: %6h (%7)\nPostcode: %8\n")
|
QString info = tr("Type: %1h\nFull size: %2h (%3)\nHeader size: %4h (%5)\nBody size: %6h (%7)\nPostcode: %8h\n")
|
||||||
.hexarg2(postcodeHeader->Type, 2)
|
.hexarg2(postcodeHeader->Type, 2)
|
||||||
.hexarg(section.size()).arg(section.size())
|
.hexarg(section.size()).arg(section.size())
|
||||||
.hexarg(header.size()).arg(header.size())
|
.hexarg(header.size()).arg(header.size())
|
||||||
.hexarg(body.size()).arg(body.size())
|
.hexarg(body.size()).arg(body.size())
|
||||||
.arg(postCode);
|
.hexarg(postCode);
|
||||||
|
|
||||||
// Construct parsing data
|
// Construct parsing data
|
||||||
pdata.offset += parentOffset;
|
pdata.offset += parentOffset;
|
||||||
|
Loading…
Reference in New Issue
Block a user