1
0
Fork 0

GUI: help on symbolic name + more icons in disasm menu

This commit is contained in:
mrexodia 2015-12-31 09:52:59 +01:00
parent 0f2aa94117
commit 4a192a1c9f
11 changed files with 79 additions and 29 deletions

1
.gitignore vendored
View File

@ -44,6 +44,7 @@ ui_*
help/x64*dbg.chm
help/output/
bin/x64*dbg.chm
bin/win32.*
# Debugger files to ignore
CppCheckResults.xml

View File

@ -1,6 +1,7 @@
#include "CPUDisassembly.h"
#include "CPUWidget.h"
#include <QMessageBox>
#include <QDesktopServices>
#include <QClipboard>
#include "Configuration.h"
#include "Bridge.h"
@ -281,7 +282,7 @@ void CPUDisassembly::setupRightClickContextMenu()
return true;
});
mMenuBuilder->addMenu(makeMenu("&Follow in Dump"), [this](QMenu * menu)
mMenuBuilder->addMenu(makeMenu(QIcon(":/icons/images/memory-map.png"), "&Follow in Dump"), [this](QMenu * menu)
{
setupFollowReferenceMenu(rvaToVa(getInitialSelection()), menu, false);
return true;
@ -301,6 +302,16 @@ void CPUDisassembly::setupRightClickContextMenu()
mMenuBuilder->addMenu(makeMenu(QIcon(":/icons/images/snowman.png"), "Decompile"), decompileMenu);
mMenuBuilder->addMenu(makeMenu(QIcon(":icons/images/help.png"), "Help on Symbolic Name"), [this](QMenu * menu)
{
QSet<QString> labels;
if(!getLabelsFromInstruction(rvaToVa(getInitialSelection()), labels))
return false;
for(auto label : labels)
menu->addAction(makeAction(label, SLOT(labelHelpSlot())));
return true;
});
mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/highlight.png"), "&Highlighting mode", SLOT(enableHighlightingModeSlot()), "ActionHighlightingMode"));
mMenuBuilder->addSeparator();
@ -332,12 +343,12 @@ void CPUDisassembly::setupRightClickContextMenu()
toggleFunctionAction->setText("Delete function");
return true;
});
mMenuBuilder->addAction(makeShortcutAction("Assemble", SLOT(assembleSlot()), "ActionAssemble"));
mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/compile.png"), "Assemble", SLOT(assembleSlot()), "ActionAssemble"));
removeAction(mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/patch.png"), "Patches", SLOT(showPatchesSlot()), "ViewPatches"))); //prevent conflicting shortcut with the MainWindow
mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/yara.png"), "&Yara...", SLOT(yaraSlot()), "ActionYara"));
mMenuBuilder->addSeparator();
mMenuBuilder->addAction(makeShortcutAction("Set New Origin Here", SLOT(setNewOriginHereActionSlot()), "ActionSetNewOriginHere"));
mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/neworigin.png"), "Set New Origin Here", SLOT(setNewOriginHereActionSlot()), "ActionSetNewOriginHere"));
MenuBuilder* gotoMenu = new MenuBuilder(this);
gotoMenu->addAction(makeShortcutAction("Origin", SLOT(gotoOriginSlot()), "ActionGotoOrigin"));
@ -357,7 +368,7 @@ void CPUDisassembly::setupRightClickContextMenu()
});
gotoMenu->addAction(makeShortcutAction("Start of Page", SLOT(gotoStartSlot()), "ActionGotoStart"));
gotoMenu->addAction(makeShortcutAction("End of Page", SLOT(gotoEndSlot()), "ActionGotoEnd"));
mMenuBuilder->addMenu(makeMenu("Go to"), gotoMenu);
mMenuBuilder->addMenu(makeMenu(QIcon(":/icons/images/goto.png"), "Go to"), gotoMenu);
mMenuBuilder->addSeparator();
MenuBuilder* searchMenu = new MenuBuilder(this);
@ -405,7 +416,7 @@ void CPUDisassembly::setupRightClickContextMenu()
mReferenceSelectedAddressAction = makeShortcutAction("&Selected Address(es)", SLOT(findReferencesSlot()), "ActionFindReferencesToSelectedAddress");
mReferenceSelectedAddressAction->setFont(QFont("Courier New", 8));
mMenuBuilder->addMenu(makeMenu("Find &references to"), [this](QMenu * menu)
mMenuBuilder->addMenu(makeMenu(QIcon(":/icons/images/find.png"), "Find &references to"), [this](QMenu * menu)
{
setupFollowReferenceMenu(rvaToVa(getInitialSelection()), menu, true);
return true;
@ -1260,3 +1271,49 @@ void CPUDisassembly::paintEvent(QPaintEvent* event)
// Signal to render the original content
Disassembly::paintEvent(event);
}
bool CPUDisassembly::getLabelsFromInstruction(duint addr, QSet<QString> & labels)
{
BASIC_INSTRUCTION_INFO basicinfo;
DbgDisasmFastAt(addr, &basicinfo);
std::vector<duint> values = { basicinfo.addr, basicinfo.value.value, basicinfo.memory.value};
for(auto value : values)
{
char label_[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(value, SEG_DEFAULT, label_))
{
//TODO: better cleanup of names
QString label(label_);
if(label.endsWith("A") || label.endsWith("W"))
label = label.left(label.length() - 1);
if(label.startsWith("&"))
label = label.right(label.length() - 1);
labels.insert(label);
}
}
return labels.size() != 0;
}
void CPUDisassembly::labelHelpSlot()
{
QString topic = ((QAction*)sender())->text();
char setting[MAX_SETTING_SIZE] = "";
if(!BridgeSettingGet("Misc", "HelpOnSymbolicNameUrl", setting))
{
//"execute://winhlp32.exe -k@topic ..\\win32.hlp";
strcpy_s(setting, "https://www.google.com/search?q=@topic");
BridgeSettingSet("Misc", "HelpOnSymbolicNameUrl", setting);
}
QString baseUrl(setting);
QString fullUrl = baseUrl.replace("@topic", topic);
if(fullUrl.startsWith("execute://"))
{
QString command = fullUrl.right(fullUrl.length() - 10);
QProcess::execute(command);
}
else
{
QDesktopServices::openUrl(QUrl(fullUrl));
}
}

View File

@ -84,11 +84,14 @@ public slots:
void decompileSelectionSlot();
void decompileFunctionSlot();
void displayWarningSlot(QString title, QString text);
void labelHelpSlot();
protected:
void paintEvent(QPaintEvent* event);
private:
bool getLabelsFromInstruction(duint addr, QSet<QString> & labels);
// Menus
QMenu* mHwSlotSelectMenu;
QMenu* mPluginMenu;
@ -110,7 +113,6 @@ private:
QAction* mFindStringsAll;
QAction* mFindCallsAll;
// Goto dialog specific
GotoDialog* mGoto;

View File

@ -477,29 +477,10 @@ void MainWindow::removeMRUEntry(QString entry)
void MainWindow::updateMRUMenu()
{
if(mMaxMRU < 1) return;
QMenu* fileMenu = this->menuBar()->findChild<QMenu*>(QString::fromWCharArray(L"menuFile"));
if(fileMenu == NULL)
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to find menu!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
if(mMaxMRU < 1)
return;
}
fileMenu = fileMenu->findChild<QMenu*>(QString::fromWCharArray(L"menuRecent_Files"));
if(fileMenu == NULL)
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to find submenu!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
return;
}
QMenu* fileMenu = ui->menuRecentFiles;
QList<QAction*> list = fileMenu->actions();
for(int i = 1; i < list.length(); ++i)
fileMenu->removeAction(list.at(i));

View File

@ -30,14 +30,18 @@
<property name="title">
<string>&amp;File</string>
</property>
<widget class="QMenu" name="menuRecent_Files">
<widget class="QMenu" name="menuRecentFiles">
<property name="title">
<string>&amp;Recent Files</string>
</property>
<property name="icon">
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/recentfiles.png</normaloff>:/icons/images/recentfiles.png</iconset>
</property>
<addaction name="separator"/>
</widget>
<addaction name="actionOpen"/>
<addaction name="menuRecent_Files"/>
<addaction name="menuRecentFiles"/>
<addaction name="actionAttach"/>
<addaction name="actionDetach"/>
<addaction name="separator"/>

BIN
src/gui/images/find.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

BIN
src/gui/images/goto.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

BIN
src/gui/images/help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

View File

@ -66,5 +66,10 @@
<file>images/notes.png</file>
<file>images/win-help.png</file>
<file>images/faq.png</file>
<file>images/help.png</file>
<file>images/goto.png</file>
<file>images/neworigin.png</file>
<file>images/find.png</file>
<file>images/recentfiles.png</file>
</qresource>
</RCC>