From 8f0f90294096ed12e099b0572e28b531636e4fd8 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Fri, 25 Jun 2021 18:08:55 -0400 Subject: GetAllTagReferenceTypeCounts for optimized all-counts list --- binaryninjaapi.h | 2 +- binaryninjacore.h | 2 ++ binaryview.cpp | 18 ++++++++++++++++++ ui/taglist.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 629f4ea8..daaff150 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1683,6 +1683,7 @@ __attribute__ ((format (printf, 1, 2))) size_t GetTagReferencesOfTypeCount(Ref tagType); size_t GetAllTagReferencesOfTypeCount(Ref tagType); + std::map, size_t> GetAllTagReferenceTypeCounts(); std::vector GetDataTagReferences(); std::vector> GetDataTags(uint64_t addr); @@ -3290,7 +3291,6 @@ __attribute__ ((format (printf, 1, 2))) std::vector GetAllTagReferences(); std::vector GetTagReferencesOfType(Ref tagType); - size_t GetTagReferencesOfTypeCount(Ref tagType); std::vector GetAddressTagReferences(); std::vector> GetAddressTags(Architecture* arch, uint64_t addr); diff --git a/binaryninjacore.h b/binaryninjacore.h index 65f86aa9..73b072be 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3771,6 +3771,8 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI size_t BNGetTagReferencesOfTypeCount(BNBinaryView* view, BNTagType* tagType); BINARYNINJACOREAPI size_t BNGetAllTagReferencesOfTypeCount(BNBinaryView* view, BNTagType* tagType); + BINARYNINJACOREAPI void BNGetAllTagReferenceTypeCounts(BNBinaryView* view, BNTagType*** tagTypes, size_t** counts, size_t* count); + BINARYNINJACOREAPI void BNFreeTagReferenceTypeCounts(BNTagType** tagTypes, size_t* counts); BINARYNINJACOREAPI BNTagReference* BNGetFunctionAllTagReferences(BNFunction* func, size_t* count); BINARYNINJACOREAPI BNTagReference* BNGetFunctionTagReferencesOfType(BNFunction* func, BNTagType* tagType, size_t* count); diff --git a/binaryview.cpp b/binaryview.cpp index 657a5cd7..b4ed691d 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -2496,6 +2496,24 @@ size_t BinaryView::GetAllTagReferencesOfTypeCount(Ref tagType) } +std::map, size_t> BinaryView::GetAllTagReferenceTypeCounts() +{ + BNTagType** types; + size_t* counts; + size_t count; + BNGetAllTagReferenceTypeCounts(m_object, &types, &counts, &count); + + std::map, size_t> result; + for (size_t i = 0; i < count; i ++) + { + result[new TagType(BNNewTagTypeReference(types[i]))] = counts[i]; + } + + BNFreeTagReferenceTypeCounts(types, counts); + return result; +} + + size_t BinaryView::GetTagReferencesOfTypeCount(Ref tagType) { return BNGetTagReferencesOfTypeCount(m_object, tagType->GetObject()); diff --git a/ui/taglist.h b/ui/taglist.h index bcd27e7f..19d163dd 100644 --- a/ui/taglist.h +++ b/ui/taglist.h @@ -140,6 +140,7 @@ protected: void selectFirstItem() override; void activateFirstItem() override; + virtual void OnAnalysisFunctionUpdated(BinaryNinja::BinaryView* view, BinaryNinja::Function* func) override; virtual void OnTagAdded(BinaryNinja::BinaryView*, const BinaryNinja::TagReference&) override; virtual void OnTagUpdated(BinaryNinja::BinaryView*, const BinaryNinja::TagReference&) override; virtual void OnTagRemoved(BinaryNinja::BinaryView*, const BinaryNinja::TagReference&) override; -- cgit v1.3.1