From 46ea950b5d147e14348806ab8ce6b0265efee06f Mon Sep 17 00:00:00 2001 From: Stephen Tong Date: Thu, 23 May 2019 16:51:03 -0400 Subject: WIP: Support adding user-defined xrefs --- binaryninjaapi.h | 2 ++ binaryninjacore.h | 2 ++ function.cpp | 5 +++++ python/function.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index e9277d65..1d22652d 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2588,6 +2588,8 @@ namespace BinaryNinja void SetComment(const std::string& comment); void SetCommentForAddress(uint64_t addr, const std::string& comment); + void SetUserXref(uint64_t addr, uint64_t target); + Ref GetLowLevelIL() const; size_t GetLowLevelILForInstruction(Architecture* arch, uint64_t addr); std::vector GetLowLevelILExitsForInstruction(Architecture* arch, uint64_t addr); diff --git a/binaryninjacore.h b/binaryninjacore.h index cc707770..c1397596 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2528,6 +2528,8 @@ extern "C" BINARYNINJACOREAPI void BNSetFunctionComment(BNFunction* func, const char* comment); BINARYNINJACOREAPI void BNSetCommentForAddress(BNFunction* func, uint64_t addr, const char* comment); + BINARYNINJACOREAPI void BNSetUserXref(BNFunction* func, uint64_t addr, uint64_t target); + BINARYNINJACOREAPI BNBasicBlock* BNNewBasicBlockReference(BNBasicBlock* block); BINARYNINJACOREAPI void BNFreeBasicBlock(BNBasicBlock* block); BINARYNINJACOREAPI BNBasicBlock** BNGetFunctionBasicBlockList(BNFunction* func, size_t* count); diff --git a/function.cpp b/function.cpp index 5b65be00..7ef0926c 100644 --- a/function.cpp +++ b/function.cpp @@ -245,6 +245,11 @@ void Function::SetCommentForAddress(uint64_t addr, const string& comment) BNSetCommentForAddress(m_object, addr, comment.c_str()); } +void Function::SetUserXref(uint64_t addr, uint64_t target) +{ + BNSetUserXref(m_object, addr, target); +} + Ref Function::GetLowLevelIL() const { diff --git a/python/function.py b/python/function.py index 9d70d5be..1aea500d 100644 --- a/python/function.py +++ b/python/function.py @@ -1293,6 +1293,9 @@ class Function(object): """ core.BNSetCommentForAddress(self.handle, addr, comment) + def set_user_xref(self, addr, target): + core.BNSetUserXref(self.handle, addr, target) + def get_low_level_il_at(self, addr, arch=None): """ ``get_low_level_il_at`` gets the LowLevelILInstruction corresponding to the given virtual address -- cgit v1.3.1