diff options
| author | KyleMiles <krm504@nyu.edu> | 2022-01-27 22:43:28 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2022-01-28 00:24:06 -0500 |
| commit | 6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch) | |
| tree | dace4156d03148bcaf02df138ab4e0d93e61bc6f /ui/viewframe.h | |
| parent | 519c9db22367f2659d1a54599fab47e6313be06e (diff) | |
Format All Files
Diffstat (limited to 'ui/viewframe.h')
| -rw-r--r-- | ui/viewframe.h | 163 |
1 files changed, 88 insertions, 75 deletions
diff --git a/ui/viewframe.h b/ui/viewframe.h index 713dee56..00ec700a 100644 --- a/ui/viewframe.h +++ b/ui/viewframe.h @@ -2,9 +2,9 @@ #include <QtWidgets/QGestureEvent> #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -#include <QtWidgets/QAction> + #include <QtWidgets/QAction> #else -#include <QtGui/QAction> + #include <QtGui/QAction> #endif #include <QtWidgets/QLabel> #include <QtCore/QPointer> @@ -43,11 +43,10 @@ struct SelectionInfoForXref FunctionRef func; ArchitectureRef arch; - bool operator== (const SelectionInfoForXref& other) const + bool operator==(const SelectionInfoForXref& other) const { if (addrValid && other.addrValid) - return (start == other.start) && (end == other.end) && - (func == other.func) && (arch == other.arch); + return (start == other.start) && (end == other.end) && (func == other.func) && (arch == other.arch); else if (typeValid && other.typeValid) return type == other.type; else if (typeFieldValid && other.typeFieldValid) @@ -57,15 +56,15 @@ struct SelectionInfoForXref return false; } - bool operator!= (const SelectionInfoForXref& other) const { return !(*this == other); } + bool operator!=(const SelectionInfoForXref& other) const { return !(*this == other); } bool isValid() const { return addrValid || typeValid || typeFieldValid || localVarValid; } }; -class BINARYNINJAUIAPI HistoryEntry: public BinaryNinja::RefCountObject +class BINARYNINJAUIAPI HistoryEntry : public BinaryNinja::RefCountObject { QString m_viewType; -public: + public: virtual ~HistoryEntry() {} QString getViewType() const { return m_viewType; } @@ -100,7 +99,7 @@ class ViewPaneHeaderSubtypeWidget; class BINARYNINJAUIAPI View { -protected: + protected: Menu m_contextMenu; UIActionHandler m_actionHandler; bool m_binaryDataNavigable = false; @@ -118,7 +117,7 @@ protected: virtual void setNavigationMode(std::string mode) { (void)mode; } virtual std::vector<std::string> getNavigationModes() { return {}; } -public: + public: View(); virtual ~View() {} @@ -127,30 +126,25 @@ public: virtual bool canAssemble() { return false; } virtual bool canCompile() { return false; } - virtual bool findNextData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, - uint64_t& addr, BNFindFlag flags, - const std::function<bool (size_t current, size_t total)>& cb); - virtual bool findNextText(uint64_t start, uint64_t end, const std::string& text, - uint64_t& addr, DisassemblySettingsRef settings, BNFindFlag flags, - BNFunctionGraphType graph, - const std::function<bool (size_t current, size_t total)>& cb); - virtual bool findNextConstant(uint64_t start, uint64_t end, uint64_t constant, - uint64_t& addr, DisassemblySettingsRef settings, BNFunctionGraphType graph, - const std::function<bool (size_t current, size_t total)>& cb); + virtual bool findNextData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, uint64_t& addr, + BNFindFlag flags, const std::function<bool(size_t current, size_t total)>& cb); + virtual bool findNextText(uint64_t start, uint64_t end, const std::string& text, uint64_t& addr, + DisassemblySettingsRef settings, BNFindFlag flags, BNFunctionGraphType graph, + const std::function<bool(size_t current, size_t total)>& cb); + virtual bool findNextConstant(uint64_t start, uint64_t end, uint64_t constant, uint64_t& addr, + DisassemblySettingsRef settings, BNFunctionGraphType graph, + const std::function<bool(size_t current, size_t total)>& cb); virtual bool findAllData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, BNFindFlag flags, - const std::function<bool (size_t current, size_t total)>& cb, - const std::function<bool (uint64_t addr, const BinaryNinja::DataBuffer& match)>& matchCallback); - virtual bool findAllText(uint64_t start, uint64_t end, const std::string& data, - DisassemblySettingsRef settings, BNFindFlag flags, BNFunctionGraphType graph, - const std::function<bool (size_t current, size_t total)>& cb, - const std::function<bool (uint64_t addr, const std::string& match, - const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback); - virtual bool findAllConstant(uint64_t start, uint64_t end, uint64_t constant, - DisassemblySettingsRef settings, BNFunctionGraphType graph, - const std::function<bool (size_t current, size_t total)>& cb, - const std::function<bool (uint64_t addr, - const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback); + const std::function<bool(size_t current, size_t total)>& cb, + const std::function<bool(uint64_t addr, const BinaryNinja::DataBuffer& match)>& matchCallback); + virtual bool findAllText(uint64_t start, uint64_t end, const std::string& data, DisassemblySettingsRef settings, + BNFindFlag flags, BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& cb, + const std::function<bool( + uint64_t addr, const std::string& match, const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback); + virtual bool findAllConstant(uint64_t start, uint64_t end, uint64_t constant, DisassemblySettingsRef settings, + BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& cb, + const std::function<bool(uint64_t addr, const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback); virtual BinaryViewRef getData() = 0; virtual uint64_t getCurrentOffset() = 0; @@ -169,9 +163,9 @@ public: void setBinaryDataNavigable(bool navigable) { m_binaryDataNavigable = navigable; } virtual bool closeRequest() { return true; } - virtual void closing() { } - virtual void updateFonts() { } - virtual void updateTheme() { } + virtual void closing() {} + virtual void updateFonts() {} + virtual void updateTheme() {} virtual void undo(); virtual void redo(); @@ -214,7 +208,7 @@ public: virtual MediumLevelILFunctionRef getCurrentMediumLevelILFunction() { return nullptr; } virtual HighLevelILFunctionRef getCurrentHighLevelILFunction() { return nullptr; } virtual BNFunctionGraphType getILViewType() { return InvalidILViewType; } - virtual void setILViewType(BNFunctionGraphType ilViewType) { } + virtual void setILViewType(BNFunctionGraphType ilViewType) {} virtual size_t getCurrentILInstructionIndex() { return BN_INVALID_EXPR; } virtual QFont getFont() = 0; @@ -234,8 +228,16 @@ public: void forceSyncFromView(ViewFrame* frame = nullptr); virtual void clearRelatedHighlights() {} - virtual void setRelatedIndexHighlights(FunctionRef func, const std::set<size_t>& related) { (void)func; (void)related; } - virtual void setRelatedInstructionHighlights(FunctionRef func, const std::set<uint64_t>& related) { (void)func; (void)related; } + virtual void setRelatedIndexHighlights(FunctionRef func, const std::set<size_t>& related) + { + (void)func; + (void)related; + } + virtual void setRelatedInstructionHighlights(FunctionRef func, const std::set<uint64_t>& related) + { + (void)func; + (void)related; + } static void registerActions(); }; @@ -248,8 +250,12 @@ class BINARYNINJAUIAPI ViewNavigationMode ViewNavigationMode(); -public: - ViewNavigationMode(View* view, std::string mode) : m_view(view) { m_mode = m_view->getNavigationMode(); m_view->setNavigationMode(mode); } + public: + ViewNavigationMode(View* view, std::string mode) : m_view(view) + { + m_mode = m_view->getNavigationMode(); + m_view->setNavigationMode(mode); + } ~ViewNavigationMode() { m_view->setNavigationMode(m_mode); } }; @@ -263,17 +269,25 @@ class BINARYNINJAUIAPI ViewLocation BNFunctionGraphType m_ilViewType = NormalFunctionGraph; size_t m_instrIndex = BN_INVALID_EXPR; -public: - ViewLocation() { } - ViewLocation(const QString& viewType, uint64_t offset) : m_valid(true), m_viewType(viewType), m_offset(offset) { } - ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType) : m_valid(true), - m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType) { } - ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) : m_valid(true), - m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { } - ViewLocation(const QString& viewType, FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) : - m_valid(true), m_viewType(viewType), m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { } - ViewLocation(FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex = BN_INVALID_EXPR) : m_valid(true), - m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { } + public: + ViewLocation() {} + ViewLocation(const QString& viewType, uint64_t offset) : m_valid(true), m_viewType(viewType), m_offset(offset) {} + ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType) : + m_valid(true), m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType) + {} + ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) : + m_valid(true), m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) + {} + ViewLocation(const QString& viewType, FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, + size_t instrIndex) : + m_valid(true), + m_viewType(viewType), m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) + {} + ViewLocation( + FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex = BN_INVALID_EXPR) : + m_valid(true), + m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) + {} bool isValid() const { return m_valid; } QString getViewType() const { return m_viewType; } @@ -290,12 +304,9 @@ public: bool operator==(const ViewLocation& other) const { - return (m_valid == other.m_valid) && - (m_viewType == other.m_viewType) && - (m_offset == other.m_offset) && - (m_ilViewType == other.m_ilViewType) && - (m_instrIndex == other.m_instrIndex) && - (m_function == other.m_function); + return (m_valid == other.m_valid) && (m_viewType == other.m_viewType) && (m_offset == other.m_offset) + && (m_ilViewType == other.m_ilViewType) && (m_instrIndex == other.m_instrIndex) + && (m_function == other.m_function); } bool operator!=(const ViewLocation& other) const { return !((*this) == other); } }; @@ -303,7 +314,7 @@ public: class BINARYNINJAUIAPI ViewContainer { -public: + public: virtual ~ViewContainer() {} virtual View* getView() = 0; }; @@ -315,13 +326,13 @@ class BINARYNINJAUIAPI ViewFrame : public QWidget { Q_OBJECT -private: + private: QWidget* createView(const QString& typeName, ViewType* type, BinaryViewRef data, bool createDynamicWidgets = true); BinaryNinja::Ref<HistoryEntry> getHistoryEntry(); ViewFrame* searchForOtherPane(const std::function<void(const std::function<void(ViewPane*)>&)>& enumerator); FileContext* m_context; - bool m_fileContentsLock = true; // file contents protection from accidental modification in the UI + bool m_fileContentsLock = true; // file contents protection from accidental modification in the UI BinaryViewRef m_data; QWidget* m_view = nullptr; QWidget* m_viewContainer; @@ -335,7 +346,7 @@ private: UIActionHandler m_actionHandler; -protected: + protected: QPointer<CompileDialog> compileDialog; bool event(QEvent* event) override; @@ -350,7 +361,7 @@ protected: */ BinaryNinja::Ref<HistoryEntry> deserializeHistoryEntry(const Json::Value& json); -public: + public: explicit ViewFrame(QWidget* parent, FileContext* file, const QString& type, bool createDynamicWidgets = false); virtual ~ViewFrame(); @@ -385,7 +396,7 @@ public: Sidebar* getSidebar(); - template<class T> + template <class T> T* getSidebarWidget(const QString& name) { Sidebar* sidebar = getSidebar(); @@ -398,12 +409,14 @@ public: } bool navigate(const QString& type, uint64_t offset, bool updateInfo = true, bool addHistoryEntry = true); - bool navigate(const QString& type, const std::function<bool(View*)>& handler, bool updateInfo = true, bool addHistoryEntry = true); + bool navigate(const QString& type, const std::function<bool(View*)>& handler, bool updateInfo = true, + bool addHistoryEntry = true); bool navigate(BinaryViewRef data, uint64_t offset, bool updateInfo = true, bool addHistoryEntry = true); bool navigateToFunction(FunctionRef func, uint64_t offset, bool updateInfo = true, bool addHistoryEntry = true); - bool goToReference(BinaryViewRef data, FunctionRef func, uint64_t source, uint64_t target, bool addHistoryEntry = true); - bool navigateToViewLocation(BinaryViewRef data, const ViewLocation& viewLocation, - bool addHistoryEntry = true, bool center = false); + bool goToReference( + BinaryViewRef data, FunctionRef func, uint64_t source, uint64_t target, bool addHistoryEntry = true); + bool navigateToViewLocation( + BinaryViewRef data, const ViewLocation& viewLocation, bool addHistoryEntry = true, bool center = false); bool navigateToHistoryEntry(BinaryNinja::Ref<HistoryEntry> entry); QString getTypeForView(QWidget* view) const; QString getDataTypeForView(const QString& type) const; @@ -432,12 +445,12 @@ public: void back(); void forward(); - static bool getAddressFromString(QWidget* parent, BinaryViewRef data, uint64_t& offset, - uint64_t currentAddress, const QString& addrStr, std::string& errorString); - static bool getAddressFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset, - uint64_t currentAddress, const QString& title = "Go to Address", const QString& msg = "Address:", bool defaultToCurrent = false); - static bool getFileOffsetFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset, - uint64_t currentAddress, const QString& title = "Go to File Offset", const QString& msg = "File Offset:", bool defaultToCurrent = false); + static bool getAddressFromString(QWidget* parent, BinaryViewRef data, uint64_t& offset, uint64_t currentAddress, + const QString& addrStr, std::string& errorString); + static bool getAddressFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset, uint64_t currentAddress, + const QString& title = "Go to Address", const QString& msg = "Address:", bool defaultToCurrent = false); + static bool getFileOffsetFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset, uint64_t currentAddress, + const QString& title = "Go to File Offset", const QString& msg = "File Offset:", bool defaultToCurrent = false); void setCurrentFunction(FunctionRef func); void updateCrossReferences(); @@ -475,11 +488,11 @@ public: ViewFrame* getOtherPane(); -public Q_SLOTS: + public Q_SLOTS: virtual void assemble(); virtual void compile(); -Q_SIGNALS: + Q_SIGNALS: void notifyCloseFeatureMap(bool recreate); void notifyViewChanged(ViewFrame* frame); }; |
