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 name = orgName;
|
||||
bool nameFound = false;
|
||||
for (int i = 0; i < 0x10000; ++i) {
|
||||
if (isExistOnFs(name)) {
|
||||
name = orgName + UString("_") + usprintf("%04X", i);
|
||||
}
|
||||
else {
|
||||
for (int i = 1; i < 1000; ++i) {
|
||||
if (!isExistOnFs(name + UString("_info.txt"))) {
|
||||
nameFound = true;
|
||||
break;
|
||||
}
|
||||
name = orgName + UString("_") + usprintf("%03d", i);
|
||||
}
|
||||
|
||||
if (!nameFound)
|
||||
return U_INVALID_PARAMETER; //TODO: replace with proper errorCode
|
||||
|
||||
|
@ -27,20 +27,20 @@ UEFIFind::~UEFIFind()
|
||||
model = NULL;
|
||||
}
|
||||
|
||||
STATUS UEFIFind::init(const QString & path)
|
||||
USTATUS UEFIFind::init(const QString & path)
|
||||
{
|
||||
STATUS result;
|
||||
USTATUS result;
|
||||
|
||||
fileInfo = QFileInfo(path);
|
||||
|
||||
if (!fileInfo.exists())
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
QFile inputFile;
|
||||
inputFile.setFileName(path);
|
||||
|
||||
if (!inputFile.open(QFile::ReadOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
QByteArray buffer = inputFile.readAll();
|
||||
inputFile.close();
|
||||
@ -50,42 +50,24 @@ STATUS UEFIFind::init(const QString & path)
|
||||
return result;
|
||||
|
||||
initDone = true;
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
QString UEFIFind::guidToQString(const UINT8* guid)
|
||||
{
|
||||
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)
|
||||
USTATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result)
|
||||
{
|
||||
QModelIndex root = model->index(0, 0);
|
||||
std::set<std::pair<QModelIndex, QModelIndex> > files;
|
||||
|
||||
result.clear();
|
||||
|
||||
STATUS returned = findFileRecursive(root, hexPattern, mode, files);
|
||||
USTATUS returned = findFileRecursive(root, hexPattern, mode, files);
|
||||
if (returned)
|
||||
return returned;
|
||||
|
||||
if (count) {
|
||||
if (!files.empty())
|
||||
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) {
|
||||
@ -93,30 +75,30 @@ STATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPat
|
||||
std::pair<QModelIndex, QModelIndex> indexes = *citer;
|
||||
if (!model->hasEmptyHeader(indexes.first))
|
||||
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
|
||||
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));
|
||||
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");
|
||||
}
|
||||
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())
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
|
||||
if (hexPattern.isEmpty())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Check for "all substrings" pattern
|
||||
if (hexPattern.count('.') == hexPattern.length())
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
|
||||
bool hasChildren = (model->rowCount(index) > 0);
|
||||
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);
|
||||
}
|
||||
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
@ -34,11 +34,11 @@ public:
|
||||
explicit UEFIFind();
|
||||
~UEFIFind();
|
||||
|
||||
STATUS init(const QString & path);
|
||||
STATUS find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result);
|
||||
USTATUS init(const QString & path);
|
||||
USTATUS find(const UINT8 mode, const bool count, const QString & hexPattern, QString & result);
|
||||
|
||||
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);
|
||||
|
||||
FfsParser* ffsParser;
|
||||
|
@ -34,7 +34,7 @@ int main(int argc, char *argv[])
|
||||
else if (a.arguments().at(1) == QString("all"))
|
||||
mode = SEARCH_MODE_ALL;
|
||||
else
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Get result type
|
||||
bool count;
|
||||
@ -43,7 +43,7 @@ int main(int argc, char *argv[])
|
||||
else if (a.arguments().at(2) == QString("count"))
|
||||
count = true;
|
||||
else
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Parse input file
|
||||
result = w.init(a.arguments().at(4));
|
||||
@ -58,26 +58,26 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Nothing is found
|
||||
if (found.isEmpty())
|
||||
return ERR_ITEM_NOT_FOUND;
|
||||
return U_ITEM_NOT_FOUND;
|
||||
|
||||
// Print result
|
||||
std::cout << found.toStdString();
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
else if (a.arguments().length() == 4) {
|
||||
// Get search mode
|
||||
if (a.arguments().at(1) != QString("file"))
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Open patterns file
|
||||
QFileInfo fileInfo(a.arguments().at(2));
|
||||
if (!fileInfo.exists())
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
QFile patternsFile;
|
||||
patternsFile.setFileName(a.arguments().at(2));
|
||||
if (!patternsFile.open(QFile::ReadOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
// Parse input file
|
||||
result = w.init(a.arguments().at(3));
|
||||
@ -143,15 +143,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Nothing is found
|
||||
if (!somethingFound)
|
||||
return ERR_ITEM_NOT_FOUND;
|
||||
return U_ITEM_NOT_FOUND;
|
||||
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
else {
|
||||
std::cout << "UEFIFind 0.10.6" << std::endl << std::endl <<
|
||||
"Usage: UEFIFind {header | body | all} {list | count} pattern 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
|
||||
UString name("SLIC pubkey");
|
||||
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,
|
||||
header.size(), header.size(),
|
||||
pubkeyHeader->KeyType,
|
||||
@ -4134,7 +4134,7 @@ USTATUS FfsParser::parseSlicMarkerHeader(const UByteArray & store, const UINT32
|
||||
// Add info
|
||||
UString name("SLIC marker");
|
||||
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,
|
||||
header.size(), header.size(),
|
||||
markerHeader->Version,
|
||||
|
@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
// Use Qt class, if Qt is available
|
||||
#include <QString>
|
||||
#define UString QString
|
||||
#define findreplace replace
|
||||
#else
|
||||
// Use Bstrlib
|
||||
#define BSTRLIB_DOESNT_THROW_EXCEPTIONS
|
||||
|
@ -52,7 +52,7 @@ UString uniqueItemName(const UModelIndex & index)
|
||||
return UString("Invalid index");
|
||||
|
||||
// Get model from index
|
||||
const TreeModel* model = index.model();
|
||||
const TreeModel* model = (const TreeModel*)index.model();
|
||||
|
||||
// Get data from parsing data
|
||||
PARSING_DATA pdata = parsingDataFromUModelIndex(index);
|
||||
@ -73,18 +73,21 @@ UString uniqueItemName(const UModelIndex & index)
|
||||
case Types::EvsaEntry:
|
||||
case Types::FlashMapEntry:
|
||||
case Types::File:
|
||||
name = itemText.isEmpty() ? itemName : itemText;
|
||||
name = itemText.isEmpty() ? itemName : itemName + '_' + itemText;
|
||||
break;
|
||||
case Types::Section: {
|
||||
// Get parent file name
|
||||
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
||||
UString fileText = model->text(fileIndex);
|
||||
name = fileText.isEmpty() ? model->name(fileIndex) : fileText;
|
||||
// Append section subtype name
|
||||
name += '_' + itemName;
|
||||
name = fileText.isEmpty() ? model->name(fileIndex) : model->name(fileIndex) + '_' + fileText;
|
||||
} 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('-', '_');
|
||||
|
Loading…
Reference in New Issue
Block a user