diff options
| author | Mason Reed <mason@vector35.com> | 2025-01-31 12:59:42 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-07-02 01:58:31 -0400 |
| commit | 110c06851bbbd09f78a3e87979d529d6e09df851 (patch) | |
| tree | 7849015b26a14cd2b7be2d87fc1e0d5c101ef457 /plugins/warp/ui/shared/function.h | |
| parent | 7b1e8bbdb971aed21b6d889aa4a46f9ef54829c1 (diff) | |
WARP 1.0
- Added FFI
- Added a sidebar to the UI
- Added project, directory and archive processing
- Added generic `Container` interface for extensible stores of WARP data
- Fixed type references being constructed and pulled incorrectly
- Added HTML, Markdown and JSON report generation
- Made the WARP information added as an analysis activity
- Flattened the signatures directory, the target information is stored in the file now
- Matched function information is stored as function metadata in the database to reliably persist, alongside the function GUID
- Split the matching out from the application, allowing you to match on a given function without applying it
- Added more/better tests
- Added support for binaries with multiple architectures, the functions are now also queried based off the Target, see WARP spec for more details
- Greatly improved support for RISC architectures, see WARP spec for more details
- Greatly improved UX when loading files after the fact, will now sanely rerun the matcher
- Omitted the function type if not a user type, this greatly reduces file size
- Improved support for functions that reference a page aligned base pointer, see WARP spec for more details
- Removed some extra cache structures that were causing erroneous behavior
- Fixed edge-case in LLIL traversal missing some constant pointers, this was a bug in the Rust bindings
- Added support for function comments
- Made long running tasks, such as generating, matching and loading signatures, cancellable where possible
- Made function constraints more versatile, allowing for easy extensions in the future, see WARP spec for details
- Added options to signature generation, such as what data to store, and whether to compress the data or not
- Made all long running tasks prompt the user for required information before the task starts, allowing users to "set it and forget it" and not have to baby sit the finalization of the task
- Myriad of other changes to the actual WARP format that impact performance, file size and general feature set, see https://github.com/Vector35/warp for more details
Diffstat (limited to 'plugins/warp/ui/shared/function.h')
| -rw-r--r-- | plugins/warp/ui/shared/function.h | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/plugins/warp/ui/shared/function.h b/plugins/warp/ui/shared/function.h new file mode 100644 index 00000000..90d52092 --- /dev/null +++ b/plugins/warp/ui/shared/function.h @@ -0,0 +1,168 @@ +#pragma once +#include <QStandardItemModel> +#include <QTableView> + +#include "binaryninjaapi.h" +#include "constraint.h" +#include "filter.h" +#include "misc.h" +#include "warp.h" + +class WarpFunctionItem : public QStandardItem +{ + Warp::Ref<Warp::Function> m_function; + + // Optional attached data used to show/manage the function. + Warp::Ref<Warp::Container> m_container; + std::optional<Warp::Source> m_source; + +public: + WarpFunctionItem(Warp::Ref<Warp::Function> function, + BinaryNinja::Ref<BinaryNinja::Function> analysisFunction); + + void SetContainer(const Warp::Ref<Warp::Container> &container); + + void SetSource(Warp::Source source); + + Warp::Ref<Warp::Function> GetFunction() { return m_function; } + Warp::Ref<Warp::Container> GetContainer() { return m_container; } + std::optional<Warp::Source> GetSource() { return m_source; } +}; + +class WarpFunctionItemModel : public QStandardItemModel +{ + Q_OBJECT + + // The current matched function, used to highlight currently. + Warp::Ref<Warp::Function> m_matchedFunction; + + // Mapping of function start address to the row index. + // This is used to identify unique functions for updating instead of resetting the entire model. + std::unordered_map<uint64_t, int> m_insertableFunctionRows; + +public: + WarpFunctionItemModel(const QStringList &labels, QObject *parent); + + static constexpr int COL_FUNCTION_ITEM = 0; + static constexpr int COL_ADDRESS_ITEM = 1; + + void AppendFunction(WarpFunctionItem *item); + + void InsertFunction(uint64_t address, WarpFunctionItem *item); + + WarpFunctionItem *GetItem(const QModelIndex &index) const; + + std::optional<uint64_t> GetAddress(const QModelIndex &index) const; + + QVariant data(const QModelIndex &index, int role) const override; + + void SetMatchedFunction(const Warp::Ref<Warp::Function> &matchedFunction) + { + Warp::Ref<Warp::Function> previousMatchedFunction = m_matchedFunction; + m_matchedFunction = matchedFunction; + + // Make sure to refresh the highlights so we don't keep the highlights from the previous function. + if (previousMatchedFunction) + { + const QModelIndex topLeft = index(0, 0); + const QModelIndex bottomRight = index(rowCount() - 1, 0); + emit dataChanged(topLeft, bottomRight); + } + } +}; + +class WarpFunctionFilterModel : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + WarpFunctionFilterModel(QObject *parent): QSortFilterProxyModel(parent) + { + } + + ~WarpFunctionFilterModel() override = default; + + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + + bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override; +}; + +class WarpFunctionTableWidget : public QWidget, public FilterTarget +{ + Q_OBJECT + + QTableView *m_table; + WarpFunctionItemModel *m_model; + WarpFunctionFilterModel *m_proxyModel; + FilterEdit *m_filterEdit; + FilteredView *m_filterView; + QMenu *m_contextMenu; + std::map<QString, std::function<void(WarpFunctionItem *, std::optional<uint64_t>)> > m_contextMenuActions; + +public: + explicit WarpFunctionTableWidget(QWidget *parent = nullptr); + + // TODO: Invert this and provide OnCallback functions that wrap the connect call. + QTableView *GetTableView() const { return m_table; } + WarpFunctionItemModel *GetModel() const { return m_model; } + WarpFunctionFilterModel *GetProxyModel() const { return m_proxyModel; } + + void RegisterContextMenuAction(const QString &name, + const std::function<void(WarpFunctionItem *, std::optional<uint64_t>)> &callback); + + void SetFunctions(QVector<WarpFunctionItem *> functions); + + void InsertFunction(uint64_t address, WarpFunctionItem *function); + + void setFilter(const std::string &) override; + + void scrollToFirstItem() override + { + } + + void scrollToCurrentItem() override + { + } + + void selectFirstItem() override + { + } + + void activateFirstItem() override + { + } +}; + +class WarpFunctionInfoWidget : public QWidget +{ + Q_OBJECT + + Warp::Ref<Warp::Function> m_function; + BinaryNinja::Ref<BinaryNinja::Function> m_analysisFunction; + + // Optionally provide this information to show the source information. + Warp::Ref<Warp::Container> m_container; + std::string source; + + WarpConstraintTableWidget *m_constraintsTable; + + QTableView *m_commentsTable; + QStandardItemModel *m_commentsModel; + + QTableView *m_variablesTable; + +public: + explicit WarpFunctionInfoWidget(QWidget *parent = nullptr); + + Warp::Ref<Warp::Function> GetFunction() { return m_function; } + void SetFunction(Warp::Ref<Warp::Function> function) { m_function = function; }; + + void SetAnalysisFunction(BinaryNinja::Ref<BinaryNinja::Function> analysisFunction) + { + m_analysisFunction = analysisFunction; + }; + BinaryNinja::Ref<BinaryNinja::Function> GetAnalysisFunction() { return m_analysisFunction; } + + // TODO: Make this private? + void UpdateInfo(); +}; |
