From 806fc5bded3471aa1d952b8a9012844457348ccc Mon Sep 17 00:00:00 2001 From: Jubal Date: Wed, 31 Jan 2018 03:01:16 -0500 Subject: [PATCH] Added options for disasm (#306) --- src/cutter.cpp | 12 ++++- src/dialogs/preferences/AsmOptionsWidget.cpp | 38 ++++++++++++++ src/dialogs/preferences/AsmOptionsWidget.h | 5 ++ src/dialogs/preferences/AsmOptionsWidget.ui | 53 +++++++++++++++++++- src/utils/Configuration.h | 15 ++++++ 5 files changed, 119 insertions(+), 4 deletions(-) diff --git a/src/cutter.cpp b/src/cutter.cpp index c3eaf767..d457e643 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -507,7 +507,11 @@ void CutterCore::resetDefaultAsmOptions() setConfig("asm.offset", Config()->getAsmOffset()); setConfig("asm.describe", Config()->getAsmDescribe()); setConfig("asm.stackptr", Config()->getAsmStackPointer()); + setConfig("asm.slow", Config()->getAsmSlow()); setConfig("asm.lines", Config()->getAsmLines()); + setConfig("asm.emu", Config()->getAsmEmu()); + setConfig("asm.cmtright", Config()->getAsmCmtRight()); + setConfig("asm.varsum", Config()->getAsmVarSum()); setConfig("asm.bytes", Config()->getAsmBytes()); setConfig("asm.bytespace", Config()->getAsmBytespace()); setConfig("asm.lbytes", Config()->getAsmLBytes()); @@ -517,6 +521,7 @@ void CutterCore::resetDefaultAsmOptions() setConfig("asm.capitalize", Config()->getAsmCapitalize()); setConfig("asm.varsub", Config()->getAsmVarsub()); setConfig("asm.varsub_only", Config()->getAsmVarsubOnly()); + setConfig("asm.tabs", Config()->getAsmTabs()); } void CutterCore::saveDefaultAsmOptions() @@ -526,7 +531,11 @@ void CutterCore::saveDefaultAsmOptions() Config()->setAsmOffset(getConfigb("asm.offset")); Config()->setAsmDescribe(getConfigb("asm.describe")); Config()->setAsmStackPointer(getConfigb("asm.stackptr")); + Config()->setAsmSlow(getConfigb("asm.slow")); Config()->setAsmLines(getConfigb("asm.lines")); + Config()->setAsmEmu(getConfigb("asm.emu")); + Config()->setAsmCmtRight(getConfigb("asm.cmtright")); + Config()->setAsmVarSum(getConfigb("asm.varsum")); Config()->setAsmBytes(getConfigb("asm.bytes")); Config()->setAsmBytespace(getConfigb("asm.bytespace")); Config()->setAsmLBytes(getConfigb("asm.lbytes")); @@ -536,6 +545,7 @@ void CutterCore::saveDefaultAsmOptions() Config()->setAsmCapitalize(getConfigb("asm.capitalize")); Config()->setAsmVarsub(getConfigb("asm.varsub")); Config()->setAsmVarsubOnly(getConfigb("asm.varsub_only")); + Config()->setAsmTabs(getConfigi("asm.tabs")); } QString CutterCore::getConfig(const QString &k) @@ -768,12 +778,10 @@ void CutterCore::setSettings() //setConfig("asm.functions", "false"); setConfig("hex.pairs", false); setConfig("asm.cmtflgrefs", false); - setConfig("asm.cmtright", true); setConfig("asm.cmtcol", 70); setConfig("asm.xrefs", false); setConfig("asm.fcnlines", false); - setConfig("asm.tabs", 5); setConfig("asm.tabsonce", true); setConfig("asm.tabsoff", 5); setConfig("asm.nbytes", 10); diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 9101e681..843b5cf5 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -40,7 +40,11 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() qhelpers::setCheckedWithoutSignals(ui->offsetCheckBox, Core()->getConfigb("asm.offset")); qhelpers::setCheckedWithoutSignals(ui->describeCheckBox, Core()->getConfigb("asm.describe")); qhelpers::setCheckedWithoutSignals(ui->stackpointerCheckBox, Core()->getConfigb("asm.stackptr")); + qhelpers::setCheckedWithoutSignals(ui->slowCheckBox, Core()->getConfigb("asm.slow")); qhelpers::setCheckedWithoutSignals(ui->linesCheckBox, Core()->getConfigb("asm.lines")); + qhelpers::setCheckedWithoutSignals(ui->emuCheckBox, Core()->getConfigb("asm.emu")); + qhelpers::setCheckedWithoutSignals(ui->cmtrightCheckBox, Core()->getConfigb("asm.cmtright")); + qhelpers::setCheckedWithoutSignals(ui->varsumCheckBox, Core()->getConfigb("asm.varsum")); bool bytesEnabled = Core()->getConfigb("asm.bytes"); qhelpers::setCheckedWithoutSignals(ui->bytesCheckBox, bytesEnabled); @@ -76,6 +80,10 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() } ui->caseComboBox->blockSignals(false); + ui->asmTabsSpinBox->blockSignals(true); + ui->asmTabsSpinBox->setValue(Core()->getConfigi("asm.tabs")); + ui->asmTabsSpinBox->blockSignals(false); + qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, Core()->getConfigb("asm.bbline")); bool varsubEnabled = Core()->getConfigb("asm.varsub"); @@ -135,12 +143,36 @@ void AsmOptionsWidget::on_stackpointerCheckBox_toggled(bool checked) triggerAsmOptionsChanged(); } +void AsmOptionsWidget::on_slowCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.slow", checked); + triggerAsmOptionsChanged(); +} + void AsmOptionsWidget::on_linesCheckBox_toggled(bool checked) { Core()->setConfig("asm.lines", checked); triggerAsmOptionsChanged(); } +void AsmOptionsWidget::on_emuCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.emu", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_cmtrightCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.cmtright", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_varsumCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.varsum", checked); + triggerAsmOptionsChanged(); +} + void AsmOptionsWidget::on_bytesCheckBox_toggled(bool checked) { Core()->setConfig("asm.bytes", checked); @@ -199,6 +231,12 @@ void AsmOptionsWidget::on_caseComboBox_currentIndexChanged(int index) triggerAsmOptionsChanged(); } +void AsmOptionsWidget::on_asmTabsSpinBox_valueChanged(int value) +{ + Core()->setConfig("asm.tabs", value); + triggerAsmOptionsChanged(); +} + void AsmOptionsWidget::on_bblineCheckBox_toggled(bool checked) { Core()->setConfig("asm.bbline", checked); diff --git a/src/dialogs/preferences/AsmOptionsWidget.h b/src/dialogs/preferences/AsmOptionsWidget.h index a5de79fd..f93c0def 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.h +++ b/src/dialogs/preferences/AsmOptionsWidget.h @@ -39,12 +39,17 @@ private slots: void on_offsetCheckBox_toggled(bool checked); void on_describeCheckBox_toggled(bool checked); void on_stackpointerCheckBox_toggled(bool checked); + void on_slowCheckBox_toggled(bool checked); void on_linesCheckBox_toggled(bool checked); + void on_emuCheckBox_toggled(bool checked); + void on_cmtrightCheckBox_toggled(bool checked); + void on_varsumCheckBox_toggled(bool checked); void on_bytesCheckBox_toggled(bool checked); void on_bytespaceCheckBox_toggled(bool checked); void on_lbytesCheckBox_toggled(bool checked); void on_syntaxComboBox_currentIndexChanged(int index); void on_caseComboBox_currentIndexChanged(int index); + void on_asmTabsSpinBox_valueChanged(int value); void on_bblineCheckBox_toggled(bool checked); void on_varsubCheckBox_toggled(bool checked); void on_varsubOnlyCheckBox_toggled(bool checked); diff --git a/src/dialogs/preferences/AsmOptionsWidget.ui b/src/dialogs/preferences/AsmOptionsWidget.ui index ca21adc1..5081d6ac 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -6,8 +6,8 @@ 0 0 - 541 - 478 + 545 + 638 @@ -49,6 +49,13 @@ + + + + Slow Analysis (asm.slow) + + + @@ -56,6 +63,27 @@ + + + + Run ESIL emulation analysis (asm.emu) + + + + + + + Show comments at right of assembly (asm.cmtright) + + + + + + + Show variables summary instead of full list (asm.varsum) + + + @@ -117,6 +145,27 @@ + + + + + + Tabs in assembly (asm.tabs): + + + + + + + 100 + + + 5 + + + + + diff --git a/src/utils/Configuration.h b/src/utils/Configuration.h index 5ac64f9a..8d3748f8 100644 --- a/src/utils/Configuration.h +++ b/src/utils/Configuration.h @@ -58,9 +58,21 @@ public: bool getAsmStackPointer() const { return s.value("asm.stackptr", false).toBool(); } void setAsmStackPointer(bool v) { s.setValue("asm.stackptr", v); } + bool getAsmSlow() const { return s.value("asm.slow", false).toBool(); } + void setAsmSlow(bool v) { s.setValue("asm.slow", v); } + bool getAsmLines() const { return s.value("asm.lines", false).toBool(); } void setAsmLines(bool v) { s.setValue("asm.lines", v); } + bool getAsmEmu() const { return s.value("asm.emu", false).toBool(); } + void setAsmEmu(bool v) { s.setValue("asm.emu", v); } + + bool getAsmCmtRight() const { return s.value("asm.cmtright", true).toBool(); } + void setAsmCmtRight(bool v) { s.setValue("asm.cmtright", v); } + + bool getAsmVarSum() const { return s.value("asm.varsum", false).toBool(); } + void setAsmVarSum(bool v) { s.setValue("asm.varsum", v); } + bool getAsmBytes() const { return s.value("asm.bytes", false).toBool(); } void setAsmBytes(bool v) { s.setValue("asm.bytes", v); } @@ -88,6 +100,9 @@ public: bool getAsmVarsubOnly() const { return s.value("asm.varsub_only", true).toBool(); } void setAsmVarsubOnly(bool v) { s.setValue("asm.varsub_only", v); } + int getAsmTabs() const { return s.value("asm.tabs", 5).toInt(); } + void setAsmTabs(int v) { s.setValue("asm.tabs", v); } + signals: void fontsUpdated(); void colorsUpdated();