diff options
| author | Rusty Wagner <rusty@vector35.com> | 2020-04-10 22:04:08 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2020-04-17 14:20:25 -0400 |
| commit | 9c1577c370d76b1797d55176cb59a10666b6ef2f (patch) | |
| tree | 4b4ee97e205557c98d48be0c9abbd94bf24b95b1 /ui | |
| parent | 111a17fe65435ccf96b66d7c55a33d3642c68b9a (diff) | |
Initial implementation of new linear view API
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/linearview.h | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/ui/linearview.h b/ui/linearview.h index 62bb3dad..f8f85439 100644 --- a/ui/linearview.h +++ b/ui/linearview.h @@ -13,34 +13,59 @@ #define LINEAR_VIEW_UPDATE_CHECK_INTERVAL 200 #define MAX_STRING_TYPE_LENGTH 1048576 +struct BINARYNINJAUIAPI LinearViewLine: public BinaryNinja::LinearDisassemblyLine +{ + BinaryNinja::Ref<BinaryNinja::LinearViewCursor> cursor; + size_t lineIndex; +}; + struct BINARYNINJAUIAPI LinearViewCursorPosition: public BinaryNinja::LinearDisassemblyPosition { - uint64_t lineAddress; - size_t lineIndexForAddress; + BinaryNinja::Ref<BinaryNinja::LinearViewCursor> cursor; + size_t lineIndex; size_t tokenIndex; LinearViewCursorPosition(); LinearViewCursorPosition(const LinearViewCursorPosition& pos); LinearViewCursorPosition(const BinaryNinja::LinearDisassemblyPosition& pos); + LinearViewCursorPosition(const LinearViewLine& line); LinearViewCursorPosition& operator=(const LinearViewCursorPosition& pos); + + bool operator==(const LinearViewCursorPosition& other) const; + bool operator!=(const LinearViewCursorPosition& other) const; + bool operator<(const LinearViewCursorPosition& other) const; + bool operator<=(const LinearViewCursorPosition& other) const; + bool operator>=(const LinearViewCursorPosition& other) const; + bool operator>(const LinearViewCursorPosition& other) const; + + LinearViewCursorPosition AsLine() const; }; class BINARYNINJAUIAPI LinearViewHistoryEntry: public HistoryEntry { - BinaryNinja::LinearDisassemblyPosition m_topPosition; - LinearViewCursorPosition m_cursorPosition; - size_t m_topLineOffset; + std::vector<BinaryNinja::LinearViewObjectIdentifier> m_topPath; + size_t m_topLineIndex; + uint64_t m_topAddr; + std::vector<BinaryNinja::LinearViewObjectIdentifier> m_cursorPath; + size_t m_cursorLineIndex; + uint64_t m_cursorAddr; HighlightTokenState m_highlight; public: - const BinaryNinja::LinearDisassemblyPosition& getTopPosition() const { return m_topPosition; } - const LinearViewCursorPosition& getCursorPosition() const { return m_cursorPosition; } - size_t getTopLineOffset() const { return m_topLineOffset; } + const std::vector<BinaryNinja::LinearViewObjectIdentifier>& getTopPath() const { return m_topPath; } + size_t getTopLineIndex() const { return m_topLineIndex; } + uint64_t getTopAddress() const { return m_topAddr; } + const std::vector<BinaryNinja::LinearViewObjectIdentifier>& getCursorPath() const { return m_cursorPath; } + size_t getCursorLineIndex() const { return m_cursorLineIndex; } + uint64_t getCursorAddress() const { return m_cursorAddr; } const HighlightTokenState& getHighlightTokenState() const { return m_highlight; } - void setTopPosition(const BinaryNinja::LinearDisassemblyPosition& pos) { m_topPosition = pos; } - void setCursorPosition(const LinearViewCursorPosition& pos) { m_cursorPosition = pos; } - void setTopLineOffset(size_t offset) { m_topLineOffset = offset; } + void setTopPath(const std::vector<BinaryNinja::LinearViewObjectIdentifier>& path) { m_topPath = path; } + void setTopLineIndex(size_t offset) { m_topLineIndex = offset; } + void setTopAddress(uint64_t addr) { m_topAddr = addr; } + void setCursorPath(const std::vector<BinaryNinja::LinearViewObjectIdentifier>& path) { m_cursorPath = path; } + void setCursorLineIndex(size_t offset) { m_cursorLineIndex = offset; } + void setCursorAddress(uint64_t addr) { m_cursorAddr = addr; } void setHighlightTokenState(const HighlightTokenState& state) { m_highlight = state; } }; @@ -73,7 +98,6 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ BinaryViewRef m_data; ViewFrame* m_view; - std::vector<BNAddressRange> m_ranges; uint64_t m_allocatedLength; RenderContext m_render; @@ -83,7 +107,7 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ bool m_updatingScrollBar; bool m_updatesRequired; - bool m_updateBounds, m_updateBlockRef; + bool m_updateBounds; LinearViewCursorPosition m_cursorPosition, m_selectionStartPos; bool m_tokenSelection = false; @@ -93,8 +117,8 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ DisassemblySettingsRef m_settings; - BinaryNinja::LinearDisassemblyPosition m_topPosition, m_bottomPosition; - std::vector<BinaryNinja::LinearDisassemblyLine> m_lines; + BinaryNinja::Ref<BinaryNinja::LinearViewCursor> m_topPosition, m_bottomPosition; + std::vector<LinearViewLine> m_lines; size_t m_topLine; QTimer* m_updateTimer; @@ -104,13 +128,11 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ void adjustSize(int width, int height); - uint64_t getContiguousOffsetForAddress(uint64_t addr); - uint64_t getAddressForContiguousOffset(uint64_t offset); - void setTopToAddress(uint64_t addr); + void setTopToOrderingIndex(uint64_t idx); void refreshLines(size_t lineOffset = 0, bool refreshUIContext = true); bool cachePreviousLines(); - bool cacheNextLines(size_t& topLineAdjustment); + bool cacheNextLines(); void updateCache(); void refreshAtCurrentLocation(); bool navigateToAddress(uint64_t addr, bool center, bool updateHighlight, bool navByRef = false); @@ -138,6 +160,15 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ TypeRef getPointerTypeAndName(ArchitectureRef arch, uint64_t addr, std::string& name); std::string getVariableName(uint64_t addr); + BinaryNinja::Ref<BinaryNinja::LinearViewObject> createLinearViewObject(); + LinearViewCursorPosition getPositionForCursor(BinaryNinja::LinearViewCursor* cursor); + bool updateCursor(LinearViewCursorPosition& cursorToUpdate, BinaryNinja::LinearViewCursor* matched, bool fullMatch); + bool updateCursor(LinearViewCursorPosition& cursorToUpdate, BinaryNinja::LinearViewCursor* newCursor); + bool updateCursor(LinearViewCursorPosition& cursorToUpdate, + const std::vector<BinaryNinja::LinearViewObjectIdentifier>& path, + BinaryNinja::LinearViewCursor* newCursor); + uint64_t getOrderingIndexForLine(const LinearViewLine& line); + private Q_SLOTS: void viewInHexEditor(); void viewInGraph(); |
