From 4b2b3d561b92a01f4d29b86d5510d39e4d1accf3 Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Thu, 21 Mar 2024 10:52:21 -0400 Subject: Base address detection widget in Triage view Initial implementation of base address detection UI widget in triage summary --- examples/triage/baseaddress.h | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 examples/triage/baseaddress.h (limited to 'examples/triage/baseaddress.h') 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 +#include +#include +#include +#include +#include +#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> Scores; + BinaryNinja::BaseAddressDetectionConfidence Confidence; +}; + +class BaseAddressDetectionThread : public QThread +{ + Q_OBJECT + BinaryNinja::Ref m_view; + BinaryNinja::BaseAddressDetection* m_baseDetection; + BaseAddressDetectionQtInputs* m_inputs {}; + void run() override; + +public: + BaseAddressDetectionThread(BaseAddressDetectionQtInputs* widgetInputs, BinaryNinja::Ref 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 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 bv); +}; \ No newline at end of file -- cgit v1.3.1