diff options
| author | Glenn Smith <glenn@vector35.com> | 2021-06-25 18:10:08 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2021-07-01 01:32:28 -0400 |
| commit | a719ec03c082ad64dece5dcae8e386bd65879843 (patch) | |
| tree | 3df98c553ecd3cf187edec9683c1c9ae280297fd /binaryview.cpp | |
| parent | 8f0f90294096ed12e099b0572e28b531636e4fd8 (diff) | |
Give tag types unique ids and stop relying on unique names
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
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); @@ -2393,6 +2402,18 @@ void BinaryView::RemoveTagType(Ref<TagType> tagType) Ref<TagType> BinaryView::GetTagType(const std::string& name) { + return GetTagTypeByName(name); +} + + +Ref<TagType> BinaryView::GetTagType(const std::string& name, TagType::Type type) +{ + return GetTagTypeByName(name, type); +} + + +Ref<TagType> BinaryView::GetTagTypeByName(const std::string& name) +{ BNTagType* tagType = BNGetTagType(m_object, name.c_str()); if (!tagType) return nullptr; @@ -2401,7 +2422,7 @@ Ref<TagType> BinaryView::GetTagType(const std::string& name) } -Ref<TagType> BinaryView::GetTagType(const std::string& name, TagType::Type type) +Ref<TagType> 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<TagType> BinaryView::GetTagType(const std::string& name, TagType::Type type) } +Ref<TagType> BinaryView::GetTagTypeById(const std::string& name) +{ + BNTagType* tagType = BNGetTagTypeById(m_object, name.c_str()); + if (!tagType) + return nullptr; + + return Ref<TagType>(new TagType(tagType)); +} + + +Ref<TagType> BinaryView::GetTagTypeById(const std::string& name, TagType::Type type) +{ + BNTagType* tagType = BNGetTagTypeByIdWithType(m_object, name.c_str(), type); + if (!tagType) + return nullptr; + + return Ref<TagType>(new TagType(tagType)); +} + + std::vector<Ref<TagType>> BinaryView::GetTagTypes() { size_t count; @@ -2584,7 +2625,7 @@ void BinaryView::RemoveTagReference(const TagReference& ref) Ref<Tag> BinaryView::CreateAutoDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique) { - Ref<TagType> tagType = GetTagType(tagTypeName); + Ref<TagType> tagType = GetTagTypeByName(tagTypeName); if (!tagType) return nullptr; @@ -2594,7 +2635,7 @@ Ref<Tag> BinaryView::CreateAutoDataTag(uint64_t addr, const std::string& tagType Ref<Tag> BinaryView::CreateUserDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique) { - Ref<TagType> tagType = GetTagType(tagTypeName); + Ref<TagType> tagType = GetTagTypeByName(tagTypeName); if (!tagType) return nullptr; |
