mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
parent
62d80d40da
commit
ee3a256206
@ -13,6 +13,7 @@ SOURCES += uefiextract_main.cpp \
|
|||||||
../common/ffs.cpp \
|
../common/ffs.cpp \
|
||||||
../common/nvram.cpp \
|
../common/nvram.cpp \
|
||||||
../common/ffsparser.cpp \
|
../common/ffsparser.cpp \
|
||||||
|
../common/fitparser.cpp \
|
||||||
../common/peimage.cpp \
|
../common/peimage.cpp \
|
||||||
../common/treeitem.cpp \
|
../common/treeitem.cpp \
|
||||||
../common/treemodel.cpp \
|
../common/treemodel.cpp \
|
||||||
@ -29,6 +30,7 @@ HEADERS += ffsdumper.h \
|
|||||||
../common/ffs.h \
|
../common/ffs.h \
|
||||||
../common/nvram.h \
|
../common/nvram.h \
|
||||||
../common/ffsparser.h \
|
../common/ffsparser.h \
|
||||||
|
../common/fitparser.h \
|
||||||
../common/peimage.h \
|
../common/peimage.h \
|
||||||
../common/types.h \
|
../common/types.h \
|
||||||
../common/treeitem.h \
|
../common/treeitem.h \
|
||||||
|
@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "../common/ffsparser.h"
|
#include "../common/ffsparser.h"
|
||||||
|
#include "../common/fitparser.h"
|
||||||
#include "ffsdumper.h"
|
#include "ffsdumper.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -32,36 +33,75 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (a.arguments().length() > 1) {
|
if (a.arguments().length() > 1) {
|
||||||
|
// Check that input file exists
|
||||||
QString path = a.arguments().at(1);
|
QString path = a.arguments().at(1);
|
||||||
QFileInfo fileInfo(path);
|
QFileInfo fileInfo(path);
|
||||||
if (!fileInfo.exists())
|
if (!fileInfo.exists())
|
||||||
return ERR_FILE_OPEN;
|
return ERR_FILE_OPEN;
|
||||||
|
|
||||||
|
// Open the input file
|
||||||
QFile inputFile;
|
QFile inputFile;
|
||||||
inputFile.setFileName(path);
|
inputFile.setFileName(path);
|
||||||
if (!inputFile.open(QFile::ReadOnly))
|
if (!inputFile.open(QFile::ReadOnly))
|
||||||
return ERR_FILE_OPEN;
|
return ERR_FILE_OPEN;
|
||||||
|
|
||||||
|
// Read and close the file
|
||||||
QByteArray buffer = inputFile.readAll();
|
QByteArray buffer = inputFile.readAll();
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
|
|
||||||
|
// Create model and ffsParser
|
||||||
TreeModel model;
|
TreeModel model;
|
||||||
FfsParser ffsParser(&model);
|
FfsParser ffsParser(&model);
|
||||||
|
// Parse input buffer
|
||||||
STATUS result = ffsParser.parse(buffer);
|
STATUS result = ffsParser.parse(buffer);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
// Show ffsParser's messages
|
||||||
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser.getMessages();
|
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser.getMessages();
|
||||||
for (size_t i = 0; i < messages.size(); i++) {
|
for (size_t i = 0; i < messages.size(); i++) {
|
||||||
std::cout << messages[i].first.toLatin1().constData() << std::endl;
|
std::cout << messages[i].first.toLatin1().constData() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get last VTF
|
||||||
|
QModelIndex lastVtf = ffsParser.getLastVtf();
|
||||||
|
if (lastVtf.isValid()) {
|
||||||
|
// Create fitParser
|
||||||
|
FitParser fitParser(&model);
|
||||||
|
// Find and parse FIT table
|
||||||
|
result = fitParser.parse(model.index(0, 0), lastVtf);
|
||||||
|
if (ERR_SUCCESS == result) {
|
||||||
|
// Show fitParser's messages
|
||||||
|
std::vector<std::pair<QString, QModelIndex> > fitMessages = fitParser.getMessages();
|
||||||
|
for (size_t i = 0; i < fitMessages.size(); i++) {
|
||||||
|
std::cout << fitMessages[i].first.toLatin1().constData() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show FIT table
|
||||||
|
std::vector<std::vector<QString> > fitTable = fitParser.getFitTable();
|
||||||
|
if (fitTable.size()) {
|
||||||
|
std::cout << "-------------------------------------------------------------------" << std::endl;
|
||||||
|
std::cout << " Address | Size | Ver | Type | CS " << std::endl;
|
||||||
|
std::cout << "-------------------------------------------------------------------" << std::endl;
|
||||||
|
for (size_t i = 0; i < fitTable.size(); i++) {
|
||||||
|
std::cout << fitTable[i][0].toLatin1().constData() << " | "
|
||||||
|
<< fitTable[i][1].toLatin1().constData() << " | "
|
||||||
|
<< fitTable[i][2].toLatin1().constData() << " | "
|
||||||
|
<< fitTable[i][3].toLatin1().constData() << " | "
|
||||||
|
<< fitTable[i][4].toLatin1().constData() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create ffsDumper
|
||||||
FfsDumper ffsDumper(&model);
|
FfsDumper ffsDumper(&model);
|
||||||
|
|
||||||
|
// Dump everyting
|
||||||
if (a.arguments().length() == 2) {
|
if (a.arguments().length() == 2) {
|
||||||
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump")) != ERR_SUCCESS);
|
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump")) != ERR_SUCCESS);
|
||||||
}
|
}
|
||||||
else {
|
else { // Dump specific files
|
||||||
UINT32 returned = 0;
|
UINT32 returned = 0;
|
||||||
for (int i = 2; i < a.arguments().length(); i++) {
|
for (int i = 2; i < a.arguments().length(); i++) {
|
||||||
result = ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"), a.arguments().at(i));
|
result = ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"), a.arguments().at(i));
|
||||||
@ -71,8 +111,8 @@ int main(int argc, char *argv[])
|
|||||||
return returned;
|
return returned;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else { // Show version and usage information
|
||||||
std::cout << "UEFIExtract 0.10.8" << std::endl << std::endl
|
std::cout << "UEFIExtract 0.10.9" << std::endl << std::endl
|
||||||
<< "Usage: UEFIExtract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << 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 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;
|
||||||
|
@ -57,7 +57,7 @@ STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIn
|
|||||||
|
|
||||||
// Add FIT header to fitTable
|
// Add FIT header to fitTable
|
||||||
std::vector<QString> currentStrings;
|
std::vector<QString> currentStrings;
|
||||||
currentStrings.push_back(QObject::tr("_FIT_ "));
|
currentStrings.push_back(QObject::tr("_FIT_ "));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(fitSize, 8));
|
currentStrings.push_back(QObject::tr("%1").hexarg2(fitSize, 8));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(fitHeader->Version, 4));
|
currentStrings.push_back(QObject::tr("%1").hexarg2(fitHeader->Version, 4));
|
||||||
currentStrings.push_back(fitEntryTypeToQString(fitHeader->Type));
|
currentStrings.push_back(fitEntryTypeToQString(fitHeader->Type));
|
||||||
@ -110,17 +110,17 @@ STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIn
|
|||||||
QString FitParser::fitEntryTypeToQString(UINT8 type)
|
QString FitParser::fitEntryTypeToQString(UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type & 0x7F) {
|
switch (type & 0x7F) {
|
||||||
case FIT_TYPE_HEADER: return QObject::tr("Header");
|
case FIT_TYPE_HEADER: return QObject::tr("Header ");
|
||||||
case FIT_TYPE_MICROCODE: return QObject::tr("Microcode");
|
case FIT_TYPE_MICROCODE: return QObject::tr("Microcode ");
|
||||||
case FIT_TYPE_BIOS_AC_MODULE: return QObject::tr("BIOS ACM");
|
case FIT_TYPE_BIOS_AC_MODULE: return QObject::tr("BIOS ACM ");
|
||||||
case FIT_TYPE_BIOS_INIT_MODULE: return QObject::tr("BIOS Init");
|
case FIT_TYPE_BIOS_INIT_MODULE: return QObject::tr("BIOS Init ");
|
||||||
case FIT_TYPE_TPM_POLICY: return QObject::tr("TPM Policy");
|
case FIT_TYPE_TPM_POLICY: return QObject::tr("TPM Policy ");
|
||||||
case FIT_TYPE_BIOS_POLICY_DATA: return QObject::tr("BIOS Policy Data");
|
case FIT_TYPE_BIOS_POLICY_DATA: return QObject::tr("BIOS Policy Data ");
|
||||||
case FIT_TYPE_TXT_CONF_POLICY: return QObject::tr("TXT Configuration Policy");
|
case FIT_TYPE_TXT_CONF_POLICY: return QObject::tr("TXT Configuration Policy");
|
||||||
case FIT_TYPE_AC_KEY_MANIFEST: return QObject::tr("BootGuard Key Manifest");
|
case FIT_TYPE_AC_KEY_MANIFEST: return QObject::tr("BootGuard Key Manifest ");
|
||||||
case FIT_TYPE_AC_BOOT_POLICY: return QObject::tr("BootGuard Boot Policy");
|
case FIT_TYPE_AC_BOOT_POLICY: return QObject::tr("BootGuard Boot Policy ");
|
||||||
case FIT_TYPE_EMPTY: return QObject::tr("Empty");
|
case FIT_TYPE_EMPTY: return QObject::tr("Empty ");
|
||||||
default: return QObject::tr("Unknown");
|
default: return QObject::tr("Unknown ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user