Merge pull request #3240 from HayFieldLaps/find-pattern-ranges
Find Pattern searches now begin at start of current region
This commit is contained in:
commit
b0392eda1c
|
@ -1217,20 +1217,23 @@ void CPUDisassembly::findCallsSlot()
|
||||||
void CPUDisassembly::findPatternSlot()
|
void CPUDisassembly::findPatternSlot()
|
||||||
{
|
{
|
||||||
HexEditDialog hexEdit(this);
|
HexEditDialog hexEdit(this);
|
||||||
hexEdit.showEntireBlock(true);
|
|
||||||
hexEdit.isDataCopiable(false);
|
hexEdit.isDataCopiable(false);
|
||||||
|
if(sender() == mFindPatternRegion)
|
||||||
|
hexEdit.showStartFromSelection(true, ConfigBool("Disassembler", "FindPatternFromSelection"));
|
||||||
hexEdit.mHexEdit->setOverwriteMode(false);
|
hexEdit.mHexEdit->setOverwriteMode(false);
|
||||||
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
||||||
if(hexEdit.exec() != QDialog::Accepted)
|
if(hexEdit.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dsint addr = rvaToVa(getSelectionStart());
|
dsint addr = rvaToVa(getSelectionStart());
|
||||||
if(hexEdit.entireBlock())
|
|
||||||
addr = DbgMemFindBaseAddr(addr, 0);
|
|
||||||
|
|
||||||
QString command;
|
QString command;
|
||||||
if(sender() == mFindPatternRegion)
|
if(sender() == mFindPatternRegion)
|
||||||
{
|
{
|
||||||
|
bool startFromSelection = hexEdit.startFromSelection();
|
||||||
|
Config()->setBool("Disassembler", "FindPatternFromSelection", startFromSelection);
|
||||||
|
if(!startFromSelection)
|
||||||
|
addr = DbgMemFindBaseAddr(addr, 0);
|
||||||
command = QString("findall %1, %2").arg(ToHexString(addr), hexEdit.mHexEdit->pattern());
|
command = QString("findall %1, %2").arg(ToHexString(addr), hexEdit.mHexEdit->pattern());
|
||||||
}
|
}
|
||||||
else if(sender() == mFindPatternModule)
|
else if(sender() == mFindPatternModule)
|
||||||
|
@ -1775,18 +1778,18 @@ void CPUDisassembly::findCommandSlot()
|
||||||
|
|
||||||
LineEditDialog mLineEdit(this);
|
LineEditDialog mLineEdit(this);
|
||||||
mLineEdit.enableCheckBox(refFindType == 0);
|
mLineEdit.enableCheckBox(refFindType == 0);
|
||||||
mLineEdit.setCheckBoxText(tr("Entire &Block"));
|
mLineEdit.setCheckBoxText(tr("Start from &Selection"));
|
||||||
mLineEdit.setCheckBox(ConfigBool("Disassembler", "FindCommandEntireBlock"));
|
mLineEdit.setCheckBox(ConfigBool("Disassembler", "FindCommandFromSelection"));
|
||||||
mLineEdit.setWindowTitle("Find Command");
|
mLineEdit.setWindowTitle("Find Command");
|
||||||
if(mLineEdit.exec() != QDialog::Accepted)
|
if(mLineEdit.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
Config()->setBool("Disassembler", "FindCommandEntireBlock", mLineEdit.bChecked);
|
Config()->setBool("Disassembler", "FindCommandFromSelection", mLineEdit.bChecked);
|
||||||
|
|
||||||
char error[MAX_ERROR_SIZE] = "";
|
char error[MAX_ERROR_SIZE] = "";
|
||||||
unsigned char dest[16];
|
unsigned char dest[16];
|
||||||
int asmsize = 0;
|
int asmsize = 0;
|
||||||
duint va = rvaToVa(getInitialSelection());
|
duint va = rvaToVa(getInitialSelection());
|
||||||
if(mLineEdit.bChecked) // entire block
|
if(!mLineEdit.bChecked) // start search from selection
|
||||||
va = mMemPage->getBase();
|
va = mMemPage->getBase();
|
||||||
|
|
||||||
if(!DbgFunctions()->Assemble(mMemPage->getBase() + mMemPage->getSize() / 2, dest, &asmsize, mLineEdit.editText.toUtf8().constData(), error))
|
if(!DbgFunctions()->Assemble(mMemPage->getBase() + mMemPage->getSize() / 2, dest, &asmsize, mLineEdit.editText.toUtf8().constData(), error))
|
||||||
|
|
|
@ -1443,14 +1443,16 @@ void CPUDump::binarySaveToFileSlot()
|
||||||
void CPUDump::findPattern()
|
void CPUDump::findPattern()
|
||||||
{
|
{
|
||||||
HexEditDialog hexEdit(this);
|
HexEditDialog hexEdit(this);
|
||||||
hexEdit.showEntireBlock(true);
|
|
||||||
hexEdit.isDataCopiable(false);
|
hexEdit.isDataCopiable(false);
|
||||||
|
hexEdit.showStartFromSelection(true, ConfigBool("Gui", "CPUDumpStartFromSelect"));
|
||||||
hexEdit.mHexEdit->setOverwriteMode(false);
|
hexEdit.mHexEdit->setOverwriteMode(false);
|
||||||
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
||||||
if(hexEdit.exec() != QDialog::Accepted)
|
if(hexEdit.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
bool startFromSelection = hexEdit.startFromSelection();
|
||||||
|
Config()->setBool("Gui", "CPUDumpStartFromSelect", startFromSelection);
|
||||||
dsint addr = rvaToVa(getSelectionStart());
|
dsint addr = rvaToVa(getSelectionStart());
|
||||||
if(hexEdit.entireBlock())
|
if(!startFromSelection)
|
||||||
addr = DbgMemFindBaseAddr(addr, 0);
|
addr = DbgMemFindBaseAddr(addr, 0);
|
||||||
QString addrText = ToPtrString(addr);
|
QString addrText = ToPtrString(addr);
|
||||||
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&"));
|
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&"));
|
||||||
|
|
|
@ -865,15 +865,19 @@ void CPUStack::binaryPasteIgnoreSizeSlot()
|
||||||
void CPUStack::findPattern()
|
void CPUStack::findPattern()
|
||||||
{
|
{
|
||||||
HexEditDialog hexEdit(this);
|
HexEditDialog hexEdit(this);
|
||||||
hexEdit.showEntireBlock(true);
|
|
||||||
hexEdit.isDataCopiable(false);
|
hexEdit.isDataCopiable(false);
|
||||||
|
hexEdit.showStartFromSelection(true, ConfigBool("Gui", "CPUStackStartFromSelect"));
|
||||||
hexEdit.mHexEdit->setOverwriteMode(false);
|
hexEdit.mHexEdit->setOverwriteMode(false);
|
||||||
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
||||||
if(hexEdit.exec() != QDialog::Accepted)
|
if(hexEdit.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dsint addr = rvaToVa(getSelectionStart());
|
dsint addr = rvaToVa(getSelectionStart());
|
||||||
if(hexEdit.entireBlock())
|
bool startFromSelection = hexEdit.startFromSelection();
|
||||||
|
Config()->setBool("Gui", "CPUStackStartFromSelect", startFromSelection);
|
||||||
|
if(!startFromSelection)
|
||||||
addr = DbgMemFindBaseAddr(addr, 0);
|
addr = DbgMemFindBaseAddr(addr, 0);
|
||||||
|
|
||||||
QString addrText = ToPtrString(addr);
|
QString addrText = ToPtrString(addr);
|
||||||
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&"));
|
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&"));
|
||||||
emit displayReferencesWidget();
|
emit displayReferencesWidget();
|
||||||
|
|
|
@ -28,6 +28,7 @@ HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexE
|
||||||
ui->chkKeepSize->setChecked(ConfigBool("HexDump", "KeepSize"));
|
ui->chkKeepSize->setChecked(ConfigBool("HexDump", "KeepSize"));
|
||||||
ui->chkKeepSize->hide();
|
ui->chkKeepSize->hide();
|
||||||
ui->chkEntireBlock->hide();
|
ui->chkEntireBlock->hide();
|
||||||
|
ui->chkFromSelection->hide();
|
||||||
|
|
||||||
mDataInitialized = false;
|
mDataInitialized = false;
|
||||||
stringEditorLock = false;
|
stringEditorLock = false;
|
||||||
|
@ -112,6 +113,12 @@ void HexEditDialog::showKeepSize(bool show)
|
||||||
ui->chkKeepSize->setVisible(show);
|
ui->chkKeepSize->setVisible(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HexEditDialog::showStartFromSelection(bool show, bool checked)
|
||||||
|
{
|
||||||
|
ui->chkFromSelection->setVisible(show);
|
||||||
|
ui->chkFromSelection->setChecked(checked);
|
||||||
|
}
|
||||||
|
|
||||||
void HexEditDialog::isDataCopiable(bool copyDataEnabled)
|
void HexEditDialog::isDataCopiable(bool copyDataEnabled)
|
||||||
{
|
{
|
||||||
if(copyDataEnabled == false)
|
if(copyDataEnabled == false)
|
||||||
|
@ -150,6 +157,11 @@ bool HexEditDialog::entireBlock()
|
||||||
return ui->chkEntireBlock->isChecked();
|
return ui->chkEntireBlock->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HexEditDialog::startFromSelection()
|
||||||
|
{
|
||||||
|
return ui->chkFromSelection->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
void HexEditDialog::updateStyle()
|
void HexEditDialog::updateStyle()
|
||||||
{
|
{
|
||||||
QString style = QString("QLineEdit { border-style: outset; border-width: 1px; border-color: %1; color: %1; background-color: %2 }").arg(ConfigColor("HexEditTextColor").name(), ConfigColor("HexEditBackgroundColor").name());
|
QString style = QString("QLineEdit { border-style: outset; border-width: 1px; border-color: %1; color: %1; background-color: %2 }").arg(ConfigColor("HexEditTextColor").name(), ConfigColor("HexEditBackgroundColor").name());
|
||||||
|
|
|
@ -18,10 +18,12 @@ public:
|
||||||
|
|
||||||
void showEntireBlock(bool show, bool checked = false);
|
void showEntireBlock(bool show, bool checked = false);
|
||||||
void showKeepSize(bool show);
|
void showKeepSize(bool show);
|
||||||
|
void showStartFromSelection(bool show, bool checked = false);
|
||||||
void isDataCopiable(bool copyDataEnabled);
|
void isDataCopiable(bool copyDataEnabled);
|
||||||
void updateCodepage();
|
void updateCodepage();
|
||||||
|
|
||||||
bool entireBlock();
|
bool entireBlock();
|
||||||
|
bool startFromSelection();
|
||||||
|
|
||||||
QHexEdit* mHexEdit;
|
QHexEdit* mHexEdit;
|
||||||
|
|
||||||
|
|
|
@ -472,6 +472,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chkFromSelection">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start from &Selection</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -612,12 +612,23 @@ void MemoryMapView::findPatternSlot()
|
||||||
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
hexEdit.setWindowTitle(tr("Find Pattern..."));
|
||||||
if(hexEdit.exec() != QDialog::Accepted)
|
if(hexEdit.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
duint addr = getSelectionAddr();
|
|
||||||
entireBlockEnabled = hexEdit.entireBlock();
|
entireBlockEnabled = hexEdit.entireBlock();
|
||||||
BridgeSettingSetUint("Gui", "MemoryMapEntireBlock", entireBlockEnabled);
|
BridgeSettingSetUint("Gui", "MemoryMapEntireBlock", entireBlockEnabled);
|
||||||
if(entireBlockEnabled)
|
if(entireBlockEnabled)
|
||||||
addr = 0;
|
{
|
||||||
DbgCmdExec(QString("findallmem %1, %2, &data&").arg(ToPtrString(addr)).arg(hexEdit.mHexEdit->pattern()));
|
DbgCmdExec(QString("findallmem 0, %2").arg(hexEdit.mHexEdit->pattern()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QList<duint> selection = getSelection();
|
||||||
|
if(selection.isEmpty())
|
||||||
|
return;
|
||||||
|
duint addrFirst = getCellUserdata(selection.first(), ColAddress);
|
||||||
|
duint addrLast = getCellUserdata(selection.last(), ColAddress);
|
||||||
|
duint size = getCellUserdata(selection.last(), ColSize);
|
||||||
|
DbgCmdExec(QString("findallmem %1, %2, %3").arg(ToPtrString(addrFirst)).arg(hexEdit.mHexEdit->pattern()).arg(ToHexString(addrLast - addrFirst + size)));
|
||||||
|
}
|
||||||
emit showReferences();
|
emit showReferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,8 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
||||||
disassemblyBool.insert("KeepSize", false);
|
disassemblyBool.insert("KeepSize", false);
|
||||||
disassemblyBool.insert("FillNOPs", false);
|
disassemblyBool.insert("FillNOPs", false);
|
||||||
disassemblyBool.insert("Uppercase", false);
|
disassemblyBool.insert("Uppercase", false);
|
||||||
disassemblyBool.insert("FindCommandEntireBlock", false);
|
disassemblyBool.insert("FindCommandFromSelection", true);
|
||||||
|
disassemblyBool.insert("FindPatternFromSelection", true);
|
||||||
disassemblyBool.insert("OnlyCipAutoComments", false);
|
disassemblyBool.insert("OnlyCipAutoComments", false);
|
||||||
disassemblyBool.insert("TabbedMnemonic", false);
|
disassemblyBool.insert("TabbedMnemonic", false);
|
||||||
disassemblyBool.insert("LongDataInstruction", false);
|
disassemblyBool.insert("LongDataInstruction", false);
|
||||||
|
@ -292,6 +293,8 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
||||||
guiBool.insert("AutoFollowInStack", true);
|
guiBool.insert("AutoFollowInStack", true);
|
||||||
guiBool.insert("EnableQtHighDpiScaling", true);
|
guiBool.insert("EnableQtHighDpiScaling", true);
|
||||||
guiBool.insert("Topmost", false);
|
guiBool.insert("Topmost", false);
|
||||||
|
guiBool.insert("CPUDumpStartFromSelect", true);
|
||||||
|
guiBool.insert("CPUStackStartFromSelect", true);
|
||||||
//Named menu settings
|
//Named menu settings
|
||||||
insertMenuBuilderBools(&guiBool, "CPUDisassembly", 50); //CPUDisassembly
|
insertMenuBuilderBools(&guiBool, "CPUDisassembly", 50); //CPUDisassembly
|
||||||
insertMenuBuilderBools(&guiBool, "CPUDump", 50); //CPUDump
|
insertMenuBuilderBools(&guiBool, "CPUDump", 50); //CPUDump
|
||||||
|
|
Loading…
Reference in New Issue