From 10c26e783ba966ade656ff737a351b45fdf6b941 Mon Sep 17 00:00:00 2001 From: torusrxxx Date: Wed, 16 Mar 2022 23:59:13 +0800 Subject: [PATCH] Remember some window settings, copy old value, UI enhancement --- README_zh-CN.md | 4 ++-- src/gui/Src/Gui/CPURegistersView.cpp | 10 +++++++++ src/gui/Src/Gui/CPURegistersView.h | 2 ++ src/gui/Src/Gui/EditBreakpointDialog.ui | 27 +++++++++++++++++++++++++ src/gui/Src/Gui/EditFloatRegister.cpp | 18 +++++++++++++++++ src/gui/Src/Gui/HexEditDialog.cpp | 10 +++++++-- src/gui/Src/Gui/PatchDialog.cpp | 3 +++ src/gui/Src/Utils/Configuration.cpp | 5 +++++ 8 files changed, 75 insertions(+), 4 deletions(-) diff --git a/README_zh-CN.md b/README_zh-CN.md index 9921aed9..ff44f93b 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -6,7 +6,7 @@ [![Telegram](https://img.shields.io/badge/chat-%20on%20Telegram-blue.svg)](https://telegram.me/x64dbg) [![Discord](https://img.shields.io/badge/chat-on%20Discord-green.svg)](https://invite.gg/x64dbg) [![Slack](https://img.shields.io/badge/chat-on%20Slack-red.svg)](https://x64dbg-slack.herokuapp.com) [![Gitter](https://img.shields.io/badge/chat-on%20Gitter-lightseagreen.svg)](https://gitter.im/x64dbg/x64dbg) [![Freenode](https://img.shields.io/badge/chat-%20on%20freenode-brightgreen.svg)](https://webchat.freenode.net/?channels=x64dbg) [![Matrix](https://img.shields.io/badge/chat-on%20Matrix-yellowgreen.svg)](https://riot.im/app/#/room/#x64dbg:matrix.org) [![XMPP](https://img.shields.io/badge/chat-%20on%20XMPP-orange.svg)](https://inverse.chat/#converse/room?jid=x64dbg@conference.jwchat.org) -一个开源的Windows二进制调试器,旨在进行恶意软件分析和你没有源代码的可执行文件的逆向工程。有许多可用的功能和一个全面的[插件系统](http://plugins.x64dbg.com) 来添加你自己的功能。你可以在[博客](https://x64dbg.com/blog)!上找到更多信息! +一个开源的Windows二进制调试器,旨在进行恶意软件分析和你没有源代码的可执行文件的逆向工程。有许多可用的功能和一个全面的[插件系统](http://plugins.x64dbg.com) 来添加你自己的功能。你可以在[博客](https://x64dbg.com/blog)上找到更多信息! ## 屏幕截图 @@ -30,7 +30,7 @@ - 调试器核心由[TitanEngine社区版](https://github.com/x64dbg/TitanEngine)提供技术支持 - 反汇编引擎由 [Zydis](https://zydis.re)提供技术支持 -- 组件由 [XEDParse](https://github.com/x64dbg/XEDParse) 和 [asmjit](https://github.com/asmjit)提供技术支持 +- 汇编由 [XEDParse](https://github.com/x64dbg/XEDParse) 和 [asmjit](https://github.com/asmjit)提供技术支持 - 导入重建由 [Scylla](https://github.com/NtQuery/Scylla)提供技术支持 - JSON由 [Jansson](https://www.digip.org/jansson)提供技术支持 - 数据库优化由 [lz4](https://bitbucket.org/mrexodia/lz4)提供技术支持 diff --git a/src/gui/Src/Gui/CPURegistersView.cpp b/src/gui/Src/Gui/CPURegistersView.cpp index 354297b8..c27d55ca 100644 --- a/src/gui/Src/Gui/CPURegistersView.cpp +++ b/src/gui/Src/Gui/CPURegistersView.cpp @@ -18,6 +18,7 @@ CPURegistersView::CPURegistersView(CPUWidget* parent) : RegistersView(parent), m wCM_Modify->setShortcut(QKeySequence(Qt::Key_Enter)); wCM_ToggleValue = setupAction(DIcon("register_toggle.png"), tr("Toggle")); wCM_Undo = setupAction(DIcon("undo.png"), tr("Undo")); + wCM_CopyPrevious = setupAction(DIcon("undo.png"), ""); wCM_FollowInDisassembly = new QAction(DIcon(QString("processor%1.png").arg(ArchValue("32", "64"))), tr("Follow in Disassembler"), this); wCM_FollowInDump = new QAction(DIcon("dump.png"), tr("Follow in Dump"), this); wCM_FollowInStack = new QAction(DIcon("stack.png"), tr("Follow in Stack"), this); @@ -37,6 +38,7 @@ CPURegistersView::CPURegistersView(CPUWidget* parent) : RegistersView(parent), m connect(wCM_Modify, SIGNAL(triggered()), this, SLOT(onModifyAction())); connect(wCM_ToggleValue, SIGNAL(triggered()), this, SLOT(onToggleValueAction())); connect(wCM_Undo, SIGNAL(triggered()), this, SLOT(onUndoAction())); + connect(wCM_CopyPrevious, SIGNAL(triggered()), this, SLOT(onCopyPreviousAction())); connect(wCM_FollowInDisassembly, SIGNAL(triggered()), this, SLOT(onFollowInDisassembly())); connect(wCM_FollowInDump, SIGNAL(triggered()), this, SLOT(onFollowInDump())); connect(wCM_FollowInStack, SIGNAL(triggered()), this, SLOT(onFollowInStack())); @@ -441,6 +443,11 @@ void CPURegistersView::onUndoAction() } } +void CPURegistersView::onCopyPreviousAction() +{ + Bridge::CopyToClipboard(wCM_CopyPrevious->data().toString()); +} + void CPURegistersView::onHighlightSlot() { Disassembly* CPUDisassemblyView = mParent->getDisasmWidget(); @@ -580,6 +587,9 @@ void CPURegistersView::displayCustomContextMenuSlot(QPoint pos) if(mUNDODISPLAY.contains(mSelected) && CompareRegisters(mSelected, &wRegDumpStruct, &wCipRegDumpStruct) != 0) { wMenu.addAction(wCM_Undo); + wCM_CopyPrevious->setData(GetRegStringValueFromValue(mSelected, registerValue(&wCipRegDumpStruct, mSelected))); + wCM_CopyPrevious->setText(tr("Copy old value: %1").arg(wCM_CopyPrevious->data().toString())); + wMenu.addAction(wCM_CopyPrevious); } if(mBOOLDISPLAY.contains(mSelected)) diff --git a/src/gui/Src/Gui/CPURegistersView.h b/src/gui/Src/Gui/CPURegistersView.h index ca6d77a7..904d42f2 100644 --- a/src/gui/Src/Gui/CPURegistersView.h +++ b/src/gui/Src/Gui/CPURegistersView.h @@ -24,6 +24,7 @@ protected slots: void onModifyAction(); void onToggleValueAction(); void onUndoAction(); + void onCopyPreviousAction(); void onFollowInDisassembly(); void onFollowInDump(); void onFollowInDumpN(); @@ -43,6 +44,7 @@ private: QAction* mFollowInDump; QAction* wCM_Modify; QAction* wCM_ToggleValue; + QAction* wCM_CopyPrevious; QAction* wCM_Undo; QAction* wCM_FollowInDisassembly; QAction* wCM_FollowInDump; diff --git a/src/gui/Src/Gui/EditBreakpointDialog.ui b/src/gui/Src/Gui/EditBreakpointDialog.ui index 362be4b2..70e6cca1 100644 --- a/src/gui/Src/Gui/EditBreakpointDialog.ui +++ b/src/gui/Src/Gui/EditBreakpointDialog.ui @@ -42,6 +42,9 @@ + + <html><head/><body><p>This text will be logged whenever the log condition is true.</p><p>String formatting can be used to print variables.</p></body></html> + &Log Text: @@ -52,6 +55,9 @@ + + <html><head/><body><p>If this expression is evaluated to 1 the breakpoint will break.</p><p>Set to <span style=" text-decoration: underline;">0</span> for a breakpoint that never breaks, but can still do logging and execute command.</p></body></html> + &Break Condition: @@ -90,6 +96,9 @@ + + <html><head/><body><p>String logging is enabled whenever this expression is evaluated to 1.</p></body></html> + Lo&g Condition: @@ -110,6 +119,9 @@ + + <html><head/><body><p>This command will be executed whenever command condition is true.</p><p>Currently certain commands, for example, stepping from breakpoint command are not supported.</p></body></html> + &Command Text: @@ -137,6 +149,9 @@ + + <html><head/><body><p>The number of times the breakpoint is hit.</p></body></html> + &Hit Count: @@ -147,6 +162,9 @@ + + <html><head/><body><p>If this expression is evaluated to 1 the command specified above is executed when the breakpoint is hit.</p><p>Set the expression to <span style=" text-decoration: underline;">1</span> to always execute the command.</p></body></html> + C&ommand Condition: @@ -181,6 +199,9 @@ + + <html><head/><body><p>Remove the breakpoint once it pauses the debuggee.</p></body></html> + Singlesho&ot @@ -188,6 +209,9 @@ + + <html><head/><body><p>Don't print the default breakpoint log.</p></body></html> + &Silent @@ -195,6 +219,9 @@ + + <html><head/><body><p>Don't enable extended conditional breakpoint features and plugins.</p></body></html> + &Fast Resume diff --git a/src/gui/Src/Gui/EditFloatRegister.cpp b/src/gui/Src/Gui/EditFloatRegister.cpp index 8fa11f27..454a28d6 100644 --- a/src/gui/Src/Gui/EditFloatRegister.cpp +++ b/src/gui/Src/Gui/EditFloatRegister.cpp @@ -58,6 +58,21 @@ EditFloatRegister::EditFloatRegister(int RegisterSize, QWidget* parent) : ui->hexEdit->setValidator(&hexValidate); connect(ui->hexEdit_2, SIGNAL(textEdited(QString)), this, SLOT(editingHex2FinishedSlot(QString))); ui->hexEdit_2->setValidator(&hexValidate); + QRadioButton* checkedRadio; + switch(ConfigUint("Gui", "EditFloatRegisterDefaultMode")) + { + case 0: + default: + checkedRadio = ui->radioHex; + break; + case 1: + checkedRadio = ui->radioSigned; + break; + case 2: + checkedRadio = ui->radioUnsigned; + break; + } + checkedRadio->setChecked(true); editingModeChangedSlot(false); connect(ui->radioHex, SIGNAL(toggled(bool)), this, SLOT(editingModeChangedSlot(bool))); connect(ui->radioSigned, SIGNAL(toggled(bool)), this, SLOT(editingModeChangedSlot(bool))); @@ -473,6 +488,7 @@ void EditFloatRegister::editingModeChangedSlot(bool arg) ui->longLongEdit0_2->setValidator(&hexValidate); ui->longLongEdit1_2->setValidator(&hexValidate); } + Config()->setUint("Gui", "EditFloatRegisterDefaultMode", 0); } else if(ui->radioSigned->isChecked()) { @@ -532,6 +548,7 @@ void EditFloatRegister::editingModeChangedSlot(bool arg) ui->longLongEdit1->setValidator(&signedLongLongValidator); ui->longLongEdit0_2->setValidator(&signedLongLongValidator); ui->longLongEdit1_2->setValidator(&signedLongLongValidator); + Config()->setUint("Gui", "EditFloatRegisterDefaultMode", 1); } else { @@ -587,6 +604,7 @@ void EditFloatRegister::editingModeChangedSlot(bool arg) ui->longLongEdit1->setValidator(&unsignedLongLongValidator); ui->longLongEdit0_2->setValidator(&unsignedLongLongValidator); ui->longLongEdit1_2->setValidator(&unsignedLongLongValidator); + Config()->setUint("Gui", "EditFloatRegisterDefaultMode", 2); } reloadDataLow(); if(RegSize > 128) diff --git a/src/gui/Src/Gui/HexEditDialog.cpp b/src/gui/Src/Gui/HexEditDialog.cpp index 63d98c93..749c2de1 100644 --- a/src/gui/Src/Gui/HexEditDialog.cpp +++ b/src/gui/Src/Gui/HexEditDialog.cpp @@ -25,7 +25,7 @@ HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexE //setup text fields ui->lineEditAscii->setEncoding(QTextCodec::codecForName("System")); ui->lineEditUnicode->setEncoding(QTextCodec::codecForName("UTF-16")); - + ui->chkKeepSize->setChecked(ConfigBool("HexDump", "KeepSize")); ui->chkEntireBlock->hide(); mDataInitialized = false; @@ -86,7 +86,9 @@ HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexE for(int i = 0; i < DataLast; i++) ui->listType->addItem(mTypes[i].name); - QModelIndex index = ui->listType->model()->index(DataCByte, 0); + duint lastDataType = ConfigUint("HexDump", "CopyDataType"); + lastDataType = std::min(lastDataType, static_cast(ui->listType->count() - 1)); + QModelIndex index = ui->listType->model()->index(lastDataType, 0); ui->listType->setCurrentIndex(index); Config()->setupWindowPos(this); @@ -162,10 +164,13 @@ void HexEditDialog::updateStyle() void HexEditDialog::on_chkKeepSize_toggled(bool checked) { + if(!this->isVisible()) + return; mHexEdit->setKeepSize(checked); ui->lineEditAscii->setKeepSize(checked); ui->lineEditUnicode->setKeepSize(checked); ui->lineEditCodepage->setKeepSize(checked); + Config()->setBool("HexDump", "KeepSize", checked); } void HexEditDialog::dataChangedSlot() @@ -818,6 +823,7 @@ void HexEditDialog::on_listType_currentRowChanged(int currentRow) mIndex = currentRow; ui->spinBox->setValue(mTypes[mIndex].itemsPerLine); printData(DataType(mIndex)); + Config()->setUint("HexDump", "CopyDataType", currentRow); } void HexEditDialog::on_buttonCopy_clicked() diff --git a/src/gui/Src/Gui/PatchDialog.cpp b/src/gui/Src/Gui/PatchDialog.cpp index 9623bed5..bf16ccff 100644 --- a/src/gui/Src/Gui/PatchDialog.cpp +++ b/src/gui/Src/Gui/PatchDialog.cpp @@ -505,6 +505,9 @@ void PatchDialog::on_btnImport_clicked() QList> patchList; DBGPATCHINFO curPatch; + if(!filenamelist.size()) + return; // No files are selected, don't show the "No patches to apply in the current process." dialog. + for(const auto & filename1 : filenamelist) { if(!filename1.length()) diff --git a/src/gui/Src/Utils/Configuration.cpp b/src/gui/Src/Utils/Configuration.cpp index 65b34fb1..007bce93 100644 --- a/src/gui/Src/Utils/Configuration.cpp +++ b/src/gui/Src/Utils/Configuration.cpp @@ -328,6 +328,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false) AbstractTableView::setupColumnConfigDefaultValue(guiUint, "SourceView", 4); AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Trace", 7); guiUint.insert("SIMDRegistersDisplayMode", 0); + guiUint.insert("EditFloatRegisterDefaultMode", 0); addWindowPosConfig(guiUint, "AssembleDialog"); addWindowPosConfig(guiUint, "AttachDialog"); addWindowPosConfig(guiUint, "GotoDialog"); @@ -342,7 +343,11 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false) //uint settings QMap hexdumpUint; hexdumpUint.insert("DefaultView", 0); + hexdumpUint.insert("CopyDataType", 0); defaultUints.insert("HexDump", hexdumpUint); + QMap hexdumpBool; + hexdumpBool.insert("KeepSize", false); + defaultBools.insert("HexDump", hexdumpBool); QMap disasmUint; disasmUint.insert("MaxModuleSize", -1);