Skip to content

Commit 63ed769

Browse files
committed
GUI: changed text of InfoBox + added copy address + rva + offset to info box
1 parent 339a27a commit 63ed769

File tree

6 files changed

+71
-12
lines changed

6 files changed

+71
-12
lines changed

src/gui/Src/BasicView/Disassembly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ QString Disassembly::getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE])
15201520
#endif //_WIN64
15211521
}
15221522
}
1523-
addrText += AddressToString(cur_addr);
1523+
addrText += ToPtrString(cur_addr);
15241524
char label_[MAX_LABEL_SIZE] = "";
15251525
if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label_)) //has label
15261526
{

src/gui/Src/BasicView/StdTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ void StdTable::setupCopyMenu(QMenu* copyMenu)
388388
QAction* mCopyTable = new QAction("Whole &Table", this);
389389
connect(mCopyTable, SIGNAL(triggered()), this, SLOT(copyTableSlot()));
390390
copyMenu->addAction(mCopyTable);
391-
//Copy->Separatoe
391+
//Copy->Separator
392392
copyMenu->addSeparator();
393393
//Copy->ColName
394394
for(int i = 0; i < getColumnCount(); i++)

src/gui/Src/Gui/CPUInfoBox.cpp

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ CPUInfoBox::CPUInfoBox(StdTable* parent) : StdTable(parent)
2424

2525
// Deselect any row (visual reasons only)
2626
setSingleSelection(-1);
27+
28+
setupContextMenu();
29+
}
30+
31+
void CPUInfoBox::setupContextMenu()
32+
{
33+
mCopyAddressAction = makeAction("Address", SLOT(copyAddress()));
34+
mCopyRvaAction = makeAction("RVA", SLOT(copyRva()));
35+
mCopyOffsetAction = makeAction("File Offset", SLOT(copyOffset()));
2736
}
2837

2938
int CPUInfoBox::getHeight()
@@ -97,6 +106,9 @@ QString CPUInfoBox::getSymbolicName(dsint addr)
97106
void CPUInfoBox::disasmSelectionChanged(dsint parVA)
98107
{
99108
curAddr = parVA;
109+
curRva = -1;
110+
curOffset = -1;
111+
100112
if(!DbgIsDebugging() || !DbgMemIsValidReadPtr(parVA))
101113
return;
102114

@@ -182,7 +194,7 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
182194

183195
// Set last line
184196
//
185-
// Format: SECTION:VA MODULE+RVA FILE_OFFSET FUNCTION
197+
// Format: SECTION:VA MODULE:$RVA :#FILE_OFFSET FUNCTION
186198
QString info;
187199

188200
// Section
@@ -191,7 +203,7 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
191203
info += QString(section) + ":";
192204

193205
// VA
194-
info += AddressToString(parVA) + " ";
206+
info += ToPtrString(parVA) + " ";
195207

196208
// Module name, RVA, and file offset
197209
char mod[MAX_MODULE_SIZE];
@@ -202,14 +214,14 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
202214
// Append modname
203215
info += mod;
204216

217+
// Module RVA
218+
curRva = parVA - modbase;
205219
if(modbase)
206-
info += ":" + QString("%1").arg(parVA - modbase, 0, 16, QChar('0')).toUpper();
207-
208-
// Append space afterwards
209-
info += " ";
220+
info += QString(":$%1 ").arg(curRva, 0, 16, QChar('0')).toUpper();
210221

211222
// File offset
212-
info += QString("%1").arg(DbgFunctions()->VaToFileOffset(parVA), 0, 16, QChar('0')).toUpper() + " ";
223+
curOffset = DbgFunctions()->VaToFileOffset(parVA);
224+
info += QString("#%1 ").arg(curOffset, 0, 16, QChar('0')).toUpper() + " ";
213225
}
214226

