-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathaddressindicator.h
More file actions
90 lines (69 loc) · 1.77 KB
/
Copy pathaddressindicator.h
File metadata and controls
90 lines (69 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
#include <QtWidgets/QLabel>
#include "viewframe.h"
#include "menus.h"
#include "uicontext.h"
/*!
\defgroup addressindicator AddressIndicator
\ingroup uiapi
*/
/*! Format for displaying offsets
\ingroup addressindicator
*/
enum class OffsetFormat : char
{
VirtualAddress,
FileStart,
SegmentStart,
SectionStart,
FunctionStart
};
/*! Format for displaying an address range
\ingroup addressindicator
*/
enum class RangeFormat : char
{
StartOnly,
EndOnly,
StartAndLength,
StartAndEnd
};
/*! Options for displaying an address or address range
\ingroup addressindicator
*/
struct DisplayOptions
{
OffsetFormat format = OffsetFormat::VirtualAddress;
RangeFormat rangeFormat = RangeFormat::StartAndEnd;
};
/*!
\ingroup addressindicator
*/
class BINARYNINJAUIAPI AddressIndicator : public MenuHelper
{
Q_OBJECT
uint64_t m_begin, m_end;
BinaryViewRef m_view;
DisplayOptions m_options{};
const DisplayOptions m_defaultOptions{};
//! 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 addCopyAction(QMenu*, RangeFormat, OffsetFormat, QString help = "");
//! Create a QAction to set the display format.
void addDisplayAction(QMenu*, RangeFormat, OffsetFormat, QString help = "");
//! Refresh the text displayed in the status bar.
void updateDisplay();
public:
AddressIndicator(QWidget* parent);
void clear();
void setOffsets(uint64_t begin, uint64_t end, BinaryViewRef view);
protected:
virtual void showMenu();
};