From b26a85dda211a0f1f00eecc37441e1725c5ef898 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Mon, 30 Jun 2025 10:31:08 -0400 Subject: Expose Add/RemoveDataReference and ensure BinaryViews use this API instead of the _user_ variant --- python/binaryview.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index 16c2dbfb..da2423ac 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -5735,6 +5735,33 @@ class BinaryView: core.BNFreeTypeReferences(refs, count.value) return result + def add_data_ref(self, from_addr: int, to_addr: int) -> None: + """ + ``add_data_ref`` adds an auto data cross-reference (xref) from the address ``from_addr`` to the address ``to_addr``. + + :param int from_addr: the reference's source virtual address. + :param int to_addr: the reference's destination virtual address. + :rtype: None + + .. note:: It is intended to be used from within workflows or binary view initialization. + """ + core.BNAddUserDataReference(self.handle, from_addr, to_addr) + + def remove_data_ref(self, from_addr: int, to_addr: int) -> None: + """ + ``remove_data_ref`` removes an auto data cross-reference (xref) from the address ``from_addr`` to the address ``to_addr``. + This function will only remove ones generated during autoanalysis. + If the reference does not exist, no action is performed. + + :param int from_addr: the reference's source virtual address. + :param int to_addr: the reference's destination virtual address. + :rtype: None + + .. note:: It is intended to be used from within workflows or other reoccurring analysis tasks. Removed \ + references will be re-created whenever auto analysis is re-run for the + """ + core.BNRemoveDataReference(self.handle, from_addr, to_addr) + def add_user_data_ref(self, from_addr: int, to_addr: int) -> None: """ ``add_user_data_ref`` adds a user-specified data cross-reference (xref) from the address ``from_addr`` to the address ``to_addr``. -- cgit v1.3.1