From ae60aab3fc9202f761901cdce4196261dcbb3527 Mon Sep 17 00:00:00 2001 From: Jon Palmisciano Date: Fri, 13 May 2022 12:21:36 -0400 Subject: Improve address indicator UI/UX --- ui/addressindicator.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/ui/addressindicator.h b/ui/addressindicator.h index 3288de35..4d7d8cf1 100644 --- a/ui/addressindicator.h +++ b/ui/addressindicator.h @@ -5,6 +5,31 @@ #include "menus.h" #include "uicontext.h" +//! Format for displaying offsets. +enum class OffsetFormat +{ + VirtualAddress, + FileStart, + SegmentStart, + SectionStart, + FunctionStart +}; + +//! Format for displaying an address range. +enum class RangeFormat +{ + StartOnly, + EndOnly, + StartAndLength, + StartAndEnd +}; + +//! Options for displaying an address or address range. +struct DisplayOptions +{ + OffsetFormat format = OffsetFormat::VirtualAddress; + RangeFormat rangeFormat = RangeFormat::StartAndEnd; +}; class BINARYNINJAUIAPI AddressIndicator : public MenuHelper { @@ -13,7 +38,25 @@ class BINARYNINJAUIAPI AddressIndicator : public MenuHelper uint64_t m_begin, m_end; BinaryViewRef m_view; - public: + DisplayOptions m_options; + + //! Format an offset as a string. + //! + //! \returns An empty string in case of failure. + QString formatOffset(uint64_t, OffsetFormat) const; + + //! Format an address range as a string. + //! + //! \returns An empty string in case of failure. + QString formatRange(uint64_t start, uint64_t end, RangeFormat, OffsetFormat) const; + + //! Create a QAction to copy a formatted offset/range. + void addActionForFormat(QMenu*, RangeFormat, OffsetFormat, QString help = ""); + + //! Refresh the text displayed in the status bar. + void updateDisplay(); + +public: AddressIndicator(QWidget* parent); void clear(); -- cgit v1.3.1