summaryrefslogtreecommitdiff
path: root/binaryview.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2025-07-11 17:55:04 -0400
committerRusty Wagner <rusty.wagner@gmail.com>2025-07-15 13:55:33 -0400
commit6894a946b1fa5ad24e64d24bb7f606bae14c300a (patch)
tree1caa51b5e5ddab129462dc245c70377aedd800ae /binaryview.cpp
parente83374c78ccb8f7351fa3fdbaa0cbb099281898d (diff)
Add API to get all type references at the same time to avoid duplicating work
Diffstat (limited to 'binaryview.cpp')
-rw-r--r--binaryview.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/binaryview.cpp b/binaryview.cpp
index f2e72930..665228c1 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -2685,6 +2685,41 @@ vector<TypeReferenceSource> BinaryView::GetTypeReferencesForTypeField(const Qual
}
+AllTypeReferences BinaryView::GetAllReferencesForType(const QualifiedName& type)
+{
+ BNQualifiedName nameObj = type.GetAPIObject();
+ BNAllTypeReferences refs = BNGetAllReferencesForType(m_object, &nameObj);
+ QualifiedName::FreeAPIObject(&nameObj);
+
+ AllTypeReferences result;
+
+ result.codeRefs.reserve(refs.codeRefCount);
+ for (size_t i = 0; i < refs.codeRefCount; i++)
+ {
+ ReferenceSource src;
+ src.func = new Function(BNNewFunctionReference(refs.codeRefs[i].func));
+ src.arch = new CoreArchitecture(refs.codeRefs[i].arch);
+ src.addr = refs.codeRefs[i].addr;
+ result.codeRefs.push_back(src);
+ }
+
+ result.dataRefs = vector<uint64_t>(refs.dataRefs, &refs.dataRefs[refs.dataRefCount]);
+
+ result.typeRefs.reserve(refs.typeRefCount);
+ for (size_t i = 0; i < refs.typeRefCount; i++)
+ {
+ TypeReferenceSource src;
+ src.name = QualifiedName::FromAPIObject(&refs.typeRefs[i].name);
+ src.offset = refs.typeRefs[i].offset;
+ src.type = refs.typeRefs[i].type;
+ result.typeRefs.push_back(src);
+ }
+
+ BNFreeAllTypeReferences(&refs);
+ return result;
+}
+
+
AllTypeFieldReferences BinaryView::GetAllReferencesForTypeField(const QualifiedName& type, uint64_t offset)
{
BNQualifiedName nameObj = type.GetAPIObject();