From 9c1577c370d76b1797d55176cb59a10666b6ef2f Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Fri, 10 Apr 2020 22:04:08 -0400 Subject: Initial implementation of new linear view API --- binaryninjaapi.h | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 8267cbb8..e48fb33d 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1210,7 +1210,6 @@ __attribute__ ((format (printf, 1, 2))) BNLinearDisassemblyLineType type; Ref function; Ref block; - size_t lineOffset; DisassemblyTextLine contents; }; @@ -4963,4 +4962,81 @@ __attribute__ ((format (printf, 1, 2))) bool hasAutoAnnotations, const std::string& leadingSpaces=" "); }; + + struct LinearViewObjectIdentifier + { + std::string name; + BNLinearViewObjectIdentifierType type; + uint64_t start, end; + + LinearViewObjectIdentifier(); + LinearViewObjectIdentifier(const std::string& name); + LinearViewObjectIdentifier(const std::string& name, uint64_t addr); + LinearViewObjectIdentifier(const std::string& name, uint64_t start, uint64_t end); + LinearViewObjectIdentifier(const LinearViewObjectIdentifier& other); + }; + + class LinearViewObject: public CoreRefCountObject + { + public: + LinearViewObject(BNLinearViewObject* obj); + + Ref GetFirstChild(); + Ref GetLastChild(); + Ref GetPreviousChild(LinearViewObject* obj); + Ref GetNextChild(LinearViewObject* obj); + + Ref GetChildForAddress(uint64_t addr); + Ref GetChildForIdentifier(const LinearViewObjectIdentifier& id); + int CompareChildren(LinearViewObject* a, LinearViewObject* b); + + std::vector GetLines(LinearViewObject* prev, LinearViewObject* next); + + uint64_t GetStart() const; + uint64_t GetEnd() const; + + LinearViewObjectIdentifier GetIdentifier() const; + + uint64_t GetOrderingIndexTotal() const; + uint64_t GetOrderingIndexForChild(LinearViewObject* obj) const; + Ref GetChildForOrderingIndex(uint64_t idx); + + static Ref CreateDisassemblyByBlock(BinaryView* view, DisassemblySettings* settings); + }; + + class LinearViewCursor: public CoreRefCountObject + { + public: + LinearViewCursor(LinearViewObject* root); + LinearViewCursor(BNLinearViewCursor* cursor); + + bool IsBeforeBegin() const; + bool IsAfterEnd() const; + bool IsValid() const; + + Ref GetCurrentObject() const; + std::vector GetPath() const; + std::vector> GetPathObjects() const; + BNAddressRange GetOrderingIndex() const; + uint64_t GetOrderingIndexTotal() const; + + void SeekToBegin(); + void SeekToEnd(); + void SeekToAddress(uint64_t addr); + bool SeekToPath(const std::vector& path); + bool SeekToPath(const std::vector& path, uint64_t addr); + bool SeekToPath(LinearViewCursor* cursor); + bool SeekToPath(LinearViewCursor* cursor, uint64_t addr); + void SeekToOrderingIndex(uint64_t idx); + bool Next(); + bool Previous(); + + std::vector GetLines(); + + Ref Duplicate(); + + static int Compare(LinearViewCursor* a, LinearViewCursor* b); + }; } -- cgit v1.3.1