summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2021-02-12 13:58:24 -0500
committerBrian Potchik <brian@vector35.com>2021-02-12 13:58:24 -0500
commit902ef4d9ca892e3de23355c3c0fc7b49bf1d9726 (patch)
treec4f028a37c10ff26b235a13959d133284667e4de
parent413eb2a9332c425a57a8ed6e22c71011f22a73df (diff)
Add unresolved control-flow tracking and associated tag support.
-rw-r--r--binaryninjaapi.h3
-rw-r--r--binaryninjacore.h3
-rw-r--r--function.cpp17
-rw-r--r--python/function.py16
4 files changed, 39 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index d7911b96..5be370c0 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -3135,6 +3135,9 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<IndirectBranchInfo> GetIndirectBranches();
std::vector<IndirectBranchInfo> GetIndirectBranchesAt(Architecture* arch, uint64_t addr);
+ std::vector<uint64_t> GetUnresolvedIndirectBranches();
+ bool HasUnresolvedIndirectBranches();
+
void SetAutoCallTypeAdjustment(Architecture* arch, uint64_t addr, const Confidence<Ref<Type>>& adjust);
void SetAutoCallStackAdjustment(Architecture* arch, uint64_t addr, const Confidence<int64_t>& adjust);
void SetAutoCallRegisterStackAdjustment(Architecture* arch, uint64_t addr,
diff --git a/binaryninjacore.h b/binaryninjacore.h
index a857bd79..c64adc23 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -3336,6 +3336,9 @@ __attribute__ ((format (printf, 1, 2)))
uint64_t addr, size_t* count);
BINARYNINJACOREAPI void BNFreeIndirectBranchList(BNIndirectBranchInfo* branches);
+ BINARYNINJACOREAPI uint64_t* BNGetUnresolvedIndirectBranches(BNFunction* func, size_t* count);
+ BINARYNINJACOREAPI bool BNHasUnresolvedIndirectBranches(BNFunction* func);
+
BINARYNINJACOREAPI void BNSetAutoCallTypeAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
BNTypeWithConfidence* type);
BINARYNINJACOREAPI void BNSetUserCallTypeAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
diff --git a/function.cpp b/function.cpp
index 80f55fe6..50799191 100644
--- a/function.cpp
+++ b/function.cpp
@@ -1192,6 +1192,23 @@ vector<IndirectBranchInfo> Function::GetIndirectBranchesAt(Architecture* arch, u
}
+vector<uint64_t> Function::GetUnresolvedIndirectBranches()
+{
+ size_t count;
+ uint64_t* addrs = BNGetUnresolvedIndirectBranches(m_object, &count);
+ vector<uint64_t> result;
+ result.insert(result.end(), addrs, &addrs[count]);
+ BNFreeAddressList(addrs);
+ return result;
+}
+
+
+bool Function::HasUnresolvedIndirectBranches()
+{
+ return BNHasUnresolvedIndirectBranches(m_object);
+}
+
+
void Function::SetAutoCallTypeAdjustment(Architecture* arch, uint64_t addr, const Confidence<Ref<Type>>& adjust)
{
BNTypeWithConfidence apiObject;
diff --git a/python/function.py b/python/function.py
index 53a0ec57..15bbf251 100644
--- a/python/function.py
+++ b/python/function.py
@@ -1660,6 +1660,22 @@ class Function(object):
return result
@property
+ def unresolved_indirect_branches(self):
+ """List of unresolved indirect branches (read-only)"""
+ count = ctypes.c_ulonglong()
+ addrs = core.BNGetUnresolvedIndirectBranches(self.handle, count)
+ result = []
+ for i in range(0, count.value):
+ result.append(addrs[i])
+ core.BNFreeAddressList(addrs)
+ return result
+
+ @property
+ def has_unresolved_indirect_branches(self):
+ """Has unresolved indirect branches (read-only)"""
+ return core.BNHasUnresolvedIndirectBranches(self.handle)
+
+ @property
def session_data(self):
"""Dictionary object where plugins can store arbitrary data associated with the function"""
handle = ctypes.cast(self.handle, ctypes.c_void_p)