mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 09:28: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->actionLoadGuidDatabase, SIGNAL(triggered()), this, SLOT(loadGuidDatabase()));
|
||||||
connect(ui->actionUnloadGuidDatabase, SIGNAL(triggered()), this, SLOT(unloadGuidDatabase()));
|
connect(ui->actionUnloadGuidDatabase, SIGNAL(triggered()), this, SLOT(unloadGuidDatabase()));
|
||||||
connect(ui->actionLoadDefaultGuidDatabase, SIGNAL(triggered()), this, SLOT(loadDefaultGuidDatabase()));
|
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->actionGenerateReport, SIGNAL(triggered()), this, SLOT(generateReport()));
|
||||||
connect(ui->actionToggleBootGuardMarking, SIGNAL(toggled(bool)), this, SLOT(toggleBootGuardMarking(bool)));
|
connect(ui->actionToggleBootGuardMarking, SIGNAL(toggled(bool)), this, SLOT(toggleBootGuardMarking(bool)));
|
||||||
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));
|
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));
|
||||||
@ -654,6 +655,9 @@ void UEFITool::openImageFile(QString path)
|
|||||||
// Enable generateReport
|
// Enable generateReport
|
||||||
ui->actionGenerateReport->setEnabled(true);
|
ui->actionGenerateReport->setEnabled(true);
|
||||||
|
|
||||||
|
// Enable saving GUIDs
|
||||||
|
ui->actionExportDiscoveredGuids->setEnabled(true);
|
||||||
|
|
||||||
// Set current directory
|
// Set current directory
|
||||||
currentDir = fileInfo.absolutePath();
|
currentDir = fileInfo.absolutePath();
|
||||||
|
|
||||||
@ -1009,6 +1013,16 @@ void UEFITool::loadDefaultGuidDatabase()
|
|||||||
openImageFile(currentPath);
|
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()
|
void UEFITool::generateReport()
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getSaveFileName(this, tr("Save report to text file"), currentPath + ".report.txt", tr("Text files (*.txt);;All files (*)"));
|
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 writeSettings();
|
||||||
|
|
||||||
void loadGuidDatabase();
|
void loadGuidDatabase();
|
||||||
void unloadGuidDatabase();
|
void unloadGuidDatabase();
|
||||||
void loadDefaultGuidDatabase();
|
void loadDefaultGuidDatabase();
|
||||||
|
void exportDiscoveredGuids();
|
||||||
void generateReport();
|
void generateReport();
|
||||||
|
|
||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
|
@ -327,6 +327,7 @@
|
|||||||
<addaction name="actionLoadGuidDatabase"/>
|
<addaction name="actionLoadGuidDatabase"/>
|
||||||
<addaction name="actionLoadDefaultGuidDatabase"/>
|
<addaction name="actionLoadDefaultGuidDatabase"/>
|
||||||
<addaction name="actionUnloadGuidDatabase"/>
|
<addaction name="actionUnloadGuidDatabase"/>
|
||||||
|
<addaction name="actionExportDiscoveredGuids"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -907,6 +908,14 @@
|
|||||||
<string>Ctrl+Alt+D</string>
|
<string>Ctrl+Alt+D</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExportDiscoveredGuids">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export discovered GUIDs</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -14,24 +14,15 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include "ubytearray.h"
|
#include "ubytearray.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
|
|
||||||
#if defined(U_ENABLE_GUID_DATABASE_SUPPORT)
|
|
||||||
#include <map>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#if defined(U_ENABLE_GUID_DATABASE_SUPPORT)
|
||||||
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bool>
|
static GuidDatabase gLocalGuidDatabase;
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
#ifdef QT_CORE_LIB
|
#ifdef QT_CORE_LIB
|
||||||
|
|
||||||
@ -61,7 +52,7 @@ static std::string readGuidDatabase(const UString &path) {
|
|||||||
|
|
||||||
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
||||||
{
|
{
|
||||||
gGuidToUStringMap.clear();
|
gLocalGuidDatabase.clear();
|
||||||
|
|
||||||
std::stringstream file(readGuidDatabase(path));
|
std::stringstream file(readGuidDatabase(path));
|
||||||
|
|
||||||
@ -90,16 +81,16 @@ void initGuidDatabase(const UString & path, UINT32* numEntries)
|
|||||||
if (!ustringToGuid(lineParts[0], guid))
|
if (!ustringToGuid(lineParts[0], guid))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gGuidToUStringMap.insert(GuidToUStringMap::value_type(guid, lineParts[1]));
|
gLocalGuidDatabase[guid] = lineParts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numEntries)
|
if (numEntries)
|
||||||
*numEntries = (UINT32)gGuidToUStringMap.size();
|
*numEntries = (UINT32)gLocalGuidDatabase.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
UString guidDatabaseLookup(const EFI_GUID & guid)
|
UString guidDatabaseLookup(const EFI_GUID & guid)
|
||||||
{
|
{
|
||||||
return gGuidToUStringMap[guid];
|
return gLocalGuidDatabase[guid];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -116,3 +107,35 @@ UString guidDatabaseLookup(const EFI_GUID & guid)
|
|||||||
return UString();
|
return UString();
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
/* guiddatabase.h
|
||||||
|
|
||||||
Copyright (c) 2017, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2017, LongSoft. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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
|
#ifndef GUID_DATABASE_H
|
||||||
#define GUID_DATABASE_H
|
#define GUID_DATABASE_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "ustring.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);
|
UString guidDatabaseLookup(const EFI_GUID & guid);
|
||||||
void initGuidDatabase(const UString & path = "", UINT32* numEntries = NULL);
|
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
|
#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