mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-21 23:48:22 +08:00
Build fixes for Windows builds
- now to test in OSX and Linux
This commit is contained in:
parent
80b85cbf19
commit
0114a72fa5
@ -159,15 +159,14 @@ USTATUS UEFIDumper::recursiveDump(const UModelIndex & index)
|
|||||||
UString orgName = uniqueItemName(index);
|
UString orgName = uniqueItemName(index);
|
||||||
UString name = orgName;
|
UString name = orgName;
|
||||||
bool nameFound = false;
|
bool nameFound = false;
|
||||||
for (int i = 0; i < 0x10000; ++i) {
|
for (int i = 1; i < 1000; ++i) {
|
||||||
if (isExistOnFs(name)) {
|
if (!isExistOnFs(name + UString("_info.txt"))) {
|
||||||
name = orgName + UString("_") + usprintf("%04X", i);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
nameFound = true;
|
nameFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
name = orgName + UString("_") + usprintf("%03d", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nameFound)
|
if (!nameFound)
|
||||||
return U_INVALID_PARAMETER; //TODO: replace with proper errorCode
|
return U_INVALID_PARAMETER; //TODO: replace with proper errorCode
|
||||||
|
|
||||||
|
@ -27,20 +27,20 @@ UEFIFind::~UEFIFind()
|
|||||||
model = NULL;
|
model = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS UEFIFind::init(const QString & path)
|
USTATUS UEFIFind::init(const QString & path)
|
||||||
{
|
{
|
||||||
STATUS result;
|
USTATUS result;
|
||||||
|
|
||||||
fileInfo = QFileInfo(path);
|
fileInfo = QFileInfo(path);
|
||||||
|
|
||||||
if (!fileInfo.exists())
|
if (!fileInfo.exists())
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
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 U_FILE_OPEN;
|
||||||
|
|
||||||
QByteArray buffer = inputFile.readAll();
|
QByteArray buffer = inputFile.readAll();
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
@ -50,42 +50,24 @@ STATUS UEFIFind::init(const QString & path)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
initDone = true;
|
initDone = true;
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UEFIFind::guidToQString(const UINT8* guid)
|
USTATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result)
|
||||||
{
|
|
||||||
const UINT32 u32 = *(const UINT32*)guid;
|
|
||||||
const UINT16 u16_1 = *(const UINT16*)(guid + 4);
|
|
||||||
const UINT16 u16_2 = *(const UINT16*)(guid + 6);
|
|
||||||
const UINT8 u8_1 = *(const UINT8*)(guid + 8);
|
|
||||||
const UINT8 u8_2 = *(const UINT8*)(guid + 9);
|
|
||||||
const UINT8 u8_3 = *(const UINT8*)(guid + 10);
|
|
||||||
const UINT8 u8_4 = *(const UINT8*)(guid + 11);
|
|
||||||
const UINT8 u8_5 = *(const UINT8*)(guid + 12);
|
|
||||||
const UINT8 u8_6 = *(const UINT8*)(guid + 13);
|
|
||||||
const UINT8 u8_7 = *(const UINT8*)(guid + 14);
|
|
||||||
const UINT8 u8_8 = *(const UINT8*)(guid + 15);
|
|
||||||
|
|
||||||
return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11").hexarg2(u32, 8).hexarg2(u16_1, 4).hexarg2(u16_2, 4).hexarg2(u8_1, 2).hexarg2(u8_2, 2)
|
|
||||||
.hexarg2(u8_3, 2).hexarg2(u8_4, 2).hexarg2(u8_5, 2).hexarg2(u8_6, 2).hexarg2(u8_7, 2).hexarg2(u8_8, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result)
|
|
||||||
{
|
{
|
||||||
QModelIndex root = model->index(0, 0);
|
QModelIndex root = model->index(0, 0);
|
||||||
std::set<std::pair<QModelIndex, QModelIndex> > files;
|
std::set<std::pair<QModelIndex, QModelIndex> > files;
|
||||||
|
|
||||||
result.clear();
|
result.clear();
|
||||||
|
|
||||||
STATUS returned = findFileRecursive(root, hexPattern, mode, files);
|
USTATUS returned = findFileRecursive(root, hexPattern, mode, files);
|
||||||
if (returned)
|
if (returned)
|
||||||
return returned;
|
return returned;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
if (!files.empty())
|
if (!files.empty())
|
||||||
result.append(QString("%1\n").arg(files.size()));
|
result.append(QString("%1\n").arg(files.size()));
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::set<std::pair<QModelIndex, QModelIndex> >::const_iterator citer = files.cbegin(); citer != files.cend(); ++citer) {
|
for (std::set<std::pair<QModelIndex, QModelIndex> >::const_iterator citer = files.cbegin(); citer != files.cend(); ++citer) {
|
||||||
@ -93,30 +75,30 @@ STATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPat
|
|||||||
std::pair<QModelIndex, QModelIndex> indexes = *citer;
|
std::pair<QModelIndex, QModelIndex> indexes = *citer;
|
||||||
if (!model->hasEmptyHeader(indexes.first))
|
if (!model->hasEmptyHeader(indexes.first))
|
||||||
data = model->header(indexes.first).left(16);
|
data = model->header(indexes.first).left(16);
|
||||||
result.append(guidToQString((const UINT8*)data.constData()));
|
result.append(guidToUString(*(const EFI_GUID*)data.constData()));
|
||||||
|
|
||||||
// Special case of freeform subtype GUID files
|
// Special case of freeform subtype GUID files
|
||||||
if (indexes.second.isValid() && model->subtype(indexes.second) == EFI_SECTION_FREEFORM_SUBTYPE_GUID) {
|
if (indexes.second.isValid() && model->subtype(indexes.second) == EFI_SECTION_FREEFORM_SUBTYPE_GUID) {
|
||||||
data = model->header(indexes.second).left(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
|
data = model->header(indexes.second).left(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
|
||||||
result.append(" ").append(guidToQString((const UINT8*)data.constData() + sizeof(EFI_COMMON_SECTION_HEADER)));
|
result.append(" ").append(guidToUString(*(const EFI_GUID*)(data.constData() + sizeof(EFI_COMMON_SECTION_HEADER))));
|
||||||
}
|
}
|
||||||
|
|
||||||
result.append("\n");
|
result.append("\n");
|
||||||
}
|
}
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set<std::pair<QModelIndex, QModelIndex> > & files)
|
USTATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set<std::pair<QModelIndex, QModelIndex> > & files)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
if (hexPattern.isEmpty())
|
if (hexPattern.isEmpty())
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Check for "all substrings" pattern
|
// Check for "all substrings" pattern
|
||||||
if (hexPattern.count('.') == hexPattern.length())
|
if (hexPattern.count('.') == hexPattern.length())
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
bool hasChildren = (model->rowCount(index) > 0);
|
bool hasChildren = (model->rowCount(index) > 0);
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
@ -157,5 +139,5 @@ STATUS UEFIFind::findFileRecursive(const QModelIndex index, const QString & hexP
|
|||||||
offset = regexp.indexIn(hexBody, offset + 1);
|
offset = regexp.indexIn(hexBody, offset + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
@ -34,11 +34,11 @@ public:
|
|||||||
explicit UEFIFind();
|
explicit UEFIFind();
|
||||||
~UEFIFind();
|
~UEFIFind();
|
||||||
|
|
||||||
STATUS init(const QString & path);
|
USTATUS init(const QString & path);
|
||||||
STATUS find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result);
|
USTATUS find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
STATUS findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set<std::pair<QModelIndex, QModelIndex> > & files);
|
USTATUS findFileRecursive(const QModelIndex index, const QString & hexPattern, const UINT8 mode, std::set<std::pair<QModelIndex, QModelIndex> > & files);
|
||||||
QString guidToQString(const UINT8* guid);
|
QString guidToQString(const UINT8* guid);
|
||||||
|
|
||||||
FfsParser* ffsParser;
|
FfsParser* ffsParser;
|
||||||
|
@ -34,7 +34,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (a.arguments().at(1) == QString("all"))
|
else if (a.arguments().at(1) == QString("all"))
|
||||||
mode = SEARCH_MODE_ALL;
|
mode = SEARCH_MODE_ALL;
|
||||||
else
|
else
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Get result type
|
// Get result type
|
||||||
bool count;
|
bool count;
|
||||||
@ -43,7 +43,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (a.arguments().at(2) == QString("count"))
|
else if (a.arguments().at(2) == QString("count"))
|
||||||
count = true;
|
count = true;
|
||||||
else
|
else
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Parse input file
|
// Parse input file
|
||||||
result = w.init(a.arguments().at(4));
|
result = w.init(a.arguments().at(4));
|
||||||
@ -58,26 +58,26 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Nothing is found
|
// Nothing is found
|
||||||
if (found.isEmpty())
|
if (found.isEmpty())
|
||||||
return ERR_ITEM_NOT_FOUND;
|
return U_ITEM_NOT_FOUND;
|
||||||
|
|
||||||
// Print result
|
// Print result
|
||||||
std::cout << found.toStdString();
|
std::cout << found.toStdString();
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (a.arguments().length() == 4) {
|
else if (a.arguments().length() == 4) {
|
||||||
// Get search mode
|
// Get search mode
|
||||||
if (a.arguments().at(1) != QString("file"))
|
if (a.arguments().at(1) != QString("file"))
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Open patterns file
|
// Open patterns file
|
||||||
QFileInfo fileInfo(a.arguments().at(2));
|
QFileInfo fileInfo(a.arguments().at(2));
|
||||||
if (!fileInfo.exists())
|
if (!fileInfo.exists())
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
QFile patternsFile;
|
QFile patternsFile;
|
||||||
patternsFile.setFileName(a.arguments().at(2));
|
patternsFile.setFileName(a.arguments().at(2));
|
||||||
if (!patternsFile.open(QFile::ReadOnly))
|
if (!patternsFile.open(QFile::ReadOnly))
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
// Parse input file
|
// Parse input file
|
||||||
result = w.init(a.arguments().at(3));
|
result = w.init(a.arguments().at(3));
|
||||||
@ -143,15 +143,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Nothing is found
|
// Nothing is found
|
||||||
if (!somethingFound)
|
if (!somethingFound)
|
||||||
return ERR_ITEM_NOT_FOUND;
|
return U_ITEM_NOT_FOUND;
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "UEFIFind 0.10.6" << std::endl << std::endl <<
|
std::cout << "UEFIFind 0.10.6" << std::endl << std::endl <<
|
||||||
"Usage: UEFIFind {header | body | all} {list | count} pattern imagefile" << std::endl <<
|
"Usage: UEFIFind {header | body | all} {list | count} pattern imagefile" << std::endl <<
|
||||||
" or UEFIFind file patternsfile imagefile" << std::endl;
|
" or UEFIFind file patternsfile imagefile" << std::endl;
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4086,7 +4086,7 @@ USTATUS FfsParser::parseSlicPubkeyHeader(const UByteArray & store, const UINT32
|
|||||||
// Add info
|
// Add info
|
||||||
UString name("SLIC pubkey");
|
UString name("SLIC pubkey");
|
||||||
UString info = usprintf("Type: 0h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\n"
|
UString info = usprintf("Type: 0h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\n"
|
||||||
"Key type :%02Xh\nVersion: %02Xh\nAlgorithm: %08Xh\nMagic: RSA1\nBit length: %08Xh\nExponent: %08Xh",
|
"Key type: %02Xh\nVersion: %02Xh\nAlgorithm: %08Xh\nMagic: RSA1\nBit length: %08Xh\nExponent: %08Xh",
|
||||||
pubkeyHeader->Size, pubkeyHeader->Size,
|
pubkeyHeader->Size, pubkeyHeader->Size,
|
||||||
header.size(), header.size(),
|
header.size(), header.size(),
|
||||||
pubkeyHeader->KeyType,
|
pubkeyHeader->KeyType,
|
||||||
@ -4134,7 +4134,7 @@ USTATUS FfsParser::parseSlicMarkerHeader(const UByteArray & store, const UINT32
|
|||||||
// Add info
|
// Add info
|
||||||
UString name("SLIC marker");
|
UString name("SLIC marker");
|
||||||
UString info = usprintf("Type: 1h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\n"
|
UString info = usprintf("Type: 1h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\n"
|
||||||
"Version :%08Xh\nOEM ID: %s\nOEM table ID: %s\nWindows flag: WINDOWS\nSLIC version: %08Xh",
|
"Version: %08Xh\nOEM ID: %s\nOEM table ID: %s\nWindows flag: WINDOWS\nSLIC version: %08Xh",
|
||||||
markerHeader->Size, markerHeader->Size,
|
markerHeader->Size, markerHeader->Size,
|
||||||
header.size(), header.size(),
|
header.size(), header.size(),
|
||||||
markerHeader->Version,
|
markerHeader->Version,
|
||||||
|
@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
// Use Qt class, if Qt is available
|
// Use Qt class, if Qt is available
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#define UString QString
|
#define UString QString
|
||||||
|
#define findreplace replace
|
||||||
#else
|
#else
|
||||||
// Use Bstrlib
|
// Use Bstrlib
|
||||||
#define BSTRLIB_DOESNT_THROW_EXCEPTIONS
|
#define BSTRLIB_DOESNT_THROW_EXCEPTIONS
|
||||||
|
@ -52,7 +52,7 @@ UString uniqueItemName(const UModelIndex & index)
|
|||||||
return UString("Invalid index");
|
return UString("Invalid index");
|
||||||
|
|
||||||
// Get model from index
|
// Get model from index
|
||||||
const TreeModel* model = index.model();
|
const TreeModel* model = (const TreeModel*)index.model();
|
||||||
|
|
||||||
// Get data from parsing data
|
// Get data from parsing data
|
||||||
PARSING_DATA pdata = parsingDataFromUModelIndex(index);
|
PARSING_DATA pdata = parsingDataFromUModelIndex(index);
|
||||||
@ -64,7 +64,7 @@ UString uniqueItemName(const UModelIndex & index)
|
|||||||
// Default name
|
// Default name
|
||||||
UString name = itemName;
|
UString name = itemName;
|
||||||
switch (model->type(index)) {
|
switch (model->type(index)) {
|
||||||
case Types::Volume:
|
case Types::Volume:
|
||||||
if (pdata.volume.hasExtendedHeader) name = guidToUString(pdata.volume.extendedHeaderGuid);
|
if (pdata.volume.hasExtendedHeader) name = guidToUString(pdata.volume.extendedHeaderGuid);
|
||||||
break;
|
break;
|
||||||
case Types::NvarEntry:
|
case Types::NvarEntry:
|
||||||
@ -72,19 +72,22 @@ UString uniqueItemName(const UModelIndex & index)
|
|||||||
case Types::FsysEntry:
|
case Types::FsysEntry:
|
||||||
case Types::EvsaEntry:
|
case Types::EvsaEntry:
|
||||||
case Types::FlashMapEntry:
|
case Types::FlashMapEntry:
|
||||||
case Types::File:
|
case Types::File:
|
||||||
name = itemText.isEmpty() ? itemName : itemText;
|
name = itemText.isEmpty() ? itemName : itemName + '_' + itemText;
|
||||||
break;
|
break;
|
||||||
case Types::Section: {
|
case Types::Section: {
|
||||||
// Get parent file name
|
// Get parent file name
|
||||||
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
||||||
UString fileText = model->text(fileIndex);
|
UString fileText = model->text(fileIndex);
|
||||||
name = fileText.isEmpty() ? model->name(fileIndex) : fileText;
|
name = fileText.isEmpty() ? model->name(fileIndex) : model->name(fileIndex) + '_' + fileText;
|
||||||
// Append section subtype name
|
|
||||||
name += '_' + itemName;
|
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UString subtypeString = itemSubtypeToUString(model->type(index), model->subtype(index));
|
||||||
|
name = itemTypeToUString(model->type(index))
|
||||||
|
+ (subtypeString.length() ? ('_' + subtypeString) : UString())
|
||||||
|
+ '_' + name;
|
||||||
|
|
||||||
name.findreplace(' ', '_');
|
name.findreplace(' ', '_');
|
||||||
name.findreplace('/', '_');
|
name.findreplace('/', '_');
|
||||||
name.findreplace('-', '_');
|
name.findreplace('-', '_');
|
||||||
|
Loading…
Reference in New Issue
Block a user