215227
// Function/label name
@@ -248,7 +260,7 @@ void CPUInfoBox::addFollowMenuItem(QMenu* menu, QString name, dsint value)
248260
void CPUInfoBox::setupFollowMenu(QMenu* menu, dsint wVA)
249261
{
250262
//most basic follow action
251-
addFollowMenuItem(menu, "&Selection", wVA);
263+
addFollowMenuItem(menu, "&Selected Address", wVA);
252264

253265
//add follow actions
254266
DISASM_INSTR instr;
@@ -286,10 +298,33 @@ void CPUInfoBox::contextMenuSlot(QPoint pos)
286298
wMenu->addMenu(wFollowMenu);
287299
QMenu wCopyMenu("&Copy", this);
288300
setupCopyMenu(&wCopyMenu);
301+
if(DbgIsDebugging())
302+
{
303+
wCopyMenu.addAction(mCopyAddressAction);
304+
if(curRva != -1)
305+
wCopyMenu.addAction(mCopyRvaAction);
306+
if(curOffset != -1)
307+
wCopyMenu.addAction(mCopyOffsetAction);
308+
}
289309
if(wCopyMenu.actions().length())
290310
{
291311
wMenu->addSeparator();
292312
wMenu->addMenu(&wCopyMenu);
293313
}
294314
wMenu->exec(mapToGlobal(pos)); //execute context menu
295315
}
316+
317+
void CPUInfoBox::copyAddress()
318+
{
319+
Bridge::CopyToClipboard(ToPtrString(curAddr));
320+
}
321+
322+
void CPUInfoBox::copyRva()
323+
{
324+
Bridge::CopyToClipboard(ToHexString(curRva));
325+
}
326+
327+
void CPUInfoBox::copyOffset()
328+
{
329+
Bridge::CopyToClipboard(ToHexString(curOffset));
330+
}

src/gui/Src/Gui/CPUInfoBox.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define INFOBOX_H
33

44
#include "StdTable.h"
5+
#include <QAction>
56

67
class CPUInfoBox : public StdTable
78
{
@@ -17,13 +18,23 @@ public slots:
1718
void dbgStateChanged(DBGSTATE state);
1819
void contextMenuSlot(QPoint pos);
1920
void followActionSlot();
21+
void copyAddress();
22+
void copyRva();
23+
void copyOffset();
2024

2125
private:
2226
dsint curAddr;
27+
dsint curRva;
28+
dsint curOffset;
2329
QString getSymbolicName(dsint addr);
2430
void setInfoLine(int line, QString text);
2531
QString getInfoLine(int line);
2632
void clear();
33+
void setupContextMenu();
34+
35+
QAction* mCopyAddressAction;
36+
QAction* mCopyRvaAction;
37+
QAction* mCopyOffsetAction;
2738
};
2839

2940
#endif // INFOBOX_H

src/gui/Src/Gui/CPUStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ QString CPUStack::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
223223
#endif //_WIN64
224224
}
225225
}
226-
addrText += AddressToString(cur_addr);
226+
addrText += ToPtrString(cur_addr);
227227
if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label
228228
{
229229
char module[MAX_MODULE_SIZE] = "";

src/gui/Src/Utils/StringUtil.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <QString>
55
#include "Imports.h"
66

7-
static QString AddressToString(dsint Address)
7+
static QString ToPtrString(duint Address)
88
{
99
//
1010
// This function exists because of how QT handles
@@ -24,4 +24,17 @@ static QString AddressToString(dsint Address)
2424
return QString(temp);
2525
}
2626

27+
static QString ToHexString(duint Address)
28+
{
29+
char temp[32];
30+
31+
#ifdef _WIN64
32+
sprintf_s(temp, "%llX", Address);
33+
#else
34+
sprintf_s(temp, "%X", Address);
35+
#endif // _WIN64
36+
37+
return QString(temp);
38+
}
39+
2740
#endif // STRINGUTIL_H

0 commit comments

Comments
 (0)