From 9c570077a562b4c45e80e6d0cf32f00909e8ebd1 Mon Sep 17 00:00:00 2001 From: Stephen Tong Date: Thu, 23 May 2019 18:45:59 -0400 Subject: Redo/Undo support for user-defined xrefs --- binaryninjaapi.h | 1 + binaryninjacore.h | 1 + function.cpp | 7 +++++++ python/function.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 1d22652d..10c64642 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2589,6 +2589,7 @@ namespace BinaryNinja void SetCommentForAddress(uint64_t addr, const std::string& comment); void SetUserXref(uint64_t addr, uint64_t target); + void RemoveUserXref(uint64_t addr, uint64_t target); Ref GetLowLevelIL() const; size_t GetLowLevelILForInstruction(Architecture* arch, uint64_t addr); diff --git a/binaryninjacore.h b/binaryninjacore.h index c1397596..628f53ed 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2529,6 +2529,7 @@ extern "C" BINARYNINJACOREAPI void BNSetCommentForAddress(BNFunction* func, uint64_t addr, const char* comment); BINARYNINJACOREAPI void BNSetUserXref(BNFunction* func, uint64_t addr, uint64_t target); + BINARYNINJACOREAPI void BNRemoveUserXref(BNFunction* func, uint64_t addr, uint64_t target); BINARYNINJACOREAPI BNBasicBlock* BNNewBasicBlockReference(BNBasicBlock* block); BINARYNINJACOREAPI void BNFreeBasicBlock(BNBasicBlock* block); diff --git a/function.cpp b/function.cpp index 7ef0926c..54c91541 100644 --- a/function.cpp +++ b/function.cpp @@ -245,12 +245,19 @@ 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); } +void Function::RemoveUserXref(uint64_t addr, uint64_t target) +{ + BNRemoveUserXref(m_object, addr, target); +} + + Ref Function::GetLowLevelIL() const { return new LowLevelILFunction(BNGetFunctionLowLevelIL(m_object)); diff --git a/python/function.py b/python/function.py index 1aea500d..36d47791 100644 --- a/python/function.py +++ b/python/function.py @@ -1296,6 +1296,9 @@ class Function(object): def set_user_xref(self, addr, target): core.BNSetUserXref(self.handle, addr, target) + def remove_user_xref(self, addr, target): + core.BNRemoveUserXref(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