summaryrefslogtreecommitdiff
path: root/examples/triage
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2022-01-27 22:43:28 -0500
committerKyleMiles <krm504@nyu.edu>2022-01-28 00:24:06 -0500
commit6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch)
treedace4156d03148bcaf02df138ab4e0d93e61bc6f /examples/triage
parent519c9db22367f2659d1a54599fab47e6313be06e (diff)
Format All Files
Diffstat (limited to 'examples/triage')
-rw-r--r--examples/triage/byte.cpp127
-rw-r--r--examples/triage/byte.h12
-rw-r--r--examples/triage/entropy.cpp5
-rw-r--r--examples/triage/entropy.h10
-rw-r--r--examples/triage/exports.cpp10
-rw-r--r--examples/triage/exports.h16
-rw-r--r--examples/triage/fileinfo.cpp128
-rw-r--r--examples/triage/fileinfo.h18
-rw-r--r--examples/triage/files.cpp15
-rw-r--r--examples/triage/files.h12
-rw-r--r--examples/triage/headers.cpp67
-rw-r--r--examples/triage/headers.h32
-rw-r--r--examples/triage/imports.cpp8
-rw-r--r--examples/triage/imports.h16
-rw-r--r--examples/triage/sections.cpp24
-rw-r--r--examples/triage/sections.h8
-rw-r--r--examples/triage/triage.cpp13
-rw-r--r--examples/triage/view.cpp20
-rw-r--r--examples/triage/view.h12
19 files changed, 269 insertions, 284 deletions
diff --git a/examples/triage/byte.cpp b/examples/triage/byte.cpp
index be25368a..b6318d1e 100644
--- a/examples/triage/byte.cpp
+++ b/examples/triage/byte.cpp
@@ -5,28 +5,21 @@
#include "theme.h"
-static const char* g_byteMapping[] =
-{
- " ", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "◙", "♂", "♀", "♪", "♫", "☼",
- "▸", "◂", "↕", "‼", "¶", "§", "▬", "↨", "↑", "↓", "→", "←", "∟", "↔", "▴", "▾",
- " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
- "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
- "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_",
- "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
- "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "⌂",
- "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å",
- "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ",
- "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»",
- "░", "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐",
- "└", "┴", "┬", "├", "─", "┼", "╞", "╟", "╚", "╔", "╩", "╦", "╠", "═", "╬", "╧",
- "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐", "▀",
- "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩",
- "≡", "±", "≥", "≤", "⌠", "⌡", "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", " "
-};
+static const char* g_byteMapping[] = {" ", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "◙", "♂", "♀", "♪", "♫", "☼",
+ "▸", "◂", "↕", "‼", "¶", "§", "▬", "↨", "↑", "↓", "→", "←", "∟", "↔", "▴", "▾", " ", "!", "\"", "#", "$", "%", "&",
+ "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=",
+ ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
+ "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "⌂", "Ç", "ü", "é",
+ "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö",
+ "Ü", "¢", "£", "¥", "₧", "ƒ", "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»", "░",
+ "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐", "└", "┴", "┬", "├", "─", "┼", "╞", "╟",
+ "╚", "╔", "╩", "╦", "╠", "═", "╬", "╧", "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐",
+ "▀", "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩", "≡", "±", "≥", "≤", "⌠", "⌡",
+ "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", " "};
-ByteView::ByteView(QWidget* parent, BinaryViewRef data): QAbstractScrollArea(parent), m_render(this)
+ByteView::ByteView(QWidget* parent, BinaryViewRef data) : QAbstractScrollArea(parent), m_render(this)
{
setBinaryDataNavigable(true);
setupView(this);
@@ -72,7 +65,7 @@ ByteView::ByteView(QWidget* parent, BinaryViewRef data): QAbstractScrollArea(par
m_updateTimer = new QTimer(this);
m_updateTimer->setInterval(200);
m_updateTimer->setSingleShot(false);
- //connect(m_updateTimer, &QTimer::timeout, this, &ByteView::updateTimerEvent);
+ // connect(m_updateTimer, &QTimer::timeout, this, &ByteView::updateTimerEvent);
actionHandler()->bindAction("Move Cursor Up", UIAction([=]() { up(false); }));
actionHandler()->bindAction("Move Cursor Down", UIAction([=]() { down(false); }));
@@ -155,7 +148,7 @@ BNAddressRange ByteView::getSelectionOffsets()
start = end;
end = t;
}
- return { start, end };
+ return {start, end};
}
void ByteView::setSelectionOffsets(BNAddressRange range)
@@ -169,11 +162,11 @@ void ByteView::updateRanges()
{
m_ranges = m_data->GetAllocatedRanges();
// Remove regions not backed by the file
- for (auto& i: m_data->GetSegments())
+ for (auto& i : m_data->GetSegments())
if (i->GetDataLength() < i->GetLength())
removeRange(i->GetStart() + i->GetDataLength(), i->GetEnd());
m_allocatedLength = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
m_allocatedLength += i.end - i.start;
}
@@ -181,7 +174,7 @@ void ByteView::updateRanges()
void ByteView::removeRange(uint64_t begin, uint64_t end)
{
std::vector<BNAddressRange> newRanges;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((end <= i.start) || (begin >= i.end))
{
@@ -193,16 +186,16 @@ void ByteView::removeRange(uint64_t begin, uint64_t end)
}
else if ((begin <= i.start) && (end < i.end))
{
- newRanges.push_back(BNAddressRange { end, i.end });
+ newRanges.push_back(BNAddressRange {end, i.end});
}
else if ((begin > i.start) && (end >= i.end))
{
- newRanges.push_back(BNAddressRange { i.start, begin });
+ newRanges.push_back(BNAddressRange {i.start, begin});
}
else
{
- newRanges.push_back(BNAddressRange { i.start, begin });
- newRanges.push_back(BNAddressRange { end, i.end });
+ newRanges.push_back(BNAddressRange {i.start, begin});
+ newRanges.push_back(BNAddressRange {end, i.end});
}
}
m_ranges = newRanges;
@@ -211,7 +204,7 @@ void ByteView::removeRange(uint64_t begin, uint64_t end)
void ByteView::setTopToAddress(uint64_t addr)
{
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((addr >= i.start) && (addr <= i.end))
{
@@ -237,7 +230,7 @@ bool ByteView::navigate(uint64_t addr)
if (addr > getEnd())
return false;
m_cursorAddr = getStart();
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if (i.start > addr)
break;
@@ -293,7 +286,7 @@ void ByteView::adjustSize(int width, int height)
uint64_t ByteView::getContiguousOffsetForAddress(uint64_t addr)
{
uint64_t offset = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((addr >= i.start) && (addr <= i.end))
{
@@ -309,7 +302,7 @@ uint64_t ByteView::getContiguousOffsetForAddress(uint64_t addr)
uint64_t ByteView::getAddressForContiguousOffset(uint64_t offset)
{
uint64_t cur = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if (offset < (cur + (i.end - i.start)))
return i.start + (offset - cur);
@@ -352,7 +345,7 @@ ByteViewLine ByteView::createLine(uint64_t addr, size_t length, bool separator)
{
if (separator)
{
- return ByteViewLine { addr, length, "", true };
+ return ByteViewLine {addr, length, "", true};
}
else
{
@@ -360,7 +353,7 @@ ByteViewLine ByteView::createLine(uint64_t addr, size_t length, bool separator)
QString line;
for (size_t i = 0; i < data.GetLength(); i++)
line.append(QString(g_byteMapping[data[i]]));
- return ByteViewLine { addr, length, line, false };
+ return ByteViewLine {addr, length, line, false};
}
}
@@ -369,7 +362,7 @@ bool ByteView::cachePreviousLines()
{
bool prevEndValid = false;
uint64_t prevEnd = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_topAddr > i.start) && (m_topAddr <= i.end))
{
@@ -410,7 +403,7 @@ bool ByteView::cachePreviousLines()
bool ByteView::cacheNextLines()
{
uint64_t lastAddr = m_data->GetStart();
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_bottomAddr >= i.start) && (m_bottomAddr < i.end))
{
@@ -519,8 +512,8 @@ void ByteView::repositionCaret()
bool found = false;
for (size_t i = 0; i < m_lines.size(); i++)
{
- if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length))) ||
- (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
+ if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length)))
+ || (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
{
if (i < m_topLine)
m_topLine = i;
@@ -557,11 +550,11 @@ void ByteView::updateCaret()
// Rerender both the old caret position and the new caret position
for (size_t i = m_topLine; (i < m_lines.size()) && (i < (m_topLine + m_visibleRows)); i++)
{
- if (((m_prevCursorAddr >= m_lines[i].address) && (m_prevCursorAddr <= (m_lines[i].address + m_lines[i].length))) ||
- ((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr <= (m_lines[i].address + m_lines[i].length))))
+ if (((m_prevCursorAddr >= m_lines[i].address) && (m_prevCursorAddr <= (m_lines[i].address + m_lines[i].length)))
+ || ((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr <= (m_lines[i].address + m_lines[i].length))))
{
- viewport()->update(0, (int)(i - m_topLine) * m_render.getFontHeight(),
- viewport()->size().width(), m_render.getFontHeight() + 3);
+ viewport()->update(0, (int)(i - m_topLine) * m_render.getFontHeight(), viewport()->size().width(),
+ m_render.getFontHeight() + 3);
}
}
}
@@ -628,22 +621,22 @@ void ByteView::paintEvent(QPaintEvent* event)
if (startY == endY)
{
p.drawRect(2 + ((int)m_addrWidth + 2 + startX) * charWidth, 2 + startY * charHeight,
- (endX - startX) * charWidth, charHeight + 1);
+ (endX - startX) * charWidth, charHeight + 1);
}
else
{
p.drawRect(2 + ((int)m_addrWidth + 2 + startX) * charWidth, 2 + startY * charHeight,
- ((int)m_cols - startX) * charWidth, charHeight + 1);
+ ((int)m_cols - startX) * charWidth, charHeight + 1);
if (endX > 0)
{
- p.drawRect(2 + ((int)m_addrWidth + 2) * charWidth, 2 + endY * charHeight,
- endX * charWidth, charHeight + 1);
+ p.drawRect(2 + ((int)m_addrWidth + 2) * charWidth, 2 + endY * charHeight, endX * charWidth,
+ charHeight + 1);
}
}
if ((endY - startY) > 1)
{
p.drawRect(2 + ((int)m_addrWidth + 2) * charWidth, 2 + (startY + 1) * charHeight,
- (int)m_cols * charWidth, ((endY - startY) - 1) * charHeight + 1);
+ (int)m_cols * charWidth, ((endY - startY) - 1) * charHeight + 1);
}
}
}
@@ -658,8 +651,8 @@ void ByteView::paintEvent(QPaintEvent* event)
break;
if (m_lines[y + m_topLine].separator)
{
- m_render.drawLinearDisassemblyLineBackground(p, NonContiguousSeparatorLineType,
- QRect(0, 2 + y * charHeight, event->rect().width(), charHeight), 0);
+ m_render.drawLinearDisassemblyLineBackground(
+ p, NonContiguousSeparatorLineType, QRect(0, 2 + y * charHeight, event->rect().width(), charHeight), 0);
continue;
}
@@ -670,8 +663,8 @@ void ByteView::paintEvent(QPaintEvent* event)
bool hasCursor = false;
int cursorCol = 0;
- if (((m_cursorAddr >= lineStartAddr) && (m_cursorAddr < (lineStartAddr + length))) ||
- (((y + (int)m_topLine + 1) >= (int)m_lines.size()) && (m_cursorAddr == (lineStartAddr + length))))
+ if (((m_cursorAddr >= lineStartAddr) && (m_cursorAddr < (lineStartAddr + length)))
+ || (((y + (int)m_topLine + 1) >= (int)m_lines.size()) && (m_cursorAddr == (lineStartAddr + length))))
{
cursorCol = (int)(m_cursorAddr - lineStartAddr);
hasCursor = true;
@@ -684,13 +677,15 @@ void ByteView::paintEvent(QPaintEvent* event)
{
p.setPen(Qt::NoPen);
p.setBrush(palette().color(QPalette::WindowText));
- p.drawRect(2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, charWidth, charHeight + 1);
+ p.drawRect(
+ 2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, charWidth, charHeight + 1);
QColor caretTextColor = palette().color(QPalette::Base);
BinaryNinja::DataBuffer byteValue = m_data->ReadBuffer(lineStartAddr + cursorCol, 1);
if (byteValue.GetLength() == 1)
{
QString byteStr = g_byteMapping[byteValue[0]];
- m_render.drawText(p, 2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, caretTextColor, byteStr);
+ m_render.drawText(
+ p, 2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, caretTextColor, byteStr);
}
}
}
@@ -699,7 +694,7 @@ void ByteView::paintEvent(QPaintEvent* event)
void ByteView::wheelEvent(QWheelEvent* event)
{
- if (event->angleDelta().x()) // ignore horizontal scrolling
+ if (event->angleDelta().x()) // ignore horizontal scrolling
return;
m_wheelDelta -= event->angleDelta().y();
@@ -796,7 +791,7 @@ void ByteView::focusOutEvent(QFocusEvent*)
void ByteView::selectNone()
{
- for (auto& i: m_lines)
+ for (auto& i : m_lines)
{
if ((m_cursorAddr >= i.address) && (m_cursorAddr < (i.address + i.length)) && i.separator)
{
@@ -825,7 +820,7 @@ void ByteView::selectAll()
void ByteView::adjustAddressAfterBackwardMovement()
{
uint64_t lastAddr = getStart();
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_cursorAddr >= i.start) && (m_cursorAddr < i.end))
break;
@@ -841,7 +836,7 @@ void ByteView::adjustAddressAfterBackwardMovement()
void ByteView::adjustAddressAfterForwardMovement()
{
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_cursorAddr >= i.start) && (m_cursorAddr < i.end))
break;
@@ -900,8 +895,8 @@ void ByteView::pageUp(bool selecting)
{
for (size_t i = 0; i < m_lines.size(); i++)
{
- if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length))) ||
- (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
+ if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length)))
+ || (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
{
if (i < m_visibleRows)
{
@@ -942,8 +937,8 @@ void ByteView::pageDown(bool selecting)
{
for (size_t i = 0; i < m_lines.size(); i++)
{
- if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length))) ||
- (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
+ if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length)))
+ || (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
{
if (i >= (m_lines.size() - m_visibleRows))
{
@@ -982,7 +977,7 @@ void ByteView::pageDown(bool selecting)
void ByteView::moveToStartOfLine(bool selecting)
{
- for (auto& i: m_lines)
+ for (auto& i : m_lines)
{
if ((m_cursorAddr >= i.address) && (m_cursorAddr < (i.address + i.length)))
{
@@ -1000,7 +995,7 @@ void ByteView::moveToStartOfLine(bool selecting)
void ByteView::moveToEndOfLine(bool selecting)
{
- for (auto& i: m_lines)
+ for (auto& i : m_lines)
{
if ((m_cursorAddr >= i.address) && (m_cursorAddr < (i.address + i.length)))
{
@@ -1095,9 +1090,7 @@ void ByteView::mouseMoveEvent(QMouseEvent* event)
}
-ByteViewType::ByteViewType(): ViewType("Bytes", "Byte Overview")
-{
-}
+ByteViewType::ByteViewType() : ViewType("Bytes", "Byte Overview") {}
int ByteViewType::getPriority(BinaryViewRef, const QString&)
diff --git a/examples/triage/byte.h b/examples/triage/byte.h
index 61cb51a4..1c8c20f8 100644
--- a/examples/triage/byte.h
+++ b/examples/triage/byte.h
@@ -14,7 +14,7 @@ struct ByteViewLine
};
-class ByteView: public QAbstractScrollArea, public View
+class ByteView : public QAbstractScrollArea, public View
{
BinaryViewRef m_data;
RenderContext m_render;
@@ -76,7 +76,7 @@ class ByteView: public QAbstractScrollArea, public View
uint64_t addressFromLocation(int x, int y);
-public:
+ public:
ByteView(QWidget* parent, BinaryViewRef data);
virtual BinaryViewRef getData() override;
@@ -93,7 +93,7 @@ public:
uint64_t getEnd();
uint64_t getLength();
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
@@ -102,16 +102,16 @@ protected:
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void scrollBarMoved(int value);
void scrollBarAction(int action);
void cursorTimerEvent();
};
-class ByteViewType: public ViewType
+class ByteViewType : public ViewType
{
-public:
+ public:
ByteViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* frame) override;
diff --git a/examples/triage/entropy.cpp b/examples/triage/entropy.cpp
index 72ca0a92..b43350cd 100644
--- a/examples/triage/entropy.cpp
+++ b/examples/triage/entropy.cpp
@@ -30,7 +30,8 @@ void EntropyThread::Run()
{
if (!m_running)
break;
- std::vector<float> entropy = m_data->GetEntropy(m_data->GetStart() + ((uint64_t)i * m_blockSize), m_blockSize, m_blockSize);
+ std::vector<float> entropy =
+ m_data->GetEntropy(m_data->GetStart() + ((uint64_t)i * m_blockSize), m_blockSize, m_blockSize);
int v;
if (entropy.size() == 0)
v = 0;
@@ -53,7 +54,7 @@ void EntropyThread::Run()
}
-EntropyWidget::EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data): QWidget(parent)
+EntropyWidget::EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data) : QWidget(parent)
{
m_view = view;
m_data = data;
diff --git a/examples/triage/entropy.h b/examples/triage/entropy.h
index eb75cfee..a48097c4 100644
--- a/examples/triage/entropy.h
+++ b/examples/triage/entropy.h
@@ -14,7 +14,7 @@ class EntropyThread
bool m_updated, m_running;
std::thread m_thread;
-public:
+ public:
EntropyThread(BinaryViewRef data, size_t blockSize, QImage* image);
~EntropyThread();
@@ -26,7 +26,7 @@ public:
class TriageView;
-class EntropyWidget: public QWidget
+class EntropyWidget : public QWidget
{
TriageView* m_view;
BinaryViewRef m_data, m_rawData;
@@ -35,16 +35,16 @@ class EntropyWidget: public QWidget
QImage m_image;
EntropyThread* m_thread;
-public:
+ public:
EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
virtual ~EntropyWidget();
virtual QSize sizeHint() const override;
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void timerExpired();
};
diff --git a/examples/triage/exports.cpp b/examples/triage/exports.cpp
index bc5b970e..5ad63613 100644
--- a/examples/triage/exports.cpp
+++ b/examples/triage/exports.cpp
@@ -12,12 +12,12 @@ GenericExportsModel::GenericExportsModel(BinaryViewRef data)
m_totalCols = 2;
m_sortCol = 0;
m_sortOrder = Qt::AscendingOrder;
- for (auto& sym: data->GetSymbolsOfType(FunctionSymbol))
+ for (auto& sym : data->GetSymbolsOfType(FunctionSymbol))
{
if ((sym->GetBinding() == GlobalBinding) || (sym->GetBinding() == WeakBinding))
m_allEntries.push_back(sym);
}
- for (auto& sym: data->GetSymbolsOfType(DataSymbol))
+ for (auto& sym : data->GetSymbolsOfType(DataSymbol))
{
if ((sym->GetBinding() == GlobalBinding) || (sym->GetBinding() == WeakBinding))
m_allEntries.push_back(sym);
@@ -148,7 +148,7 @@ void GenericExportsModel::setFilter(const std::string& filterText)
{
beginResetModel();
m_entries.clear();
- for (auto& entry: m_allEntries)
+ for (auto& entry : m_allEntries)
{
if (FilteredView::match(entry->GetFullName(), filterText))
m_entries.push_back(entry);
@@ -158,7 +158,7 @@ void GenericExportsModel::setFilter(const std::string& filterText)
}
-ExportsTreeView::ExportsTreeView(ExportsWidget* parent, TriageView* view, BinaryViewRef data): QTreeView(parent)
+ExportsTreeView::ExportsTreeView(ExportsWidget* parent, TriageView* view, BinaryViewRef data) : QTreeView(parent)
{
m_data = data;
m_parent = parent;
@@ -262,7 +262,7 @@ void ExportsTreeView::keyPressEvent(QKeyEvent* event)
}
-ExportsWidget::ExportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data): QWidget(parent)
+ExportsWidget::ExportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data) : QWidget(parent)
{
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
diff --git a/examples/triage/exports.h b/examples/triage/exports.h
index e79fe7eb..bb0c4411 100644
--- a/examples/triage/exports.h
+++ b/examples/triage/exports.h
@@ -5,7 +5,7 @@
#include "filter.h"
-class GenericExportsModel: public QAbstractItemModel
+class GenericExportsModel : public QAbstractItemModel
{
std::vector<SymbolRef> m_allEntries, m_entries;
int m_addrCol, m_nameCol, m_ordinalCol;
@@ -14,7 +14,7 @@ class GenericExportsModel: public QAbstractItemModel
void performSort(int col, Qt::SortOrder order);
-public:
+ public:
GenericExportsModel(BinaryViewRef data);
virtual int columnCount(const QModelIndex& parent) const override;
@@ -36,7 +36,7 @@ public:
class TriageView;
class ExportsWidget;
-class ExportsTreeView: public QTreeView, public FilterTarget
+class ExportsTreeView : public QTreeView, public FilterTarget
{
BinaryViewRef m_data;
ExportsWidget* m_parent;
@@ -44,7 +44,7 @@ class ExportsTreeView: public QTreeView, public FilterTarget
UIActionHandler m_actionHandler;
GenericExportsModel* m_model;
-public:
+ public:
ExportsTreeView(ExportsWidget* parent, TriageView* view, BinaryViewRef data);
virtual void setFilter(const std::string& filterText) override;
@@ -54,20 +54,20 @@ public:
virtual void activateFirstItem() override;
virtual void closeFilter() override;
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void exportSelected(const QModelIndex& cur, const QModelIndex& prev);
void exportDoubleClicked(const QModelIndex& cur);
};
-class ExportsWidget: public QWidget
+class ExportsWidget : public QWidget
{
FilteredView* m_filter;
-public:
+ public:
ExportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
void showFilter(const QString& filter);
};
diff --git a/examples/triage/fileinfo.cpp b/examples/triage/fileinfo.cpp
index 2ff7cf38..ddb94897 100644
--- a/examples/triage/fileinfo.cpp
+++ b/examples/triage/fileinfo.cpp
@@ -6,94 +6,92 @@
#include <QToolTip>
#include <QPainter>
-class CopyableLabel: public QLabel
+class CopyableLabel : public QLabel
{
- QColor m_desiredColor{};
+ QColor m_desiredColor {};
-public:
- CopyableLabel(const QString& text, const QColor& color)
- : QLabel(text), m_desiredColor(color)
- {
- this->setMouseTracking(true);
- auto style = QPalette(palette());
- style.setColor(QPalette::WindowText, m_desiredColor);
- setPalette(style);
- this->setToolTip("Copy");
- }
+ public:
+ CopyableLabel(const QString& text, const QColor& color) : QLabel(text), m_desiredColor(color)
+ {
+ this->setMouseTracking(true);
+ auto style = QPalette(palette());
+ style.setColor(QPalette::WindowText, m_desiredColor);
+ setPalette(style);
+ this->setToolTip("Copy");
+ }
- void enterEvent(QEnterEvent* event) override
- {
- auto font = this->font();
- font.setBold(true);
- this->setFont(font);
- QToolTip::showText(event->globalPosition().toPoint(), this->toolTip());
- }
+ void enterEvent(QEnterEvent* event) override
+ {
+ auto font = this->font();
+ font.setBold(true);
+ this->setFont(font);
+ QToolTip::showText(event->globalPosition().toPoint(), this->toolTip());
+ }
- void leaveEvent(QEvent* event) override
- {
- auto font = this->font();
- font.setBold(false);
- this->setFont(font);
- QToolTip::hideText();
- }
+ void leaveEvent(QEvent* event) override
+ {
+ auto font = this->font();
+ font.setBold(false);
+ this->setFont(font);
+ QToolTip::hideText();
+ }
- void mousePressEvent(QMouseEvent* event) override
- {
- if (event->button() == Qt::LeftButton)
- QApplication::clipboard()->setText(this->text());
- }
+ void mousePressEvent(QMouseEvent* event) override
+ {
+ if (event->button() == Qt::LeftButton)
+ QApplication::clipboard()->setText(this->text());
+ }
};
void FileInfoWidget::addField(const QString& name, const QVariant& value)
{
- auto& [row, column] = this->m_fieldPosition;
+ auto& [row, column] = this->m_fieldPosition;
- const auto valueLabel = new QLabel(value.toString());
- valueLabel->setFont(getMonospaceFont(this));
+ const auto valueLabel = new QLabel(value.toString());
+ valueLabel->setFont(getMonospaceFont(this));
- this->m_layout->addWidget(new QLabel(name), row, column);
- this->m_layout->addWidget(valueLabel, row++, column + 1);
+ this->m_layout->addWidget(new QLabel(name), row, column);
+ this->m_layout->addWidget(valueLabel, row++, column + 1);
}
-void FileInfoWidget::addHashField(const QString& hashName,
- const QCryptographicHash::Algorithm& algorithm,
- const QByteArray& data)
+void FileInfoWidget::addHashField(
+ const QString& hashName, const QCryptographicHash::Algorithm& algorithm, const QByteArray& data)
{
- auto& [row, column] = this->m_fieldPosition;
+ auto& [row, column] = this->m_fieldPosition;
- const auto hashFieldColor = getThemeColor(AlphanumericHighlightColor);
- const auto crypto = QCryptographicHash::hash(data, algorithm);
- const auto hashLabel = new CopyableLabel(crypto.toHex(), hashFieldColor);
- hashLabel->setFont(getMonospaceFont(this));
+ const auto hashFieldColor = getThemeColor(AlphanumericHighlightColor);
+ const auto crypto = QCryptographicHash::hash(data, algorithm);
+ const auto hashLabel = new CopyableLabel(crypto.toHex(), hashFieldColor);
+ hashLabel->setFont(getMonospaceFont(this));
- this->m_layout->addWidget(new QLabel(hashName), row, column);
- this->m_layout->addWidget(hashLabel, row++, column + 1);
+ this->m_layout->addWidget(new QLabel(hashName), row, column);
+ this->m_layout->addWidget(hashLabel, row++, column + 1);
}
FileInfoWidget::FileInfoWidget(QWidget* parent, BinaryViewRef bv)
{
- this->m_layout = new QGridLayout();
- this->m_layout->setContentsMargins(0, 0, 0, 0);
- this->m_layout->setVerticalSpacing(1);
+ this->m_layout = new QGridLayout();
+ this->m_layout->setContentsMargins(0, 0, 0, 0);
+ this->m_layout->setVerticalSpacing(1);
- const auto view = bv->GetParentView() ? bv->GetParentView() : bv;
- const auto filePath = bv->GetFile()->GetOriginalFilename();
- this->addField("Path: ", filePath.c_str());
+ const auto view = bv->GetParentView() ? bv->GetParentView() : bv;
+ const auto filePath = bv->GetFile()->GetOriginalFilename();
+ this->addField("Path: ", filePath.c_str());
- const auto fileSize = QString::number(view->GetLength(), 16).prepend("0x");
- this->addField("Size: ", fileSize);
+ const auto fileSize = QString::number(view->GetLength(), 16).prepend("0x");
+ this->addField("Size: ", fileSize);
- const auto bufferSize = fileSize.toUInt(nullptr, 16);
- const auto fileBuffer = std::make_unique<char[]>(bufferSize);
- view->Read(fileBuffer.get(), 0, bufferSize);
+ const auto bufferSize = fileSize.toUInt(nullptr, 16);
+ const auto fileBuffer = std::make_unique<char[]>(bufferSize);
+ view->Read(fileBuffer.get(), 0, bufferSize);
- const auto fileBytes = QByteArray(fileBuffer.get(), bufferSize);
- this->addHashField("MD5: ", QCryptographicHash::Md5, fileBytes);
- this->addHashField("SHA-1: ", QCryptographicHash::Sha1, fileBytes);
- this->addHashField("SHA-256: ", QCryptographicHash::Sha256, fileBytes);
+ const auto fileBytes = QByteArray(fileBuffer.get(), bufferSize);
+ this->addHashField("MD5: ", QCryptographicHash::Md5, fileBytes);
+ this->addHashField("SHA-1: ", QCryptographicHash::Sha1, fileBytes);
+ this->addHashField("SHA-256: ", QCryptographicHash::Sha256, fileBytes);
- const auto scaledWidth = UIContext::getScaledWindowSize(20, 20).width();
- this->m_layout->setColumnMinimumWidth(FileInfoWidget::m_maxColumns * 3 - 1, scaledWidth);
- this->m_layout->setColumnStretch(FileInfoWidget::m_maxColumns * 3 - 1, 1);
- setLayout(this->m_layout);
+ const auto scaledWidth = UIContext::getScaledWindowSize(20, 20).width();
+ this->m_layout->setColumnMinimumWidth(FileInfoWidget::m_maxColumns * 3 - 1, scaledWidth);
+ this->m_layout->setColumnStretch(FileInfoWidget::m_maxColumns * 3 - 1, 1);
+ setLayout(this->m_layout);
} \ No newline at end of file
diff --git a/examples/triage/fileinfo.h b/examples/triage/fileinfo.h
index 02cc154d..14a7ec3c 100644
--- a/examples/triage/fileinfo.h
+++ b/examples/triage/fileinfo.h
@@ -5,17 +5,15 @@
#include "uitypes.h"
#include "viewframe.h"
-class FileInfoWidget: public QWidget
+class FileInfoWidget : public QWidget
{
- static constexpr std::int32_t m_maxColumns{2};
- std::pair<std::int32_t, std::int32_t> m_fieldPosition{}; // row, column
- QGridLayout* m_layout{};
+ static constexpr std::int32_t m_maxColumns {2};
+ std::pair<std::int32_t, std::int32_t> m_fieldPosition {}; // row, column
+ QGridLayout* m_layout {};
- void addField(const QString& name, const QVariant& value);
- void addHashField(const QString& hashName,
- const QCryptographicHash::Algorithm& algorithm,
- const QByteArray& data);
+ void addField(const QString& name, const QVariant& value);
+ void addHashField(const QString& hashName, const QCryptographicHash::Algorithm& algorithm, const QByteArray& data);
-public:
- FileInfoWidget(QWidget* parent, BinaryViewRef bv);
+ public:
+ FileInfoWidget(QWidget* parent, BinaryViewRef bv);
};
diff --git a/examples/triage/files.cpp b/examples/triage/files.cpp
index fcb71cd0..d70b61cd 100644
--- a/examples/triage/files.cpp
+++ b/examples/triage/files.cpp
@@ -18,7 +18,7 @@ TriageFilePicker::TriageFilePicker(UIContext* context)
m_model = new QFileSystemModel();
m_model->setRootPath("");
if (hiddenFiles)
- m_model->setFilter(QDir::Hidden | QDir::AllEntries | QDir::System );
+ m_model->setFilter(QDir::Hidden | QDir::AllEntries | QDir::System);
m_tree = new QTreeView(this);
m_tree->setModel(m_model);
m_tree->setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -45,9 +45,8 @@ TriageFilePicker::TriageFilePicker(UIContext* context)
recentFile = parentDir;
}
- m_actionHandler.bindAction("Open Selected Files", UIAction(
- [=]() { openSelectedFiles(); },
- [=]() { return areFilesSelected(); }));
+ m_actionHandler.bindAction(
+ "Open Selected Files", UIAction([=]() { openSelectedFiles(); }, [=]() { return areFilesSelected(); }));
m_contextMenu.addAction("Open Selected Files", "Open");
}
@@ -70,11 +69,11 @@ void TriageFilePicker::openSelectedFiles()
std::set<QString> files;
SettingsRef settings = BinaryNinja::Settings::Instance();
- for (auto& index: m_tree->selectionModel()->selectedIndexes())
+ for (auto& index : m_tree->selectionModel()->selectedIndexes())
if (m_model->fileInfo(index).isFile())
files.insert(m_model->fileInfo(index).absoluteFilePath());
- for (auto& filename: files)
+ for (auto& filename : files)
{
QSettings().setValue("triage/recentFile", filename);
@@ -85,7 +84,7 @@ void TriageFilePicker::openSelectedFiles()
continue;
}
- for (auto data: f->getAllDataViews())
+ for (auto data : f->getAllDataViews())
{
settings->Set("analysis.mode", settings->Get<std::string>("triage.analysisMode"), data);
settings->Set("triage.preferSummaryView", true, data);
@@ -118,7 +117,7 @@ void TriageFilePicker::openSelectedFiles()
if (failedToOpen.size() > 0)
{
QString message = "Unable to open:\n";
- for (auto& name: failedToOpen)
+ for (auto& name : failedToOpen)
message += name + "\n";
QMessageBox::critical(this, "Error", message);
}
diff --git a/examples/triage/files.h b/examples/triage/files.h
index e371d869..01d8e75e 100644
--- a/examples/triage/files.h
+++ b/examples/triage/files.h
@@ -3,15 +3,15 @@
#include <QtWidgets/QWidget>
#include <QtWidgets/QTreeView>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWidgets/QFileSystemModel>
+ #include <QtWidgets/QFileSystemModel>
#else
-#include <QtGui/QFileSystemModel>
+ #include <QtGui/QFileSystemModel>
#endif
#include "action.h"
#include "menus.h"
-class TriageFilePicker: public QWidget
+class TriageFilePicker : public QWidget
{
UIContext* m_context;
UIActionHandler m_actionHandler;
@@ -24,12 +24,12 @@ class TriageFilePicker: public QWidget
void openSelectedFiles();
bool areFilesSelected();
-public:
+ public:
TriageFilePicker(UIContext* context);
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent*) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void onDoubleClick(const QModelIndex& idx);
};
diff --git a/examples/triage/headers.cpp b/examples/triage/headers.cpp
index 7b8de78e..e327153e 100644
--- a/examples/triage/headers.cpp
+++ b/examples/triage/headers.cpp
@@ -6,8 +6,8 @@
#include "viewframe.h"
-NavigationLabel::NavigationLabel(const QString& text, QColor color, const std::function<void()>& func):
- QLabel(text), m_func(func)
+NavigationLabel::NavigationLabel(const QString& text, QColor color, const std::function<void()>& func) :
+ QLabel(text), m_func(func)
{
QPalette style(palette());
style.setColor(QPalette::WindowText, color);
@@ -22,8 +22,8 @@ void NavigationLabel::mousePressEvent(QMouseEvent*)
}
-NavigationAddressLabel::NavigationAddressLabel(const QString& text):
- NavigationLabel(text, getThemeColor(AddressColor), [this]() { clickEvent(); })
+NavigationAddressLabel::NavigationAddressLabel(const QString& text) :
+ NavigationLabel(text, getThemeColor(AddressColor), [this]() { clickEvent(); })
{
m_address = text.toULongLong(nullptr, 0);
}
@@ -37,8 +37,8 @@ void NavigationAddressLabel::clickEvent()
}
-NavigationCodeLabel::NavigationCodeLabel(const QString& text):
- NavigationLabel(text, getThemeColor(CodeSymbolColor), [this]() { clickEvent(); })
+NavigationCodeLabel::NavigationCodeLabel(const QString& text) :
+ NavigationLabel(text, getThemeColor(CodeSymbolColor), [this]() { clickEvent(); })
{
m_address = text.toULongLong(nullptr, 0);
}
@@ -52,20 +52,18 @@ void NavigationCodeLabel::clickEvent()
}
-Headers::Headers(): m_columns(1), m_rowsPerColumn(8)
-{
-}
+Headers::Headers() : m_columns(1), m_rowsPerColumn(8) {}
void Headers::AddField(const QString& title, const QString& value, HeaderFieldType type)
{
- m_fields.push_back(HeaderField { title, {value}, type });
+ m_fields.push_back(HeaderField {title, {value}, type});
}
void Headers::AddField(const QString& title, const std::vector<QString>& values, HeaderFieldType type)
{
- m_fields.push_back(HeaderField { title, values, type });
+ m_fields.push_back(HeaderField {title, values, type});
}
@@ -174,40 +172,39 @@ PEHeaders::PEHeaders(BinaryViewRef data)
uint64_t stackCommit = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfStackCommit");
uint64_t stackReserve = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfStackReserve");
- AddField("Stack Size", QString("0x") + QString::number(stackCommit, 16) + QString(" / 0x") +
- QString::number(stackReserve, 16));
+ AddField("Stack Size",
+ QString("0x") + QString::number(stackCommit, 16) + QString(" / 0x") + QString::number(stackReserve, 16));
uint64_t heapCommit = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfHeapCommit");
uint64_t heapReserve = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfHeapReserve");
- AddField("Heap Size", QString("0x") + QString::number(heapCommit, 16) + QString(" / 0x") +
- QString::number(heapReserve, 16));
+ AddField("Heap Size",
+ QString("0x") + QString::number(heapCommit, 16) + QString(" / 0x") + QString::number(heapReserve, 16));
uint64_t linkerMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorLinkerVersion");
uint64_t linkerMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorLinkerVersion");
- AddField("Linker Version", QString::number(linkerMajor) + QString(".") +
- QString::number(linkerMinor).rightJustified(2, '0'));
+ AddField("Linker Version",
+ QString::number(linkerMajor) + QString(".") + QString::number(linkerMinor).rightJustified(2, '0'));
uint64_t imageMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorImageVersion");
uint64_t imageMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorImageVersion");
- AddField("Image Version", QString::number(imageMajor) + QString(".") +
- QString::number(imageMinor).rightJustified(2, '0'));
+ AddField("Image Version",
+ QString::number(imageMajor) + QString(".") + QString::number(imageMinor).rightJustified(2, '0'));
uint64_t osMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorOperatingSystemVersion");
uint64_t osMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorOperatingSystemVersion");
- AddField("OS Version", QString::number(osMajor) + QString(".") +
- QString::number(osMinor).rightJustified(2, '0'));
+ AddField("OS Version", QString::number(osMajor) + QString(".") + QString::number(osMinor).rightJustified(2, '0'));
uint64_t subMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorSubsystemVersion");
uint64_t subMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorSubsystemVersion");
- AddField("Subsystem Version", QString::number(subMajor) + QString(".") +
- QString::number(subMinor).rightJustified(2, '0'));
+ AddField("Subsystem Version",
+ QString::number(subMajor) + QString(".") + QString::number(subMinor).rightJustified(2, '0'));
uint64_t coffCharValue = GetValueOfStructMember(data, "COFF_Header", peOffset, "characteristics");
TypeRef coffCharEnum = data->GetTypeByName(BinaryNinja::QualifiedName("coff_characteristics"));
if (coffCharEnum && (coffCharEnum->GetClass() == EnumerationTypeClass))
{
std::vector<QString> coffCharValues;
- for (auto& member: coffCharEnum->GetEnumeration()->GetMembers())
+ for (auto& member : coffCharEnum->GetEnumeration()->GetMembers())
{
if (coffCharValue & member.value)
{
@@ -226,12 +223,13 @@ PEHeaders::PEHeaders(BinaryViewRef data)
if (dllCharEnum && (dllCharEnum->GetClass() == EnumerationTypeClass))
{
std::vector<QString> dllCharValues;
- for (auto& member: dllCharEnum->GetEnumeration()->GetMembers())
+ for (auto& member : dllCharEnum->GetEnumeration()->GetMembers())
{
if (dllCharValue & member.value)
{
if (QString::fromStdString(member.name).startsWith("IMAGE_DLLCHARACTERISTICS_"))
- dllCharValues.push_back(QString::fromStdString(member.name).mid((int)strlen("IMAGE_DLLCHARACTERISTICS_")));
+ dllCharValues.push_back(
+ QString::fromStdString(member.name).mid((int)strlen("IMAGE_DLLCHARACTERISTICS_")));
else
dllCharValues.push_back(QString::fromStdString(member.name));
}
@@ -245,8 +243,8 @@ PEHeaders::PEHeaders(BinaryViewRef data)
}
-uint64_t PEHeaders::GetValueOfStructMember(BinaryViewRef data, const std::string& structName, uint64_t structStart,
- const std::string& fieldName)
+uint64_t PEHeaders::GetValueOfStructMember(
+ BinaryViewRef data, const std::string& structName, uint64_t structStart, const std::string& fieldName)
{
TypeRef type = data->GetTypeByName(structName);
if (!type)
@@ -254,7 +252,7 @@ uint64_t PEHeaders::GetValueOfStructMember(BinaryViewRef data, const std::string
if (type->GetClass() != StructureTypeClass)
return 0;
StructureRef s = type->GetStructure();
- for (auto& member: s->GetMembers())
+ for (auto& member : s->GetMembers())
{
if (member.name == fieldName)
{
@@ -285,7 +283,7 @@ QString PEHeaders::GetNameOfEnumerationMember(BinaryViewRef data, const std::str
TypeRef type = data->GetTypeByName(enumName);
if (type && (type->GetClass() == EnumerationTypeClass))
{
- for (auto& member: type->GetEnumeration()->GetMembers())
+ for (auto& member : type->GetEnumeration()->GetMembers())
{
if (member.value == value)
return QString::fromStdString(member.name);
@@ -295,17 +293,17 @@ QString PEHeaders::GetNameOfEnumerationMember(BinaryViewRef data, const std::str
}
-HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header): QWidget(parent)
+HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header) : QWidget(parent)
{
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setVerticalSpacing(1);
int row = 0;
int col = 0;
- for (auto& field: header.GetFields())
+ for (auto& field : header.GetFields())
{
layout->addWidget(new QLabel(field.title + ": "), row, col * 3);
- for (auto& value: field.values)
+ for (auto& value : field.values)
{
QWidget* label;
if (field.type == AddressHeaderField)
@@ -324,7 +322,8 @@ HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header): QWidget(pare
layout->addWidget(label, row, col * 3 + 1);
row++;
}
- if ((header.GetColumns() > 1) && (row >= (int)header.GetRowsPerColumn()) && ((col + 1) < (int)header.GetColumns()))
+ if ((header.GetColumns() > 1) && (row >= (int)header.GetRowsPerColumn())
+ && ((col + 1) < (int)header.GetColumns()))
{
row = 0;
col++;
diff --git a/examples/triage/headers.h b/examples/triage/headers.h
index 0a9af5ff..a8348401 100644
--- a/examples/triage/headers.h
+++ b/examples/triage/headers.h
@@ -6,36 +6,36 @@
#include "uitypes.h"
-class NavigationLabel: public QLabel
+class NavigationLabel : public QLabel
{
std::function<void()> m_func;
-public:
+ public:
NavigationLabel(const QString& text, QColor color, const std::function<void()>& func);
-protected:
+ protected:
virtual void mousePressEvent(QMouseEvent* event) override;
};
-class NavigationAddressLabel: public NavigationLabel
+class NavigationAddressLabel : public NavigationLabel
{
uint64_t m_address;
void clickEvent();
-public:
+ public:
NavigationAddressLabel(const QString& text);
};
-class NavigationCodeLabel: public NavigationLabel
+class NavigationCodeLabel : public NavigationLabel
{
uint64_t m_address;
void clickEvent();
-public:
+ public:
NavigationCodeLabel(const QString& text);
};
@@ -61,7 +61,7 @@ class Headers
std::vector<HeaderField> m_fields;
size_t m_columns, m_rowsPerColumn;
-public:
+ public:
Headers();
void AddField(const QString& title, const QString& value, HeaderFieldType type = TextHeaderField);
void AddField(const QString& title, const std::vector<QString>& values, HeaderFieldType type = TextHeaderField);
@@ -73,27 +73,27 @@ public:
};
-class GenericHeaders: public Headers
+class GenericHeaders : public Headers
{
-public:
+ public:
GenericHeaders(BinaryViewRef data);
};
-class PEHeaders: public Headers
+class PEHeaders : public Headers
{
- uint64_t GetValueOfStructMember(BinaryViewRef data, const std::string& structName, uint64_t structStart,
- const std::string& fieldName);
+ uint64_t GetValueOfStructMember(
+ BinaryViewRef data, const std::string& structName, uint64_t structStart, const std::string& fieldName);
uint64_t GetAddressAfterStruct(BinaryViewRef data, const std::string& structName, uint64_t structStart);
QString GetNameOfEnumerationMember(BinaryViewRef data, const std::string& enumName, uint64_t value);
-public:
+ public:
PEHeaders(BinaryViewRef data);
};
-class HeaderWidget: public QWidget
+class HeaderWidget : public QWidget
{
-public:
+ public:
HeaderWidget(QWidget* parent, const Headers& headers);
};
diff --git a/examples/triage/imports.cpp b/examples/triage/imports.cpp
index 7a0c0d2a..79c1f35e 100644
--- a/examples/triage/imports.cpp
+++ b/examples/triage/imports.cpp
@@ -14,7 +14,7 @@ GenericImportsModel::GenericImportsModel(BinaryViewRef data)
m_sortCol = 0;
m_sortOrder = Qt::AscendingOrder;
m_allEntries = data->GetSymbolsOfType(ImportAddressSymbol);
- for (auto& sym: m_allEntries)
+ for (auto& sym : m_allEntries)
{
if ((sym->GetNameSpace().size() != 1) || (sym->GetNameSpace()[0] != "BNINTERNALNAMESPACE"))
{
@@ -168,7 +168,7 @@ void GenericImportsModel::setFilter(const std::string& filterText)
{
beginResetModel();
m_entries.clear();
- for (auto& entry: m_allEntries)
+ for (auto& entry : m_allEntries)
{
if (FilteredView::match(entry->GetFullName(), filterText))
m_entries.push_back(entry);
@@ -180,7 +180,7 @@ void GenericImportsModel::setFilter(const std::string& filterText)
}
-ImportsTreeView::ImportsTreeView(ImportsWidget* parent, TriageView* view, BinaryViewRef data): QTreeView(parent)
+ImportsTreeView::ImportsTreeView(ImportsWidget* parent, TriageView* view, BinaryViewRef data) : QTreeView(parent)
{
m_data = data;
m_parent = parent;
@@ -279,7 +279,7 @@ void ImportsTreeView::keyPressEvent(QKeyEvent* event)
}
-ImportsWidget::ImportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data): QWidget(parent)
+ImportsWidget::ImportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data) : QWidget(parent)
{
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
diff --git a/examples/triage/imports.h b/examples/triage/imports.h
index cacda087..2199aa47 100644
--- a/examples/triage/imports.h
+++ b/examples/triage/imports.h
@@ -5,7 +5,7 @@
#include "filter.h"
-class GenericImportsModel: public QAbstractItemModel
+class GenericImportsModel : public QAbstractItemModel
{
std::vector<SymbolRef> m_allEntries, m_entries;
bool m_hasModules;
@@ -16,7 +16,7 @@ class GenericImportsModel: public QAbstractItemModel
QString getNamespace(SymbolRef sym) const;
void performSort(int col, Qt::SortOrder order);
-public:
+ public:
GenericImportsModel(BinaryViewRef data);
virtual int columnCount(const QModelIndex& parent) const override;
@@ -38,7 +38,7 @@ public:
class TriageView;
class ImportsWidget;
-class ImportsTreeView: public QTreeView, public FilterTarget
+class ImportsTreeView : public QTreeView, public FilterTarget
{
BinaryViewRef m_data;
ImportsWidget* m_parent;
@@ -46,7 +46,7 @@ class ImportsTreeView: public QTreeView, public FilterTarget
UIActionHandler m_actionHandler;
GenericImportsModel* m_model;
-public:
+ public:
ImportsTreeView(ImportsWidget* parent, TriageView* view, BinaryViewRef data);
virtual void setFilter(const std::string& filterText) override;
@@ -56,20 +56,20 @@ public:
virtual void activateFirstItem() override;
virtual void closeFilter() override;
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void importSelected(const QModelIndex& cur, const QModelIndex& prev);
void importDoubleClicked(const QModelIndex& cur);
};
-class ImportsWidget: public QWidget
+class ImportsWidget : public QWidget
{
FilteredView* m_filter;
-public:
+ public:
ImportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
void showFilter(const QString& filter);
};
diff --git a/examples/triage/sections.cpp b/examples/triage/sections.cpp
index 026b3d7b..95993031 100644
--- a/examples/triage/sections.cpp
+++ b/examples/triage/sections.cpp
@@ -7,22 +7,21 @@
#include "fontsettings.h"
-SegmentsWidget::SegmentsWidget(QWidget* parent, BinaryViewRef data): QWidget(parent)
+SegmentsWidget::SegmentsWidget(QWidget* parent, BinaryViewRef data) : QWidget(parent)
{
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setVerticalSpacing(1);
layout->setHorizontalSpacing(UIContext::getScaledWindowSize(16, 16).width());
- for (auto& segment: data->GetSegments())
+ for (auto& segment : data->GetSegments())
if ((segment->GetFlags() & (SegmentReadable | SegmentWritable | SegmentExecutable)) != 0)
m_segments.push_back(segment);
- sort(m_segments.begin(), m_segments.end(), [&](SegmentRef a, SegmentRef b) {
- return a->GetStart() < b->GetStart();
- });
+ sort(m_segments.begin(), m_segments.end(),
+ [&](SegmentRef a, SegmentRef b) { return a->GetStart() < b->GetStart(); });
int row = 0;
- for (auto& segment: m_segments)
+ for (auto& segment : m_segments)
{
QString begin = QString("0x") + QString::number(segment->GetStart(), 16);
QString end = QString("0x") + QString::number(segment->GetEnd(), 16);
@@ -64,7 +63,7 @@ SegmentsWidget::SegmentsWidget(QWidget* parent, BinaryViewRef data): QWidget(par
}
-SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data): QWidget(parent)
+SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data) : QWidget(parent)
{
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
@@ -72,21 +71,20 @@ SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data): QWidget(par
layout->setHorizontalSpacing(UIContext::getScaledWindowSize(16, 16).width());
size_t maxNameLen = 0;
- for (auto& section: data->GetSections())
+ for (auto& section : data->GetSections())
if (section->GetName().size() > maxNameLen)
maxNameLen = section->GetName().size();
if (maxNameLen > 32)
maxNameLen = 32;
- for (auto& section: data->GetSections())
+ for (auto& section : data->GetSections())
if (section->GetSemantics() != ExternalSectionSemantics)
m_sections.push_back(section);
- sort(m_sections.begin(), m_sections.end(), [&](SectionRef a, SectionRef b) {
- return a->GetStart() < b->GetStart();
- });
+ sort(m_sections.begin(), m_sections.end(),
+ [&](SectionRef a, SectionRef b) { return a->GetStart() < b->GetStart(); });
int row = 0;
- for (auto& section: m_sections)
+ for (auto& section : m_sections)
{
std::string name = section->GetName();
if (name.size() > maxNameLen)
diff --git a/examples/triage/sections.h b/examples/triage/sections.h
index 09c9ea63..00285df8 100644
--- a/examples/triage/sections.h
+++ b/examples/triage/sections.h
@@ -4,21 +4,21 @@
#include "uitypes.h"
-class SegmentsWidget: public QWidget
+class SegmentsWidget : public QWidget
{
std::vector<SegmentRef> m_segments;
-public:
+ public:
SegmentsWidget(QWidget* parent, BinaryViewRef data);
const std::vector<SegmentRef>& GetSegments() const { return m_segments; }
};
-class SectionsWidget: public QWidget
+class SectionsWidget : public QWidget
{
std::vector<SectionRef> m_sections;
-public:
+ public:
SectionsWidget(QWidget* parent, BinaryViewRef data);
const std::vector<SectionRef>& GetSections() const { return m_sections; }
};
diff --git a/examples/triage/triage.cpp b/examples/triage/triage.cpp
index 5d0dc1d5..b268f069 100644
--- a/examples/triage/triage.cpp
+++ b/examples/triage/triage.cpp
@@ -17,7 +17,7 @@ extern "C"
SettingsRef settings = BinaryNinja::Settings::Instance();
settings->RegisterGroup("triage", "Triage");
settings->RegisterSetting("triage.preferSummaryView",
- R"({
+ R"({
"title" : "Always Prefer Triage Summary View",
"type" : "boolean",
"default" : false,
@@ -25,7 +25,7 @@ extern "C"
})");
settings->RegisterSetting("triage.preferSummaryViewForRaw",
- R"({
+ R"({
"title" : "Prefer Triage Summary View for Raw Files",
"type" : "boolean",
"default" : false,
@@ -35,7 +35,7 @@ extern "C"
ViewType::registerViewType(new TriageViewType());
settings->RegisterSetting("triage.analysisMode",
- R"({
+ R"({
"title" : "Triage Analysis Mode",
"type" : "string",
"default" : "basic",
@@ -48,7 +48,7 @@ extern "C"
})");
settings->RegisterSetting("triage.linearSweep",
- R"({
+ R"({
"title" : "Triage Linear Sweep Mode",
"type" : "string",
"default" : "partial",
@@ -61,7 +61,7 @@ extern "C"
})");
settings->RegisterSetting("triage.hiddenFiles",
- R"({
+ R"({
"title" : "Triage Shows Hidden Files",
"type" : "boolean",
"default" : false,
@@ -85,7 +85,8 @@ extern "C"
Menu::mainMenu("File")->addAction("Open for Triage...", "Open");
- UIContext::registerFileOpenMode("Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...");
+ UIContext::registerFileOpenMode(
+ "Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...");
ViewType::registerViewType(new ByteViewType());
return true;
diff --git a/examples/triage/view.cpp b/examples/triage/view.cpp
index 2c5f7b9b..8a85ba26 100644
--- a/examples/triage/view.cpp
+++ b/examples/triage/view.cpp
@@ -11,7 +11,7 @@
#include "fontsettings.h"
#include <binaryninjacore.h>
-TriageView::TriageView(QWidget* parent, BinaryViewRef data): QScrollArea(parent)
+TriageView::TriageView(QWidget* parent, BinaryViewRef data) : QScrollArea(parent)
{
setBinaryDataNavigable(true);
setupView(this);
@@ -26,11 +26,11 @@ TriageView::TriageView(QWidget* parent, BinaryViewRef data): QScrollArea(parent)
entropyGroup->setLayout(entropyLayout);
layout->addWidget(entropyGroup);
- QGroupBox* fileInfoGroup = new QGroupBox("File Info", container);
- QVBoxLayout* fileInfoLayout = new QVBoxLayout();
- fileInfoLayout->addWidget(new FileInfoWidget(fileInfoGroup, m_data));
- fileInfoGroup->setLayout(fileInfoLayout);
- layout->addWidget(fileInfoGroup);
+ QGroupBox* fileInfoGroup = new QGroupBox("File Info", container);
+ QVBoxLayout* fileInfoLayout = new QVBoxLayout();
+ fileInfoLayout->addWidget(new FileInfoWidget(fileInfoGroup, m_data));
+ fileInfoGroup->setLayout(fileInfoLayout);
+ layout->addWidget(fileInfoGroup);
Headers* hdr = nullptr;
if (m_data->GetTypeName() == "PE")
@@ -129,7 +129,7 @@ BNAddressRange TriageView::getSelectionOffsets()
{
if (m_byteView)
return m_byteView->getSelectionOffsets();
- return { m_currentOffset, m_currentOffset };
+ return {m_currentOffset, m_currentOffset};
}
void TriageView::setSelectionOffsets(BNAddressRange range)
@@ -164,7 +164,7 @@ bool TriageView::navigate(uint64_t addr)
void TriageView::startFullAnalysis()
{
BinaryNinja::Settings::Instance()->Set("analysis.mode", "full", m_data);
- for (auto& f: m_data->GetAnalysisFunctionList())
+ for (auto& f : m_data->GetAnalysisFunctionList())
{
if (f->IsAnalysisSkipped())
f->Reanalyze();
@@ -223,9 +223,7 @@ void TriageView::focusInEvent(QFocusEvent*)
}
-TriageViewType::TriageViewType(): ViewType("Triage", "Triage Summary")
-{
-}
+TriageViewType::TriageViewType() : ViewType("Triage", "Triage Summary") {}
int TriageViewType::getPriority(BinaryViewRef data, const QString&)
diff --git a/examples/triage/view.h b/examples/triage/view.h
index 37e53e7c..354091fb 100644
--- a/examples/triage/view.h
+++ b/examples/triage/view.h
@@ -6,14 +6,14 @@
#include "byte.h"
-class TriageView: public QScrollArea, public View
+class TriageView : public QScrollArea, public View
{
BinaryViewRef m_data;
uint64_t m_currentOffset = 0;
ByteView* m_byteView = nullptr;
QPushButton* m_fullAnalysisButton = nullptr;
-public:
+ public:
TriageView(QWidget* parent, BinaryViewRef data);
virtual BinaryViewRef getData() override;
@@ -26,17 +26,17 @@ public:
void setCurrentOffset(uint64_t offset);
void navigateToFileOffset(uint64_t offset);
-protected:
+ protected:
virtual void focusInEvent(QFocusEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void startFullAnalysis();
};
-class TriageViewType: public ViewType
+class TriageViewType : public ViewType
{
-public:
+ public:
TriageViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* frame) override;