From a719ec03c082ad64dece5dcae8e386bd65879843 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Fri, 25 Jun 2021 18:10:08 -0400 Subject: Give tag types unique ids and stop relying on unique names --- binaryview.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index b4ed691d..139e319c 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -405,6 +405,15 @@ BinaryView* TagType::GetView() const } +std::string TagType::GetId() const +{ + char* str = BNTagTypeGetId(m_object); + string result = str; + BNFreeString(str); + return result; +} + + std::string TagType::GetName() const { char* str = BNTagTypeGetName(m_object); @@ -2392,6 +2401,18 @@ void BinaryView::RemoveTagType(Ref tagType) Ref BinaryView::GetTagType(const std::string& name) +{ + return GetTagTypeByName(name); +} + + +Ref BinaryView::GetTagType(const std::string& name, TagType::Type type) +{ + return GetTagTypeByName(name, type); +} + + +Ref BinaryView::GetTagTypeByName(const std::string& name) { BNTagType* tagType = BNGetTagType(m_object, name.c_str()); if (!tagType) @@ -2401,7 +2422,7 @@ Ref BinaryView::GetTagType(const std::string& name) } -Ref BinaryView::GetTagType(const std::string& name, TagType::Type type) +Ref BinaryView::GetTagTypeByName(const std::string& name, TagType::Type type) { BNTagType* tagType = BNGetTagTypeWithType(m_object, name.c_str(), type); if (!tagType) @@ -2411,6 +2432,26 @@ Ref BinaryView::GetTagType(const std::string& name, TagType::Type type) } +Ref BinaryView::GetTagTypeById(const std::string& name) +{ + BNTagType* tagType = BNGetTagTypeById(m_object, name.c_str()); + if (!tagType) + return nullptr; + + return Ref(new TagType(tagType)); +} + + +Ref BinaryView::GetTagTypeById(const std::string& name, TagType::Type type) +{ + BNTagType* tagType = BNGetTagTypeByIdWithType(m_object, name.c_str(), type); + if (!tagType) + return nullptr; + + return Ref(new TagType(tagType)); +} + + std::vector> BinaryView::GetTagTypes() { size_t count; @@ -2584,7 +2625,7 @@ void BinaryView::RemoveTagReference(const TagReference& ref) Ref BinaryView::CreateAutoDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique) { - Ref tagType = GetTagType(tagTypeName); + Ref tagType = GetTagTypeByName(tagTypeName); if (!tagType) return nullptr; @@ -2594,7 +2635,7 @@ Ref BinaryView::CreateAutoDataTag(uint64_t addr, const std::string& tagType Ref BinaryView::CreateUserDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique) { - Ref tagType = GetTagType(tagTypeName); + Ref tagType = GetTagTypeByName(tagTypeName); if (!tagType) return nullptr; -- cgit v1.3.1