MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / SectionsWidget

Method SectionsWidget

examples/triage/sections.cpp:66–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65
66SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data) : QWidget(parent)
67{
68 QGridLayout* layout = new QGridLayout();
69 layout->setContentsMargins(0, 0, 0, 0);
70 layout->setVerticalSpacing(1);
71 layout->setHorizontalSpacing(UIContext::getScaledWindowSize(16, 16).width());
72
73 size_t maxNameLen = 0;
74 for (auto& section : data->GetSections())
75 if (section->GetName().size() > maxNameLen)
76 maxNameLen = section->GetName().size();
77 if (maxNameLen > 32)
78 maxNameLen = 32;
79
80 for (auto& section : data->GetSections())
81 if (section->GetSemantics() != ExternalSectionSemantics)
82 m_sections.push_back(section);
83 sort(m_sections.begin(), m_sections.end(),
84 [&](SectionRef a, SectionRef b) { return a->GetStart() < b->GetStart(); });
85
86 int row = 0;
87 for (auto& section : m_sections)
88 {
89 std::string name = section->GetName();
90 if (name.size() > maxNameLen)
91 name = name.substr(0, maxNameLen - 1) + std::string("…");
92
93 QString begin = QString("0x") + QString::number(section->GetStart(), 16);
94 QString end = QString("0x") + QString::number(section->GetStart() + section->GetLength(), 16);
95 QString typeName = QString::fromStdString(section->GetType());
96
97 QString permissions;
98 if (data->IsOffsetReadable(section->GetStart()))
99 permissions += "r";
100 else
101 permissions += "-";
102 if (data->IsOffsetWritable(section->GetStart()))
103 permissions += "w";
104 else
105 permissions += "-";
106 if (data->IsOffsetExecutable(section->GetStart()))
107 permissions += "x";
108 else
109 permissions += "-";
110
111 QString semantics;
112 if (section->GetSemantics() == ReadOnlyCodeSectionSemantics)
113 semantics = "Code";
114 else if (section->GetSemantics() == ReadOnlyDataSectionSemantics)
115 semantics = "Read-only Data";
116 else if (section->GetSemantics() == ReadWriteDataSectionSemantics)
117 semantics = "Writable Data";
118
119 QLabel* nameLabel = new QLabel(QString::fromStdString(name));
120 nameLabel->setFont(getMonospaceFont(this));
121 layout->addWidget(nameLabel, row, 0);
122
123 QHBoxLayout* rangeLayout = new QHBoxLayout();

Callers 1

__init__Method · 0.80

Calls 14

GetSectionsMethod · 0.80
GetSemanticsMethod · 0.80
push_backMethod · 0.80
IsOffsetReadableMethod · 0.80
IsOffsetWritableMethod · 0.80
IsOffsetExecutableMethod · 0.80
widthMethod · 0.45
sizeMethod · 0.45
GetNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetStartMethod · 0.45

Tested by

no test coverage detected