mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
UEFITool 0.18.3
- added pattern-based search for hex patterns, '.' (dot) means "any hex digit" - added pattern-based search for GUIDs - added copy action for messages - focus is now setting properly for all search window tabs
This commit is contained in:
parent
fd578a8c70
commit
6e1f226aa0
104
ffsengine.cpp
104
ffsengine.cpp
@ -2961,9 +2961,9 @@ UINT8 FfsEngine::reconstructImageFile(QByteArray & reconstructed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search routines
|
// Search routines
|
||||||
UINT8 FfsEngine::findHexPattern(const QModelIndex & index, const QByteArray & pattern, const UINT8 mode)
|
UINT8 FfsEngine::findHexPattern(const QModelIndex & index, const QByteArray & hexPattern, const UINT8 mode)
|
||||||
{
|
{
|
||||||
if (pattern.isEmpty())
|
if (hexPattern.isEmpty())
|
||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -2971,7 +2971,7 @@ UINT8 FfsEngine::findHexPattern(const QModelIndex & index, const QByteArray & pa
|
|||||||
|
|
||||||
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.child(i, index.column()), pattern, mode);
|
findHexPattern(index.child(i, index.column()), hexPattern, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
@ -2988,13 +2988,93 @@ UINT8 FfsEngine::findHexPattern(const QModelIndex & index, const QByteArray & pa
|
|||||||
data.append(model->header(index)).append(model->body(index)).append(model->tail(index));
|
data.append(model->header(index)).append(model->body(index)).append(model->tail(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = -1;
|
// Check for "all substrings" pattern
|
||||||
while ((offset = data.indexOf(pattern, offset + 1)) >= 0) {
|
if (hexPattern.count('.') == hexPattern.length())
|
||||||
msg(tr("Hex pattern \"%1\" found in %2 at offset %3")
|
return ERR_SUCCESS;
|
||||||
.arg(QString(pattern.toHex()))
|
|
||||||
.arg(model->nameString(index))
|
QString hexBody = QString(data.toHex());
|
||||||
.arg(offset, 8, 16, QChar('0')),
|
QRegExp regexp = QRegExp(QString(hexPattern), Qt::CaseInsensitive);
|
||||||
index);
|
INT32 offset = regexp.indexIn(hexBody);
|
||||||
|
while (offset >= 0) {
|
||||||
|
if (offset % 2 == 0) {
|
||||||
|
msg(tr("Hex pattern \"%1\" found as \"%2\" in %3 at %4-offset %5")
|
||||||
|
.arg(QString(hexPattern))
|
||||||
|
.arg(hexBody.mid(offset, hexPattern.length()))
|
||||||
|
.arg(model->nameString(index))
|
||||||
|
.arg(mode == SEARCH_MODE_BODY ? tr("body") : tr("header"))
|
||||||
|
.arg(offset/2, 8, 16, QChar('0')),
|
||||||
|
index);
|
||||||
|
}
|
||||||
|
offset = regexp.indexIn(hexBody, offset + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT8 FfsEngine::findGuidPattern(const QModelIndex & index, const QByteArray & guidPattern, const UINT8 mode)
|
||||||
|
{
|
||||||
|
if (guidPattern.isEmpty())
|
||||||
|
return ERR_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (!index.isValid())
|
||||||
|
return ERR_SUCCESS;
|
||||||
|
|
||||||
|
bool hasChildren = (model->rowCount(index) > 0);
|
||||||
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
|
findGuidPattern(index.child(i, index.column()), guidPattern, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray data;
|
||||||
|
if (hasChildren) {
|
||||||
|
if (mode != SEARCH_MODE_BODY)
|
||||||
|
data = model->header(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mode == SEARCH_MODE_HEADER)
|
||||||
|
data.append(model->header(index)).append(model->tail(index));
|
||||||
|
else if (mode == SEARCH_MODE_BODY)
|
||||||
|
data.append(model->body(index));
|
||||||
|
else
|
||||||
|
data.append(model->header(index)).append(model->body(index)).append(model->tail(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString hexBody = QString(data.toHex());
|
||||||
|
QList<QByteArray> list = guidPattern.split('-');
|
||||||
|
if (list.count() != 5)
|
||||||
|
return ERR_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
QByteArray hexPattern;
|
||||||
|
// Reverse first GUID block
|
||||||
|
hexPattern.append(list.at(0).mid(6, 2));
|
||||||
|
hexPattern.append(list.at(0).mid(4, 2));
|
||||||
|
hexPattern.append(list.at(0).mid(2, 2));
|
||||||
|
hexPattern.append(list.at(0).mid(0, 2));
|
||||||
|
// Reverse second GUID block
|
||||||
|
hexPattern.append(list.at(1).mid(2, 2));
|
||||||
|
hexPattern.append(list.at(1).mid(0, 2));
|
||||||
|
// Reverse third GUID block
|
||||||
|
hexPattern.append(list.at(2).mid(2, 2));
|
||||||
|
hexPattern.append(list.at(2).mid(0, 2));
|
||||||
|
// Append fourth and fifth GUID blocks as is
|
||||||
|
hexPattern.append(list.at(3)).append(list.at(4));
|
||||||
|
|
||||||
|
// Check for "all substrings" pattern
|
||||||
|
if (hexPattern.count('.') == hexPattern.length())
|
||||||
|
return ERR_SUCCESS;
|
||||||
|
|
||||||
|
QRegExp regexp = QRegExp(QString(hexPattern), Qt::CaseInsensitive);
|
||||||
|
INT32 offset = regexp.indexIn(hexBody);
|
||||||
|
while (offset >= 0) {
|
||||||
|
if (offset % 2 == 0) {
|
||||||
|
msg(tr("GUID pattern \"%1\" found as \"%2\" in %3 at %4-offset %5")
|
||||||
|
.arg(QString(guidPattern))
|
||||||
|
.arg(hexBody.mid(offset, hexPattern.length()))
|
||||||
|
.arg(model->nameString(index))
|
||||||
|
.arg(mode == SEARCH_MODE_BODY ? tr("body") : tr("header"))
|
||||||
|
.arg(offset / 2, 8, 16, QChar('0')),
|
||||||
|
index);
|
||||||
|
}
|
||||||
|
offset = regexp.indexIn(hexBody, offset + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
@ -3480,7 +3560,7 @@ UINT8 FfsEngine::patchViaOffset(QByteArray & data, const UINT32 offset, const QB
|
|||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 FfsEngine::patchViaPattern(QByteArray & data, const QByteArray hexFindPattern, const QByteArray & hexReplacePattern)
|
UINT8 FfsEngine::patchViaPattern(QByteArray & data, const QByteArray & hexFindPattern, const QByteArray & hexReplacePattern)
|
||||||
{
|
{
|
||||||
QByteArray body = data;
|
QByteArray body = data;
|
||||||
|
|
||||||
@ -3491,7 +3571,7 @@ UINT8 FfsEngine::patchViaPattern(QByteArray & data, const QByteArray hexFindPatt
|
|||||||
// Convert file body to hex;
|
// Convert file body to hex;
|
||||||
QString hexBody = QString(body.toHex());
|
QString hexBody = QString(body.toHex());
|
||||||
QRegExp regexp = QRegExp(QString(hexFindPattern), Qt::CaseInsensitive);
|
QRegExp regexp = QRegExp(QString(hexFindPattern), Qt::CaseInsensitive);
|
||||||
INT64 offset = regexp.indexIn(hexBody);
|
INT32 offset = regexp.indexIn(hexBody);
|
||||||
while (offset >= 0) {
|
while (offset >= 0) {
|
||||||
if (offset % 2 == 0) {
|
if (offset % 2 == 0) {
|
||||||
UINT8 result = patchViaOffset(body, offset/2, hexReplacePattern);
|
UINT8 result = patchViaOffset(body, offset/2, hexReplacePattern);
|
||||||
|
@ -98,7 +98,8 @@ public:
|
|||||||
UINT8 patch(const QModelIndex & index, const QVector<PatchData> & patches);
|
UINT8 patch(const QModelIndex & index, const QVector<PatchData> & patches);
|
||||||
|
|
||||||
// Search routines
|
// Search routines
|
||||||
UINT8 findHexPattern(const QModelIndex & index, const QByteArray & pattern, const UINT8 mode);
|
UINT8 findHexPattern(const QModelIndex & index, const QByteArray & hexPattern, const UINT8 mode);
|
||||||
|
UINT8 findGuidPattern(const QModelIndex & index, const QByteArray & guidPattern, const UINT8 mode);
|
||||||
UINT8 findTextPattern(const QModelIndex & index, const QString & pattern, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
UINT8 findTextPattern(const QModelIndex & index, const QString & pattern, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -129,7 +130,7 @@ private:
|
|||||||
|
|
||||||
// Patch helpers
|
// Patch helpers
|
||||||
UINT8 patchViaOffset(QByteArray & data, const UINT32 offset, const QByteArray & hexReplacePattern);
|
UINT8 patchViaOffset(QByteArray & data, const UINT32 offset, const QByteArray & hexReplacePattern);
|
||||||
UINT8 patchViaPattern(QByteArray & data, const QByteArray hexFindPattern, const QByteArray & hexReplacePattern);
|
UINT8 patchViaPattern(QByteArray & data, const QByteArray & hexFindPattern, const QByteArray & hexReplacePattern);
|
||||||
|
|
||||||
#ifndef _CONSOLE
|
#ifndef _CONSOLE
|
||||||
QQueue<MessageListItem> messageItems;
|
QQueue<MessageListItem> messageItems;
|
||||||
|
@ -15,13 +15,34 @@
|
|||||||
|
|
||||||
SearchDialog::SearchDialog(QWidget *parent) :
|
SearchDialog::SearchDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::SearchDialog)
|
ui(new Ui::SearchDialog),
|
||||||
|
hexValidator(QRegExp("([0-9a-fA-F\\.])*")),
|
||||||
|
guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}"))
|
||||||
{
|
{
|
||||||
// Create UI
|
// Create UI
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->hexEdit->setValidator(&hexValidator);
|
||||||
|
ui->guidEdit->setValidator(&guidValidator);
|
||||||
|
|
||||||
|
// Connect
|
||||||
|
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(setEditFocus(int)));
|
||||||
|
|
||||||
|
// Set initial focus
|
||||||
|
setEditFocus(ui->tabWidget->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchDialog::~SearchDialog()
|
SearchDialog::~SearchDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchDialog::setEditFocus(int index)
|
||||||
|
{
|
||||||
|
if (index == 0) // Hex pattern
|
||||||
|
ui->hexEdit->setFocus();
|
||||||
|
else if (index == 1) // GUID
|
||||||
|
ui->guidEdit->setFocus();
|
||||||
|
else if (index == 2) // Text
|
||||||
|
ui->textEdit->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define SEARCHDIALOG_H
|
#define SEARCHDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QRegExpValidator>
|
||||||
#include "ui_searchdialog.h"
|
#include "ui_searchdialog.h"
|
||||||
|
|
||||||
class SearchDialog : public QDialog
|
class SearchDialog : public QDialog
|
||||||
@ -27,8 +28,11 @@ public:
|
|||||||
Ui::SearchDialog* ui;
|
Ui::SearchDialog* ui;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//void setEditMask();
|
void setEditFocus(int index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QRegExpValidator hexValidator;
|
||||||
|
QRegExpValidator guidValidator;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,7 +35,17 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="hexEdit"/>
|
<widget class="QLineEdit" name="hexEdit">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Consolas</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="inputMask">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="hexGroupBox">
|
<widget class="QGroupBox" name="hexGroupBox">
|
||||||
@ -78,6 +88,78 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="guidTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>GUID</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="guidLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>GUID:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="guidEdit">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Consolas</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="inputMask">
|
||||||
|
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; </string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>........-....-....-....-............</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="guidGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Search scope</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="guidScopeFullRadioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Header and body</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="guidScopeHeaderRadioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Header only</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="guidScopeBodyRadioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Body only</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="textTab">
|
<widget class="QWidget" name="textTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Text</string>
|
<string>Text</string>
|
||||||
@ -136,7 +218,15 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
<tabstop>tabWidget</tabstop>
|
||||||
|
<tabstop>hexEdit</tabstop>
|
||||||
|
<tabstop>hexScopeFullRadioButton</tabstop>
|
||||||
|
<tabstop>hexScopeHeaderRadioButton</tabstop>
|
||||||
|
<tabstop>hexScopeBodyRadioButton</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
|
<tabstop>textEdit</tabstop>
|
||||||
|
<tabstop>textUnicodeCheckBox</tabstop>
|
||||||
|
<tabstop>textCaseSensitiveCheckBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
39
uefitool.cpp
39
uefitool.cpp
@ -18,6 +18,8 @@ UEFITool::UEFITool(QWidget *parent) :
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::UEFITool)
|
ui(new Ui::UEFITool)
|
||||||
{
|
{
|
||||||
|
clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
// Create UI
|
// Create UI
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
searchDialog = new SearchDialog(this);
|
searchDialog = new SearchDialog(this);
|
||||||
@ -36,6 +38,7 @@ UEFITool::UEFITool(QWidget *parent) :
|
|||||||
connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
|
connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
|
||||||
connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
|
connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
|
||||||
connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
|
connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
|
||||||
|
connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage()));
|
||||||
connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
|
connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
|
||||||
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
|
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
|
||||||
connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
|
connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
|
||||||
@ -73,6 +76,7 @@ void UEFITool::init()
|
|||||||
ui->menuVolumeActions->setDisabled(true);
|
ui->menuVolumeActions->setDisabled(true);
|
||||||
ui->menuFileActions->setDisabled(true);
|
ui->menuFileActions->setDisabled(true);
|
||||||
ui->menuSectionActions->setDisabled(true);
|
ui->menuSectionActions->setDisabled(true);
|
||||||
|
ui->actionMessagesCopy->setDisabled(true);
|
||||||
|
|
||||||
// Make new ffsEngine
|
// Make new ffsEngine
|
||||||
if (ffsEngine)
|
if (ffsEngine)
|
||||||
@ -84,6 +88,7 @@ void UEFITool::init()
|
|||||||
connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
|
connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
|
||||||
this, SLOT(populateUi(const QModelIndex &)));
|
this, SLOT(populateUi(const QModelIndex &)));
|
||||||
connect(ui->messageListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
|
connect(ui->messageListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
|
||||||
|
connect(ui->messageListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyAction(QListWidgetItem*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::populateUi(const QModelIndex ¤t)
|
void UEFITool::populateUi(const QModelIndex ¤t)
|
||||||
@ -119,6 +124,7 @@ void UEFITool::populateUi(const QModelIndex ¤t)
|
|||||||
ui->actionInsertAfter->setEnabled(type == Types::File || type == Types::Section);
|
ui->actionInsertAfter->setEnabled(type == Types::File || type == Types::Section);
|
||||||
ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::File || type == Types::Section);
|
ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::File || type == Types::Section);
|
||||||
ui->actionReplaceBody->setEnabled(type == Types::File || type == Types::Section);
|
ui->actionReplaceBody->setEnabled(type == Types::File || type == Types::Section);
|
||||||
|
ui->actionMessagesCopy->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::search()
|
void UEFITool::search()
|
||||||
@ -130,7 +136,8 @@ void UEFITool::search()
|
|||||||
|
|
||||||
int index = searchDialog->ui->tabWidget->currentIndex();
|
int index = searchDialog->ui->tabWidget->currentIndex();
|
||||||
if (index == 0) { // Hex pattern
|
if (index == 0) { // Hex pattern
|
||||||
QByteArray pattern = QByteArray::fromHex(searchDialog->ui->hexEdit->text().toLatin1());
|
searchDialog->ui->hexEdit->setFocus();
|
||||||
|
QByteArray pattern = searchDialog->ui->hexEdit->text().toLatin1();
|
||||||
if (pattern.isEmpty())
|
if (pattern.isEmpty())
|
||||||
return;
|
return;
|
||||||
UINT8 mode;
|
UINT8 mode;
|
||||||
@ -143,7 +150,23 @@ void UEFITool::search()
|
|||||||
ffsEngine->findHexPattern(rootIndex, pattern, mode);
|
ffsEngine->findHexPattern(rootIndex, pattern, mode);
|
||||||
showMessages();
|
showMessages();
|
||||||
}
|
}
|
||||||
else if (index == 1) { // Text string
|
else if (index == 1) { // GUID
|
||||||
|
searchDialog->ui->guidEdit->setFocus();
|
||||||
|
QByteArray pattern = searchDialog->ui->guidEdit->text().toLatin1();
|
||||||
|
if (pattern.isEmpty())
|
||||||
|
return;
|
||||||
|
UINT8 mode;
|
||||||
|
if (searchDialog->ui->guidScopeHeaderRadioButton->isChecked())
|
||||||
|
mode = SEARCH_MODE_HEADER;
|
||||||
|
else if (searchDialog->ui->guidScopeBodyRadioButton->isChecked())
|
||||||
|
mode = SEARCH_MODE_BODY;
|
||||||
|
else
|
||||||
|
mode = SEARCH_MODE_ALL;
|
||||||
|
ffsEngine->findGuidPattern(rootIndex, pattern, mode);
|
||||||
|
showMessages();
|
||||||
|
}
|
||||||
|
else if (index == 2) { // Text string
|
||||||
|
searchDialog->ui->textEdit->setFocus();
|
||||||
QString pattern = searchDialog->ui->textEdit->text();
|
QString pattern = searchDialog->ui->textEdit->text();
|
||||||
if (pattern.isEmpty())
|
if (pattern.isEmpty())
|
||||||
return;
|
return;
|
||||||
@ -526,11 +549,23 @@ void UEFITool::openImageFile(QString path)
|
|||||||
ui->actionSearch->setEnabled(true);
|
ui->actionSearch->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UEFITool::copyMessage()
|
||||||
|
{
|
||||||
|
clipboard->clear();
|
||||||
|
clipboard->setText(ui->messageListWidget->currentItem()->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void UEFITool::enableMessagesCopyAction(QListWidgetItem* item)
|
||||||
|
{
|
||||||
|
ui->actionMessagesCopy->setEnabled(item != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void UEFITool::clearMessages()
|
void UEFITool::clearMessages()
|
||||||
{
|
{
|
||||||
ffsEngine->clearMessages();
|
ffsEngine->clearMessages();
|
||||||
messageItems.clear();
|
messageItems.clear();
|
||||||
ui->messageListWidget->clear();
|
ui->messageListWidget->clear();
|
||||||
|
ui->actionMessagesCopy->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::dragEnterEvent(QDragEnterEvent* event)
|
void UEFITool::dragEnterEvent(QDragEnterEvent* event)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -54,7 +55,6 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void init();
|
void init();
|
||||||
void populateUi(const QModelIndex ¤t);
|
void populateUi(const QModelIndex ¤t);
|
||||||
//void resizeTreeViewColumns();
|
|
||||||
void scrollTreeView(QListWidgetItem* item);
|
void scrollTreeView(QListWidgetItem* item);
|
||||||
|
|
||||||
void openImageFile();
|
void openImageFile();
|
||||||
@ -78,8 +78,10 @@ private slots:
|
|||||||
|
|
||||||
void remove();
|
void remove();
|
||||||
|
|
||||||
|
void copyMessage();
|
||||||
|
void enableMessagesCopyAction(QListWidgetItem* item);
|
||||||
void clearMessages();
|
void clearMessages();
|
||||||
|
|
||||||
void about();
|
void about();
|
||||||
void aboutQt();
|
void aboutQt();
|
||||||
|
|
||||||
@ -90,8 +92,9 @@ private:
|
|||||||
Ui::UEFITool* ui;
|
Ui::UEFITool* ui;
|
||||||
FfsEngine* ffsEngine;
|
FfsEngine* ffsEngine;
|
||||||
SearchDialog* searchDialog;
|
SearchDialog* searchDialog;
|
||||||
|
QClipboard* clipboard;
|
||||||
QQueue<MessageListItem> messageItems;
|
QQueue<MessageListItem> messageItems;
|
||||||
|
|
||||||
void showMessages();
|
void showMessages();
|
||||||
|
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
|
60
uefitool.ui
60
uefitool.ui
@ -20,7 +20,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>UEFITool 0.18.2</string>
|
<string>UEFITool 0.18.3</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -33,16 +33,7 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -62,16 +53,7 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -115,16 +97,7 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -160,16 +133,7 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -180,6 +144,9 @@
|
|||||||
<pointsize>9</pointsize>
|
<pointsize>9</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -301,6 +268,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Messages</string>
|
<string>&Messages</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionMessagesCopy"/>
|
||||||
<addaction name="actionMessagesClear"/>
|
<addaction name="actionMessagesClear"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuCapsuleActions"/>
|
<addaction name="menuCapsuleActions"/>
|
||||||
@ -494,7 +462,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionMessagesClear">
|
<action name="actionMessagesClear">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Clear</string>
|
<string>Cl&ear</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Clear messages</string>
|
<string>Clear messages</string>
|
||||||
@ -517,6 +485,14 @@
|
|||||||
<string>Ctrl+Shift+R</string>
|
<string>Ctrl+Shift+R</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionMessagesCopy">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Copy</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Shift+C</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
Reference in New Issue
Block a user