mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-21 23:48:22 +08:00
Display message when search fails
Display a message 'could not be found' when the UEFITool search fails.
This commit is contained in:
parent
a7cf9cc3e3
commit
a5675bda90
@ -19,6 +19,14 @@
|
|||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
USTATUS FfsFinder::findHexPattern(const UByteArray & hexPattern, const UINT8 mode) {
|
||||||
|
const UModelIndex rootIndex = model->index(0, 0);
|
||||||
|
USTATUS ret = findHexPattern(rootIndex, hexPattern, mode);
|
||||||
|
if (ret != U_SUCCESS)
|
||||||
|
msg(UString("Hex pattern \"") + UString(hexPattern) + UString("\" could not be found"), rootIndex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray & hexPattern, const UINT8 mode)
|
USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray & hexPattern, const UINT8 mode)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -31,9 +39,11 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
|||||||
if (hexPattern.count('.') == hexPattern.length())
|
if (hexPattern.count('.') == hexPattern.length())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
|
USTATUS ret = U_ITEM_NOT_FOUND;
|
||||||
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++) {
|
||||||
findHexPattern(index.model()->index(i, index.column(), index), hexPattern, mode);
|
if (U_SUCCESS == findHexPattern(index.model()->index(i, index.column(), index), hexPattern, mode))
|
||||||
|
ret = U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UByteArray data;
|
UByteArray data;
|
||||||
@ -83,6 +93,7 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
|||||||
+ UString("\" in ") + name
|
+ UString("\" in ") + name
|
||||||
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
||||||
index);
|
index);
|
||||||
|
ret = U_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +104,15 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
USTATUS FfsFinder::findGuidPattern(const UByteArray & guidPattern, const UINT8 mode) {
|
||||||
|
const UModelIndex rootIndex = model->index(0, 0);
|
||||||
|
USTATUS ret = findGuidPattern(rootIndex, guidPattern, mode);
|
||||||
|
if (ret != U_SUCCESS)
|
||||||
|
msg(UString("GUID pattern \"") + UString(guidPattern) + UString("\" could not be found"), rootIndex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray & guidPattern, const UINT8 mode)
|
USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray & guidPattern, const UINT8 mode)
|
||||||
@ -104,9 +123,11 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray &
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
|
USTATUS ret = U_ITEM_NOT_FOUND;
|
||||||
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++) {
|
||||||
findGuidPattern(index.model()->index(i, index.column(), index), guidPattern, mode);
|
if (U_SUCCESS == findGuidPattern(index.model()->index(i, index.column(), index), guidPattern, mode))
|
||||||
|
ret = U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UByteArray data;
|
UByteArray data;
|
||||||
@ -174,6 +195,7 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray &
|
|||||||
+ UString("\" in ") + name
|
+ UString("\" in ") + name
|
||||||
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
||||||
index);
|
index);
|
||||||
|
ret = U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR >= 6
|
#if QT_VERSION_MAJOR >= 6
|
||||||
@ -183,7 +205,16 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray &
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
USTATUS FfsFinder::findTextPattern(const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive) {
|
||||||
|
const UModelIndex rootIndex = model->index(0, 0);
|
||||||
|
USTATUS ret = findTextPattern(rootIndex, pattern, mode, unicode, caseSensitive);
|
||||||
|
if (ret != U_SUCCESS)
|
||||||
|
msg((unicode ? UString("Unicode") : UString("ASCII")) + UString(" text \"")
|
||||||
|
+ UString(pattern) + UString("\" could not be found"), rootIndex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive)
|
USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive)
|
||||||
@ -194,9 +225,11 @@ USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pa
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
|
USTATUS ret = U_ITEM_NOT_FOUND;
|
||||||
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++) {
|
||||||
findTextPattern(index.model()->index(i, index.column(), index), pattern, mode, unicode, caseSensitive);
|
if (U_SUCCESS == findTextPattern(index.model()->index(i, index.column(), index), pattern, mode, unicode, caseSensitive))
|
||||||
|
ret = U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UByteArray body;
|
UByteArray body;
|
||||||
@ -236,7 +269,8 @@ USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pa
|
|||||||
+ UString("\" found in ") + name
|
+ UString("\" found in ") + name
|
||||||
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset),
|
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset),
|
||||||
index);
|
index);
|
||||||
|
ret = U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ public:
|
|||||||
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; }
|
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; }
|
||||||
void clearMessages() { messagesVector.clear(); }
|
void clearMessages() { messagesVector.clear(); }
|
||||||
|
|
||||||
USTATUS findHexPattern(const UModelIndex & index, const UByteArray & hexPattern, const UINT8 mode);
|
USTATUS findHexPattern(const UByteArray & hexPattern, const UINT8 mode);
|
||||||
USTATUS findGuidPattern(const UModelIndex & index, const UByteArray & guidPattern, const UINT8 mode);
|
USTATUS findGuidPattern(const UByteArray & guidPattern, const UINT8 mode);
|
||||||
USTATUS findTextPattern(const UModelIndex & index, const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
USTATUS findTextPattern(const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const TreeModel* model;
|
const TreeModel* model;
|
||||||
@ -41,6 +41,10 @@ private:
|
|||||||
void msg(const UString & message, const UModelIndex &index = UModelIndex()) {
|
void msg(const UString & message, const UModelIndex &index = UModelIndex()) {
|
||||||
messagesVector.push_back(std::pair<UString, UModelIndex>(message, index));
|
messagesVector.push_back(std::pair<UString, UModelIndex>(message, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
USTATUS findHexPattern(const UModelIndex & index, const UByteArray & hexPattern, const UINT8 mode);
|
||||||
|
USTATUS findGuidPattern(const UModelIndex & index, const UByteArray & guidPattern, const UINT8 mode);
|
||||||
|
USTATUS findTextPattern(const UModelIndex & index, const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FFSFINDER_H
|
#endif // FFSFINDER_H
|
||||||
|
@ -305,8 +305,6 @@ void UEFITool::search()
|
|||||||
if (searchDialog->exec() != QDialog::Accepted)
|
if (searchDialog->exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QModelIndex rootIndex = model->index(0, 0);
|
|
||||||
|
|
||||||
int index = searchDialog->ui->tabWidget->currentIndex();
|
int index = searchDialog->ui->tabWidget->currentIndex();
|
||||||
if (index == 0) { // Hex pattern
|
if (index == 0) { // Hex pattern
|
||||||
searchDialog->ui->hexEdit->setFocus();
|
searchDialog->ui->hexEdit->setFocus();
|
||||||
@ -320,7 +318,7 @@ void UEFITool::search()
|
|||||||
mode = SEARCH_MODE_BODY;
|
mode = SEARCH_MODE_BODY;
|
||||||
else
|
else
|
||||||
mode = SEARCH_MODE_ALL;
|
mode = SEARCH_MODE_ALL;
|
||||||
ffsFinder->findHexPattern(rootIndex, pattern, mode);
|
ffsFinder->findHexPattern(pattern, mode);
|
||||||
showFinderMessages();
|
showFinderMessages();
|
||||||
}
|
}
|
||||||
else if (index == 1) { // GUID
|
else if (index == 1) { // GUID
|
||||||
@ -336,7 +334,7 @@ void UEFITool::search()
|
|||||||
mode = SEARCH_MODE_BODY;
|
mode = SEARCH_MODE_BODY;
|
||||||
else
|
else
|
||||||
mode = SEARCH_MODE_ALL;
|
mode = SEARCH_MODE_ALL;
|
||||||
ffsFinder->findGuidPattern(rootIndex, pattern, mode);
|
ffsFinder->findGuidPattern(pattern, mode);
|
||||||
showFinderMessages();
|
showFinderMessages();
|
||||||
}
|
}
|
||||||
else if (index == 2) { // Text string
|
else if (index == 2) { // Text string
|
||||||
@ -351,7 +349,7 @@ void UEFITool::search()
|
|||||||
mode = SEARCH_MODE_BODY;
|
mode = SEARCH_MODE_BODY;
|
||||||
else
|
else
|
||||||
mode = SEARCH_MODE_ALL;
|
mode = SEARCH_MODE_ALL;
|
||||||
ffsFinder->findTextPattern(rootIndex, pattern, mode, searchDialog->ui->textUnicodeCheckBox->isChecked(),
|
ffsFinder->findTextPattern(pattern, mode, searchDialog->ui->textUnicodeCheckBox->isChecked(),
|
||||||
(Qt::CaseSensitivity) searchDialog->ui->textCaseSensitiveCheckBox->isChecked());
|
(Qt::CaseSensitivity) searchDialog->ui->textCaseSensitiveCheckBox->isChecked());
|
||||||
showFinderMessages();
|
showFinderMessages();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user