From 78f177679cfacfcfb4f9ff542cb20a04914aed1f Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Fri, 26 Feb 2021 22:07:50 -0500 Subject: Expose Tag::GetId --- binaryninjaapi.h | 1 + binaryninjacore.h | 1 + binaryview.cpp | 9 +++++++++ python/binaryview.py | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 65a79fcd..629f4ea8 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1327,6 +1327,7 @@ __attribute__ ((format (printf, 1, 2))) Tag(BNTag* tag); Tag(Ref type, const std::string& data = ""); + std::string GetId() const; Ref GetType() const; std::string GetData() const; void SetData(const std::string& data); diff --git a/binaryninjacore.h b/binaryninjacore.h index 0f0743fb..65f86aa9 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3738,6 +3738,7 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI BNTag* BNNewTagReference(BNTag* tag); BINARYNINJACOREAPI void BNFreeTag(BNTag* tag); BINARYNINJACOREAPI void BNFreeTagList(BNTag** tags, size_t count); + BINARYNINJACOREAPI char* BNTagGetId(BNTag* tag); BINARYNINJACOREAPI BNTagType* BNTagGetType(BNTag* tag); BINARYNINJACOREAPI char* BNTagGetData(BNTag* tag); BINARYNINJACOREAPI void BNTagSetData(BNTag* tag, const char* data); diff --git a/binaryview.cpp b/binaryview.cpp index 63e73ad1..657a5cd7 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -468,6 +468,15 @@ Tag::Tag(Ref type, const std::string& data) } +std::string Tag::GetId() const +{ + char* id = BNTagGetId(m_object); + std::string result = id; + BNFreeString(id); + return result; +} + + Ref Tag::GetType() const { return new TagType(BNTagGetType(m_object)); diff --git a/python/binaryview.py b/python/binaryview.py index 9dd321c1..29ecced8 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1306,6 +1306,10 @@ class Tag(object): def __hash__(self): return hash(ctypes.addressof(self.handle.contents)) + @property + def id(self): + return core.BNTagGetId(self.handle) + @property def type(self): return TagType(core.BNTagGetType(self.handle)) -- cgit v1.3.1