mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
Implement dumping GUIDs from firmware and add more to builtin database
This commit is contained in:
parent
afce02430a
commit
d16c438069
@ -65,6 +65,7 @@ markingEnabled(true)
|
||||
connect(ui->actionLoadGuidDatabase, SIGNAL(triggered()), this, SLOT(loadGuidDatabase()));
|
||||
connect(ui->actionUnloadGuidDatabase, SIGNAL(triggered()), this, SLOT(unloadGuidDatabase()));
|
||||
connect(ui->actionLoadDefaultGuidDatabase, SIGNAL(triggered()), this, SLOT(loadDefaultGuidDatabase()));
|
||||
connect(ui->actionExportDiscoveredGuids, SIGNAL(triggered()), this, SLOT(exportDiscoveredGuids()));
|
||||
connect(ui->actionGenerateReport, SIGNAL(triggered()), this, SLOT(generateReport()));
|
||||
connect(ui->actionToggleBootGuardMarking, SIGNAL(toggled(bool)), this, SLOT(toggleBootGuardMarking(bool)));
|
||||
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));
|
||||
@ -654,6 +655,9 @@ void UEFITool::openImageFile(QString path)
|
||||
// Enable generateReport
|
||||
ui->actionGenerateReport->setEnabled(true);
|
||||
|
||||
// Enable saving GUIDs
|
||||
ui->actionExportDiscoveredGuids->setEnabled(true);
|
||||
|
||||
// Set current directory
|
||||
currentDir = fileInfo.absolutePath();
|
||||
|
||||
@ -1009,6 +1013,16 @@ void UEFITool::loadDefaultGuidDatabase()
|
||||
openImageFile(currentPath);
|
||||
}
|
||||
|
||||
void UEFITool::exportDiscoveredGuids()
|
||||
{
|
||||
GuidDatabase db = guidDatabaseFromTreeRecursive(model, model->index(0, 0));
|
||||
if (!db.empty()) {
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Save parsed GUIDs to datavase"), currentPath + ".guids.csv", tr("Comma-separated values files (*.csv);;All files (*)"));
|
||||
if (!path.isEmpty())
|
||||
guidDatabseExportToFile(path, db);
|
||||
}
|
||||
}
|
||||
|
||||
void UEFITool::generateReport()
|
||||
{
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Save report to text file"), currentPath + ".report.txt", tr("Text files (*.txt);;All files (*)"));
|
||||
|
@ -117,8 +117,9 @@ private slots:
|
||||
void writeSettings();
|
||||
|
||||
void loadGuidDatabase();
|
||||
void unloadGuidDatabase();
|
||||
void loadDefaultGuidDatabase();
|
||||
void unloadGuidDatabase();
|
||||
void loadDefaultGuidDatabase();
|
||||
void exportDiscoveredGuids();
|
||||
void generateReport();
|
||||
|
||||
void currentTabChanged(int index);
|
||||
|
@ -327,6 +327,7 @@
|
||||
<addaction name="actionLoadGuidDatabase"/>
|
||||
<addaction name="actionLoadDefaultGuidDatabase"/>
|
||||
<addaction name="actionUnloadGuidDatabase"/>
|
||||
<addaction name="actionExportDiscoveredGuids"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
@ -907,6 +908,14 @@
|
||||
<string>Ctrl+Alt+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportDiscoveredGuids">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export discovered GUIDs</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
@ -14,24 +14,15 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include "ubytearray.h"
|
||||
#include "ffs.h"
|
||||
|
||||
#if defined(U_ENABLE_GUID_DATABASE_SUPPORT)
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#if defined(U_ENABLE_GUID_DATABASE_SUPPORT)
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
|
||||
struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bool>
|
||||
{
|
||||
bool operator()(const EFI_GUID& lhs, const EFI_GUID& rhs) const
|
||||
{
|
||||
return (memcmp(&lhs, &rhs, sizeof(EFI_GUID)) < 0);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map<EFI_GUID, UString, OperatorLessForGuids> GuidToUStringMap;
|
||||
static GuidToUStringMap gGuidToUStringMap;
|
||||
static GuidDatabase gLocalGuidDatabase;
|
||||
|
||||
#ifdef QT_CORE_LIB
|
||||
|
||||
@ -61,7 +52,7 @@ static std::string readGuidDatabase(const UString &path) {
|
||||
|
||||
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
||||
{
|
||||
gGuidToUStringMap.clear();
|
||||
gLocalGuidDatabase.clear();
|
||||
|
||||
std::stringstream file(readGuidDatabase(path));
|
||||
|
||||
@ -90,16 +81,16 @@ void initGuidDatabase(const UString & path, UINT32* numEntries)
|
||||
if (!ustringToGuid(lineParts[0], guid))
|
||||
continue;
|
||||
|
||||
gGuidToUStringMap.insert(GuidToUStringMap::value_type(guid, lineParts[1]));
|
||||
gLocalGuidDatabase[guid] = lineParts[1];
|
||||
}
|
||||
|
||||
if (numEntries)
|
||||
*numEntries = (UINT32)gGuidToUStringMap.size();
|
||||
*numEntries = (UINT32)gLocalGuidDatabase.size();
|
||||
}
|
||||
|
||||
UString guidDatabaseLookup(const EFI_GUID & guid)
|
||||
{
|
||||
return gGuidToUStringMap[guid];
|
||||
return gLocalGuidDatabase[guid];
|
||||
}
|
||||
|
||||
#else
|
||||
@ -116,3 +107,35 @@ UString guidDatabaseLookup(const EFI_GUID & guid)
|
||||
return UString();
|
||||
}
|
||||
#endif
|
||||
|
||||
GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex index)
|
||||
{
|
||||
GuidDatabase db;
|
||||
|
||||
if (!index.isValid())
|
||||
return db;
|
||||
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
GuidDatabase tmpDb = guidDatabaseFromTreeRecursive(model, index.child(i, index.column()));
|
||||
db.insert(tmpDb.begin(), tmpDb.end());
|
||||
}
|
||||
|
||||
if (model->type(index) == Types::File && !model->text(index).isEmpty())
|
||||
db[readUnaligned((const EFI_GUID*)model->header(index).left(16).constData())] = model->text(index);
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
USTATUS guidDatabseExportToFile(const UString & outPath, GuidDatabase & db)
|
||||
{
|
||||
std::ofstream outputFile(outPath.toLocal8Bit(), std::ios::out | std::ios::trunc);
|
||||
if (!outputFile)
|
||||
return U_FILE_OPEN;
|
||||
for (GuidDatabase::iterator it = db.begin(); it != db.end(); it++) {
|
||||
std::string guid(guidToUString (it->first, false).toLocal8Bit());
|
||||
std::string name(it->second.toLocal8Bit());
|
||||
outputFile << guid << ',' << name << '\n';
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* guiddatabase.h
|
||||
|
||||
Copyright (c) 2017, Nikolaj Schlej. All rights reserved.
|
||||
Copyright (c) 2017, 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
|
||||
@ -13,10 +13,28 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#ifndef GUID_DATABASE_H
|
||||
#define GUID_DATABASE_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "basetypes.h"
|
||||
#include "ustring.h"
|
||||
#include "ffsparser.h"
|
||||
#include "ffs.h"
|
||||
#include "utility.h"
|
||||
|
||||
struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bool>
|
||||
{
|
||||
bool operator()(const EFI_GUID& lhs, const EFI_GUID& rhs) const
|
||||
{
|
||||
return (memcmp(&lhs, &rhs, sizeof(EFI_GUID)) < 0);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map<EFI_GUID, UString, OperatorLessForGuids> GuidDatabase;
|
||||
|
||||
UString guidDatabaseLookup(const EFI_GUID & guid);
|
||||
void initGuidDatabase(const UString & path = "", UINT32* numEntries = NULL);
|
||||
GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex index);
|
||||
USTATUS guidDatabseExportToFile(const UString & outPath, GuidDatabase & db);
|
||||
|
||||
#endif // GUID_DATABASE_H
|
||||
|
605
common/guids.csv
605
common/guids.csv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user