Skip to content

Commit

Permalink
Show available flags and comments in hexdump (rizinorg#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhavalpur0hit committed Mar 23, 2020
1 parent 5fb7fa5 commit 9990b00
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/widgets/HexdumpWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
ui->bytesCRC32->setPlaceholderText(placeholder);
ui->hexDisasTextEdit->setPlaceholderText(placeholder);

// Set placeholders for the flag and comment components
QString placeholder_2 = tr("Select address to display information");
ui->addressFlag->setPlaceholderText(placeholder_2);
ui->addressComment->setPlaceholderText(placeholder_2);

setupFonts();

ui->openSideViewB->setStyleSheet(""
Expand Down Expand Up @@ -97,6 +102,7 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
seekable->seek(addr);
sent_seek = false;
}
showMetaInfo(addr);
});
connect(ui->hexTextView, &HexWidget::selectionChanged, this, &HexdumpWidget::selectionChanged);
connect(ui->hexSideTab_2, &QTabWidget::currentChanged, this, &HexdumpWidget::refreshSelectionInfo);
Expand Down Expand Up @@ -289,6 +295,28 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
}
}

void HexdumpWidget::showMetaInfo(RVA address) {
QString flagName = "";

RCore *core = Core()->core();
RFlagItem *f = r_flag_get_i (core->flags, address);

if (f) {
// Check if Realname is enabled. If yes, show it instead of the full flag-name.
if (Config()->getConfigBool("asm.flags.real") && f->realname) {
flagName = f->realname;
} else {
flagName = f->name;
}
}

// Fill the information for flag and comment
ui->addressFlag->setText(flagName.trimmed());
ui->addressComment->setText(Core()->cmd("CC." + RAddressString(address).trimmed()));
ui->addressFlag->setCursorPosition(0);
ui->addressComment->setCursorPosition(0);
}

void HexdumpWidget::on_parseTypeComboBox_currentTextChanged(const QString &)
{
if (ui->parseTypeComboBox->currentIndex() == 0) {
Expand Down
1 change: 1 addition & 0 deletions src/widgets/HexdumpWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public slots:
void setupFonts();

void refreshSelectionInfo();
void showMetaInfo(RVA address);
void updateParseWindow(RVA start_address, int size);
void clearParseWindow();
void showSidePanel(bool show);
Expand Down
64 changes: 64 additions & 0 deletions src/widgets/HexdumpWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,70 @@
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLineEdit" name="addressFlag">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelFlag">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Flag:</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="QLineEdit" name="addressComment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelComment">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Comment:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="bytesSHA1">
<property name="sizePolicy">
Expand Down

0 comments on commit 9990b00

Please sign in to comment.