1
0
Fork 0

Add Start from Selection

This commit is contained in:
dad 2023-10-23 11:10:59 -06:00
parent ca637fad33
commit 7dade58481
7 changed files with 45 additions and 8 deletions

View File

@ -1218,6 +1218,8 @@ void CPUDisassembly::findPatternSlot()
{
HexEditDialog hexEdit(this);
hexEdit.isDataCopiable(false);
if(sender() == mFindPatternRegion)
hexEdit.showStartFromSelection(true, ConfigBool("Disassembler", "FindPatternFromSelection"));
hexEdit.mHexEdit->setOverwriteMode(false);
hexEdit.setWindowTitle(tr("Find Pattern..."));
if(hexEdit.exec() != QDialog::Accepted)
@ -1228,7 +1230,10 @@ void CPUDisassembly::findPatternSlot()
QString command;
if(sender() == mFindPatternRegion)
{
addr = DbgMemFindBaseAddr(addr, 0);
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());
}
else if(sender() == mFindPatternModule)
@ -1773,18 +1778,18 @@ void CPUDisassembly::findCommandSlot()
LineEditDialog mLineEdit(this);
mLineEdit.enableCheckBox(refFindType == 0);
mLineEdit.setCheckBoxText(tr("Entire &Block"));
mLineEdit.setCheckBox(ConfigBool("Disassembler", "FindCommandEntireBlock"));
mLineEdit.setCheckBoxText(tr("Start from &Selection"));
mLineEdit.setCheckBox(ConfigBool("Disassembler", "FindCommandFromSelection"));
mLineEdit.setWindowTitle("Find Command");
if(mLineEdit.exec() != QDialog::Accepted)
return;
Config()->setBool("Disassembler", "FindCommandEntireBlock", mLineEdit.bChecked);
Config()->setBool("Disassembler", "FindCommandFromSelection", mLineEdit.bChecked);
char error[MAX_ERROR_SIZE] = "";
unsigned char dest[16];
int asmsize = 0;
duint va = rvaToVa(getInitialSelection());
if(mLineEdit.bChecked) // entire block
if(!mLineEdit.bChecked) // start search from selection
va = mMemPage->getBase();
if(!DbgFunctions()->Assemble(mMemPage->getBase() + mMemPage->getSize() / 2, dest, &asmsize, mLineEdit.editText.toUtf8().constData(), error))

View File

@ -1444,12 +1444,16 @@ void CPUDump::findPattern()
{
HexEditDialog hexEdit(this);
hexEdit.isDataCopiable(false);
hexEdit.showStartFromSelection(true, ConfigBool("Gui", "CPUDumpStartFromSelect"));
hexEdit.mHexEdit->setOverwriteMode(false);
hexEdit.setWindowTitle(tr("Find Pattern..."));
if(hexEdit.exec() != QDialog::Accepted)
return;
bool startFromSelection = hexEdit.startFromSelection();
Config()->setBool("Gui", "CPUDumpStartFromSelect", startFromSelection);
dsint addr = rvaToVa(getSelectionStart());
addr = DbgMemFindBaseAddr(addr, 0);
if(!startFromSelection)
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText = ToPtrString(addr);
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&"));
emit displayReferencesWidget();

View File

@ -866,13 +866,17 @@ void CPUStack::findPattern()
{
HexEditDialog hexEdit(this);
hexEdit.isDataCopiable(false);
hexEdit.showStartFromSelection(true, ConfigBool("Gui", "CPUStackStartFromSelect"));
hexEdit.mHexEdit->setOverwriteMode(false);
hexEdit.setWindowTitle(tr("Find Pattern..."));
if(hexEdit.exec() != QDialog::Accepted)
return;
dsint addr = rvaToVa(getSelectionStart());
addr = DbgMemFindBaseAddr(addr, 0);
bool startFromSelection = hexEdit.startFromSelection();
Config()->setBool("Gui", "CPUStackStartFromSelect", startFromSelection);
if(!startFromSelection)
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText = ToPtrString(addr);
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&"));

View File

@ -28,6 +28,7 @@ HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexE
ui->chkKeepSize->setChecked(ConfigBool("HexDump", "KeepSize"));
ui->chkKeepSize->hide();
ui->chkEntireBlock->hide();
ui->chkFromSelection->hide();
mDataInitialized = false;
stringEditorLock = false;
@ -112,6 +113,12 @@ void HexEditDialog::showKeepSize(bool 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)
{
if(copyDataEnabled == false)
@ -150,6 +157,11 @@ bool HexEditDialog::entireBlock()
return ui->chkEntireBlock->isChecked();
}
bool HexEditDialog::startFromSelection()
{
return ui->chkFromSelection->isChecked();
}
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());

View File

@ -18,10 +18,12 @@ public:
void showEntireBlock(bool show, bool checked = false);
void showKeepSize(bool show);
void showStartFromSelection(bool show, bool checked = false);
void isDataCopiable(bool copyDataEnabled);
void updateCodepage();
bool entireBlock();
bool startFromSelection();
QHexEdit* mHexEdit;

View File

@ -445,6 +445,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkFromSelection">
<property name="text">
<string>Start from &amp;Selection</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

View File

@ -254,7 +254,8 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
disassemblyBool.insert("KeepSize", false);
disassemblyBool.insert("FillNOPs", false);
disassemblyBool.insert("Uppercase", false);
disassemblyBool.insert("FindCommandEntireBlock", false);
disassemblyBool.insert("FindCommandFromSelection", true);
disassemblyBool.insert("FindPatternFromSelection", true);
disassemblyBool.insert("OnlyCipAutoComments", false);
disassemblyBool.insert("TabbedMnemonic", false);
disassemblyBool.insert("LongDataInstruction", false);
@ -292,6 +293,8 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
guiBool.insert("AutoFollowInStack", true);
guiBool.insert("EnableQtHighDpiScaling", true);
guiBool.insert("Topmost", false);
guiBool.insert("CPUDumpStartFromSelect", true);
guiBool.insert("CPUStackStartFromSelect", true);
//Named menu settings
insertMenuBuilderBools(&guiBool, "CPUDisassembly", 50); //CPUDisassembly
insertMenuBuilderBools(&guiBool, "CPUDump", 50); //CPUDump