Skip to content

Commit 0bccbd0

Browse files
committed
GUI: resolved issue x64dbg#229 (automatic comments have a different color)
1 parent 842469e commit 0bccbd0

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,28 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
380380
char comment[MAX_COMMENT_SIZE] = "";
381381
if(DbgGetCommentAt(rvaToVa(mInstBuffer.at(rowOffset).rva), comment))
382382
{
383-
painter->setPen(ConfigColor("DisassemblyCommentColor"));
384-
int width = getCharWidth() * QString(comment).length() + 4;
383+
QString commentText;
384+
QColor penColor;
385+
QColor backgroundColor;
386+
if(comment[0] == '\1') //automatic comment
387+
{
388+
penColor = ConfigColor("DisassemblyAutoCommentColor");
389+
backgroundColor = ConfigColor("DisassemblyAutoCommentBackgroundColor");
390+
commentText = QString(comment + 1);
391+
}
392+
else //user comment
393+
{
394+
penColor = ConfigColor("DisassemblyCommentColor");
395+
backgroundColor = ConfigColor("DisassemblyCommentBackgroundColor");
396+
commentText = comment;
397+
}
398+
painter->setPen(penColor);
399+
int width = getCharWidth() * commentText.length() + 4;
385400
if(width > w)
386401
width = w;
387402
if(width)
388-
painter->fillRect(QRect(x + 2, y, width, h), QBrush(ConfigColor("DisassemblyCommentBackgroundColor"))); //fill bookmark color
389-
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, QString(comment));
403+
painter->fillRect(QRect(x + 2, y, width, h), QBrush(backgroundColor)); //fill comment color
404+
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, commentText);
390405
}
391406
}
392407
break;

x64_dbg_gui/Project/Src/Gui/AppearanceDialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ void AppearanceDialog::colorInfoListInit()
428428
colorInfoListAppend("Hardware Breakpoints", "DisassemblyHardwareBreakpointColor", "DisassemblyHardwareBreakpointBackgroundColor");
429429
colorInfoListAppend("Bookmarks", "DisassemblyBookmarkColor", "DisassemblyBookmarkBackgroundColor");
430430
colorInfoListAppend("Comments", "DisassemblyCommentColor", "DisassemblyCommentBackgroundColor");
431+
colorInfoListAppend("Automatic Comments", "DisassemblyAutoCommentColor", "DisassemblyAutoCommentBackgroundColor");
431432
colorInfoListAppend("Labels", "DisassemblyLabelColor", "DisassemblyLabelBackgroundColor");
432433
colorInfoListAppend("Addresses", "DisassemblyAddressColor", "DisassemblyAddressBackgroundColor");
433434
colorInfoListAppend("Selected Addresses", "DisassemblySelectedAddressColor", "DisassemblySelectedAddressBackgroundColor");

x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ void BreakpointsView::reloadData()
9797

9898
char comment[MAX_COMMENT_SIZE] = "";
9999
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
100-
mHardBPTable->setCellContent(wI, 4, comment);
100+
{
101+
if(comment[0] == '\1') //automatic comment
102+
mHardBPTable->setCellContent(wI, 4, QString(comment + 1));
103+
else
104+
mHardBPTable->setCellContent(wI, 4, comment);
105+
}
101106
}
102107
mHardBPTable->reloadData();
103108
if(wBPList.count)
@@ -129,7 +134,12 @@ void BreakpointsView::reloadData()
129134

130135
char comment[MAX_COMMENT_SIZE] = "";
131136
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
132-
mSoftBPTable->setCellContent(wI, 4, comment);
137+
{
138+
if(comment[0] == '\1') //automatic comment
139+
mSoftBPTable->setCellContent(wI, 4, QString(comment + 1));
140+
else
141+
mSoftBPTable->setCellContent(wI, 4, comment);
142+
}
133143
}
134144
mSoftBPTable->reloadData();
135145
if(wBPList.count)
@@ -161,7 +171,12 @@ void BreakpointsView::reloadData()
161171

162172
char comment[MAX_COMMENT_SIZE] = "";
163173
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
164-
mMemBPTable->setCellContent(wI, 4, comment);
174+
{
175+
if(comment[0] == '\1') //automatic comment
176+
mMemBPTable->setCellContent(wI, 4, QString(comment + 1));
177+
else
178+
mMemBPTable->setCellContent(wI, 4, comment);
179+
}
165180
}
166181
mMemBPTable->reloadData();
167182
if(wBPList.count)

x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,12 @@ void CPUDisassembly::setComment()
708708
QString addr_text = QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
709709
char comment_text[MAX_COMMENT_SIZE] = "";
710710
if(DbgGetCommentAt((duint)wVA, comment_text))
711-
mLineEdit.setText(QString(comment_text));
711+
{
712+
if(comment_text[0] == '\1') //automatic comment
713+
mLineEdit.setText(QString(comment_text + 1));
714+
else
715+
mLineEdit.setText(QString(comment_text));
716+
}
712717
mLineEdit.setWindowTitle("Add comment at " + addr_text);
713718
if(mLineEdit.exec() != QDialog::Accepted)
714719
return;
@@ -1160,7 +1165,12 @@ void CPUDisassembly::copySelection(bool copyBytes)
11601165
char comment[MAX_COMMENT_SIZE] = "";
11611166
QString fullComment;
11621167
if(DbgGetCommentAt(cur_addr, comment))
1163-
fullComment = " ;" + QString(comment);
1168+
{
1169+
if(comment[0] == '\1') //automatic comment
1170+
fullComment = " ;" + QString(comment + 1);
1171+
else
1172+
fullComment = " ;" + QString(comment);
1173+
}
11641174
clipboard += address.leftJustified(addressLen, QChar(' '), true);
11651175
if(copyBytes)
11661176
clipboard += " | " + bytes.leftJustified(bytesLen, QChar(' '), true);

x64_dbg_gui/Project/Src/Utils/Configuration.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Configuration::Configuration() : QObject()
3939
defaultColors.insert("DisassemblyModifiedBytesColor", QColor("#FF0000"));
4040
defaultColors.insert("DisassemblyCommentColor", QColor("#000000"));
4141
defaultColors.insert("DisassemblyCommentBackgroundColor", Qt::transparent);
42+
defaultColors.insert("DisassemblyAutoCommentColor", QColor("#808080"));
43+
defaultColors.insert("DisassemblyAutoCommentBackgroundColor", Qt::transparent);
4244

4345
defaultColors.insert("SideBarCipLabelColor", QColor("#FFFFFF"));
4446
defaultColors.insert("SideBarCipLabelBackgroundColor", QColor("#4040FF"));

0 commit comments

Comments
 (0)