summaryrefslogtreecommitdiff
path: root/examples/triage/baseaddress.h
diff options
context:
space:
mode:
authorBrandon Miller <brandon@vector35.com>2024-03-21 10:52:21 -0400
committerBrandon Miller <bkmiller89@icloud.com>2024-04-25 10:56:18 -0400
commit4b2b3d561b92a01f4d29b86d5510d39e4d1accf3 (patch)
tree2d51e8c9c1fd539f27ffc52bcfe464ab6bd73ef0 /examples/triage/baseaddress.h
parent6ba7605eafb5419b82e2721026e9dc922de95347 (diff)
Base address detection widget in Triage view
Initial implementation of base address detection UI widget in triage summary
Diffstat (limited to 'examples/triage/baseaddress.h')
-rw-r--r--examples/triage/baseaddress.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/examples/triage/baseaddress.h b/examples/triage/baseaddress.h
new file mode 100644
index 00000000..aa5e70ab
--- /dev/null
+++ b/examples/triage/baseaddress.h
@@ -0,0 +1,81 @@
+#pragma once
+
+#include <QThread>
+#include <QtWidgets/QPushButton>
+#include <QtWidgets/QLineEdit>
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QTableWidget>
+#include <QHeaderView>
+#include "theme.h"
+#include "fontsettings.h"
+#include "viewframe.h"
+#include "binaryninjaapi.h"
+#include "binaryninjacore.h"
+
+struct BaseAddressDetectionQtInputs
+{
+ QComboBox* ArchitectureBox;
+ QComboBox* AnalysisBox;
+ QLineEdit* StrlenLineEdit;
+ QLineEdit* AlignmentLineEdit;
+ QLineEdit* LowerBoundary;
+ QLineEdit* UpperBoundary;
+ QComboBox* POIBox;
+ QLineEdit* MaxPointersPerCluster;
+};
+
+struct BaseAddressDetectionQtResults
+{
+ std::string Status;
+ std::set<std::pair<size_t, uint64_t>> Scores;
+ BinaryNinja::BaseAddressDetectionConfidence Confidence;
+};
+
+class BaseAddressDetectionThread : public QThread
+{
+ Q_OBJECT
+ BinaryNinja::Ref<BinaryNinja::BinaryView> m_view;
+ BinaryNinja::BaseAddressDetection* m_baseDetection;
+ BaseAddressDetectionQtInputs* m_inputs {};
+ void run() override;
+
+public:
+ BaseAddressDetectionThread(BaseAddressDetectionQtInputs* widgetInputs, BinaryNinja::Ref<BinaryNinja::BinaryView> bv)
+ {
+ m_inputs = widgetInputs;
+ m_view = bv;
+ m_baseDetection = new BinaryNinja::BaseAddressDetection(m_view);
+ }
+
+ void Abort() { m_baseDetection->Abort(); }
+ bool IsAborted() { return m_baseDetection->IsAborted(); }
+
+signals:
+ void ResultReady(const BaseAddressDetectionQtResults& result);
+};
+
+class BaseAddressDetectionWidget : public QWidget
+{
+ BaseAddressDetectionThread* m_worker;
+ BinaryNinja::Ref<BinaryNinja::BinaryView> m_view;
+ QGridLayout* m_layout {};
+
+ QPushButton* m_detectBaseAddressButton = nullptr;
+ QPushButton* m_abortButton = nullptr;
+
+ BaseAddressDetectionQtInputs m_inputs;
+ QLabel* m_preferredBase;
+ QLabel* m_confidence;
+ QLabel* m_status;
+ QLineEdit* m_reloadBase;
+ QPushButton* m_rebaseButton;
+ QTableWidget* m_resultsTableWidget;
+
+ void DetectBaseAddress();
+ void RebaseWithFullAnalysis();
+ void Abort();
+ void HandleResults(const BaseAddressDetectionQtResults& results);
+
+public:
+ BaseAddressDetectionWidget(QWidget* parent, BinaryNinja::Ref<BinaryNinja::BinaryView> bv);
+}; \ No newline at end of file