mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
Untie guid database from Qt
This commit is contained in:
parent
6982aace9b
commit
8f6c8ef5cc
@ -57,6 +57,6 @@ SET(PROJECT_HEADERS
|
|||||||
../version.h
|
../version.h
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT)
|
ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT -DU_ENABLE_FIT_PARSING_SUPPORT -DU_ENABLE_GUID_DATABASE_SUPPORT)
|
||||||
|
|
||||||
ADD_EXECUTABLE(UEFIExtract ${PROJECT_SOURCES} ${PROJECT_HEADERS})
|
ADD_EXECUTABLE(UEFIExtract ${PROJECT_SOURCES} ${PROJECT_HEADERS})
|
@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include "../common/filesystem.h"
|
#include "../common/filesystem.h"
|
||||||
#include "../common/ffsparser.h"
|
#include "../common/ffsparser.h"
|
||||||
#include "../common/ffsreport.h"
|
#include "../common/ffsreport.h"
|
||||||
|
#include "../common/guiddatabase.h"
|
||||||
#include "ffsdumper.h"
|
#include "ffsdumper.h"
|
||||||
#include "uefidump.h"
|
#include "uefidump.h"
|
||||||
|
|
||||||
@ -31,6 +32,8 @@ enum ReadType {
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
initGuidDatabase("guids.csv");
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
// Check that input file exists
|
// Check that input file exists
|
||||||
UString path = argv[1];
|
UString path = argv[1];
|
||||||
|
@ -55,6 +55,6 @@ SET(PROJECT_HEADERS
|
|||||||
../version.h
|
../version.h
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT)
|
ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT -DU_ENABLE_FIT_PARSING_SUPPORT -DU_ENABLE_GUID_DATABASE_SUPPORT)
|
||||||
|
|
||||||
ADD_EXECUTABLE(UEFIFind ${PROJECT_SOURCES} ${PROJECT_HEADERS})
|
ADD_EXECUTABLE(UEFIFind ${PROJECT_SOURCES} ${PROJECT_HEADERS})
|
@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
|
#include "../common/guiddatabase.h"
|
||||||
#include "uefifind.h"
|
#include "uefifind.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -23,6 +24,8 @@ int main(int argc, char *argv[])
|
|||||||
UEFIFind w;
|
UEFIFind w;
|
||||||
UINT8 result;
|
UINT8 result;
|
||||||
|
|
||||||
|
initGuidDatabase("guids.csv");
|
||||||
|
|
||||||
if (argc == 5) {
|
if (argc == 5) {
|
||||||
UString inputArg = argv[1];
|
UString inputArg = argv[1];
|
||||||
UString modeArg = argv[2];
|
UString modeArg = argv[2];
|
||||||
|
@ -1491,8 +1491,6 @@ int p, i;
|
|||||||
|
|
||||||
static int streamSplitCb (void * parm, int ofs, const_bstring entry) {
|
static int streamSplitCb (void * parm, int ofs, const_bstring entry) {
|
||||||
CBStringList * r = (CBStringList *) parm;
|
CBStringList * r = (CBStringList *) parm;
|
||||||
//FIXME: this is broken!
|
|
||||||
// ofs = ofs;
|
|
||||||
(void)ofs;
|
(void)ofs;
|
||||||
r->push_back (CBString (*entry));
|
r->push_back (CBString (*entry));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -13,11 +13,13 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include "guiddatabase.h"
|
#include "guiddatabase.h"
|
||||||
#include "ubytearray.h"
|
#include "ubytearray.h"
|
||||||
|
|
||||||
// TODO: remove Qt dependency
|
#if defined(U_ENABLE_GUID_DATABASE_SUPPORT)
|
||||||
#if defined(U_ENABLE_GUID_DATABASE_SUPPORT) && defined(QT_CORE_LIB)
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <QFile>
|
#include <fstream>
|
||||||
#include <QUuid>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bool>
|
struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bool>
|
||||||
{
|
{
|
||||||
@ -30,29 +32,82 @@ struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bo
|
|||||||
typedef std::map<EFI_GUID, UString, OperatorLessForGuids> GuidToUStringMap;
|
typedef std::map<EFI_GUID, UString, OperatorLessForGuids> GuidToUStringMap;
|
||||||
static GuidToUStringMap gGuidToUStringMap;
|
static GuidToUStringMap gGuidToUStringMap;
|
||||||
|
|
||||||
|
#ifdef QT_CORE_LIB
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
// This is required to be able to read Qt-embedded paths
|
||||||
|
|
||||||
|
static std::string readGuidDatabase(const UString &path) {
|
||||||
|
QFile guids(path);
|
||||||
|
if (guids.open(QFile::ReadOnly | QFile::Text))
|
||||||
|
return QTextStream(&guids).readAll().toStdString();
|
||||||
|
return std::string {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static std::string readGuidDatabase(const UString &path) {
|
||||||
|
std::ifstream guids(path.toLocal8Bit());
|
||||||
|
std::stringstream ret;
|
||||||
|
if (ret)
|
||||||
|
ret << guids.rdbuf();
|
||||||
|
return ret.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
||||||
{
|
{
|
||||||
gGuidToUStringMap.clear();
|
gGuidToUStringMap.clear();
|
||||||
|
|
||||||
QFile file(path);
|
std::stringstream file(readGuidDatabase(path));
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (!file.atEnd()) {
|
while (!file.eof()) {
|
||||||
UByteArray line = file.readLine();
|
std::string line;
|
||||||
|
std::getline(file, line);
|
||||||
|
|
||||||
// Use sharp sign as commentary
|
// Use sharp symbol as commentary
|
||||||
if (line.length() == 0 || line[0] == '#')
|
if (line.size() == 0 || line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// GUID and name are comma-separated
|
// GUID and name are comma-separated
|
||||||
QList<UByteArray> lineParts = line.split(',');
|
std::vector<UString> lineParts;
|
||||||
if (lineParts.length() < 2)
|
std::string::size_type prev = 0, curr = 0;
|
||||||
|
while ((curr = line.find(',', curr)) != std::string::npos) {
|
||||||
|
std::string substring( line.substr(prev, curr-prev) );
|
||||||
|
lineParts.push_back(UString(substring.c_str()));
|
||||||
|
prev = ++curr;
|
||||||
|
}
|
||||||
|
lineParts.push_back(UString(line.substr(prev, curr-prev).c_str()));
|
||||||
|
|
||||||
|
if (lineParts.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QUuid uuid(lineParts[0]);
|
EFI_GUID guid;
|
||||||
UString str(lineParts[1].constData());
|
|
||||||
gGuidToUStringMap.insert(GuidToUStringMap::value_type(*(const EFI_GUID*)&uuid.data1, str.simplified()));
|
unsigned long p0;
|
||||||
|
int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
|
||||||
|
|
||||||
|
int err = std::sscanf(lineParts[0].toLocal8Bit(), "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||||
|
&p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
|
||||||
|
if (err == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
guid.Data1 = p0;
|
||||||
|
guid.Data2 = p1;
|
||||||
|
guid.Data3 = p2;
|
||||||
|
guid.Data4[0] = p3;
|
||||||
|
guid.Data4[1] = p4;
|
||||||
|
guid.Data4[2] = p5;
|
||||||
|
guid.Data4[3] = p6;
|
||||||
|
guid.Data4[4] = p7;
|
||||||
|
guid.Data4[5] = p8;
|
||||||
|
guid.Data4[6] = p9;
|
||||||
|
guid.Data4[7] = p10;
|
||||||
|
|
||||||
|
gGuidToUStringMap.insert(GuidToUStringMap::value_type(guid, lineParts[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numEntries)
|
if (numEntries)
|
||||||
|
Loading…
Reference in New Issue
Block a user