From a500bfff86248be5812bd502326c2608b020ef28 Mon Sep 17 00:00:00 2001 From: Dhaval Purohit Date: Mon, 23 Mar 2020 12:08:33 +0100 Subject: [PATCH] Show available flags and comments in hexdump (#1471) --- src/widgets/HexdumpWidget.cpp | 29 ++++++++++++++++ src/widgets/HexdumpWidget.h | 1 + src/widgets/HexdumpWidget.ui | 64 +++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index f7a66082b..cc57080b7 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -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("" @@ -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); @@ -289,6 +295,29 @@ 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) { diff --git a/src/widgets/HexdumpWidget.h b/src/widgets/HexdumpWidget.h index f18c3e2cd..61ff1f1f9 100644 --- a/src/widgets/HexdumpWidget.h +++ b/src/widgets/HexdumpWidget.h @@ -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); diff --git a/src/widgets/HexdumpWidget.ui b/src/widgets/HexdumpWidget.ui index e2656a5f3..6d72110b1 100644 --- a/src/widgets/HexdumpWidget.ui +++ b/src/widgets/HexdumpWidget.ui @@ -490,6 +490,70 @@ + + + + + 0 + 0 + + + + true + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + Flag: + + + + + + + + 0 + 0 + + + + true + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + Comment: + + +