1
0
Fork 0

GUI: resolved issue #407 (copy address + rva in dump and disasm)

This commit is contained in:
Mr. eXoDia 2015-10-15 17:38:50 +02:00
parent 0195c20936
commit cb173d28a1
4 changed files with 62 additions and 0 deletions

View File

@ -519,12 +519,16 @@ void CPUDisassembly::setupRightClickContextMenu()
this->addAction(mCopyAddress);
connect(mCopyAddress, SIGNAL(triggered()), this, SLOT(copyAddress()));
mCopyRva = new QAction("&RVA", this);
connect(mCopyRva, SIGNAL(triggered()), this, SLOT(copyRva()));
mCopyDisassembly = new QAction("Disassembly", this);
connect(mCopyDisassembly, SIGNAL(triggered()), this, SLOT(copyDisassembly()));
mCopyMenu->addAction(mCopySelection);
mCopyMenu->addAction(mCopySelectionNoBytes);
mCopyMenu->addAction(mCopyAddress);
mCopyMenu->addAction(mCopyRva);
mCopyMenu->addAction(mCopyDisassembly);
// Open Source file
@ -1318,6 +1322,19 @@ void CPUDisassembly::copyAddress()
Bridge::CopyToClipboard(addrText);
}
void CPUDisassembly::copyRva()
{
uint_t addr = rvaToVa(getInitialSelection());
uint_t base = DbgFunctions()->ModBaseFromAddr(addr);
if(base)
{
QString addrText = QString("%1").arg(addr - base, 0, 16, QChar('0')).toUpper();
Bridge::CopyToClipboard(addrText);
}
else
QMessageBox::warning(this, "Error!", "Selection not in a module...");
}
void CPUDisassembly::copyDisassembly()
{
QList<Instruction_t> instBuffer;

View File

@ -73,6 +73,7 @@ public slots:
void copySelection();
void copySelectionNoBytes();
void copyAddress();
void copyRva();
void copyDisassembly();
void findCommand();
void openSource();
@ -130,6 +131,7 @@ private:
QAction* mCopySelection;
QAction* mCopySelectionNoBytes;
QAction* mCopyAddress;
QAction* mCopyRva;
QAction* mCopyDisassembly;
QAction* mOpenSource;

View File

@ -90,6 +90,7 @@ void CPUDump::setupContextMenu()
{
//Binary menu
mBinaryMenu = new QMenu("B&inary", this);
mBinaryMenu->setIcon(QIcon(":/icons/images/binary.png"));
//Binary->Edit
mBinaryEditAction = new QAction("&Edit", this);
@ -401,6 +402,22 @@ void CPUDump::setupContextMenu()
mPluginMenu = new QMenu(this);
Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_DUMP_MENU);
//Copy
mCopyMenu = new QMenu("&Copy", this);
mCopyMenu->setIcon(QIcon(":/icons/images/copy.png"));
// Copy -> Address
mCopyAddress = new QAction("&Address", this);
connect(mCopyAddress, SIGNAL(triggered()), this, SLOT(copyAddressSlot()));
mCopyAddress->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mCopyAddress);
mCopyMenu->addAction(mCopyAddress);
// Copy -> RVA
mCopyRva = new QAction("&RVA", this);
connect(mCopyRva, SIGNAL(triggered()), this, SLOT(copyRvaSlot()));
mCopyMenu->addAction(mCopyRva);
refreshShortcutsSlot();
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
}
@ -421,6 +438,7 @@ void CPUDump::refreshShortcutsSlot()
mGotoEnd->setShortcut(ConfigShortcut("ActionGotoEnd"));
mGotoFileOffset->setShortcut(ConfigShortcut("ActionGotoFileOffset"));
mYaraAction->setShortcut(ConfigShortcut("ActionYara"));
mCopyAddress->setShortcut(ConfigShortcut("ActionCopyAddress"));
}
QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h)
@ -518,6 +536,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addMenu(mBinaryMenu);
wMenu->addMenu(mCopyMenu);
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
@ -1468,3 +1487,22 @@ void CPUDump::entropySlot()
entropyDialog.GraphMemory(data.constData(), data.size());
entropyDialog.exec();
}
void CPUDump::copyAddressSlot()
{
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
Bridge::CopyToClipboard(addrText);
}
void CPUDump::copyRvaSlot()
{
uint_t addr = rvaToVa(getInitialSelection());
uint_t base = DbgFunctions()->ModBaseFromAddr(addr);
if(base)
{
QString addrText = QString("%1").arg(addr - base, 0, 16, QChar('0')).toUpper();
Bridge::CopyToClipboard(addrText);
}
else
QMessageBox::warning(this, "Error!", "Selection not in a module...");
}

View File

@ -87,6 +87,8 @@ public slots:
void yaraSlot();
void dataCopySlot();
void entropySlot();
void copyAddressSlot();
void copyRvaSlot();
private:
QMenu* mBreakpointMenu;
@ -177,10 +179,13 @@ private:
QAction* mFollowData;
QAction* mFollowDataDump;
QAction* mEntropy;
QAction* mCopyAddress;
QAction* mCopyRva;
QMenu* mSpecialMenu;
QMenu* mCustomMenu;
QMenu* mPluginMenu;
QMenu* mCopyMenu;
GotoDialog* mGoto;
CPUDisassembly* mDisas;