summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2016-10-20 18:28:43 -0400
committerRusty Wagner <rusty@vector35.com>2016-10-20 18:49:02 -0400
commit0ccbd5f5fe3e646ac18ea013bb443a2b5b29b609 (patch)
tree06a6b1ffa8129528411ac3d8fe953bcfa76ee31b
parent254d5aa23c0d114e9a275f60538fcb3b76ac1c69 (diff)
Add associated arch API to Python
-rw-r--r--python/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/python/__init__.py b/python/__init__.py
index 70267678..63916b1f 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -6011,6 +6011,8 @@ class Architecture(object):
self._cb.getDefaultIntegerSize = self._cb.getDefaultIntegerSize.__class__(self._get_default_integer_size)
self._cb.getMaxInstructionLength = self._cb.getMaxInstructionLength.__class__(self._get_max_instruction_length)
self._cb.getOpcodeDisplayLength = self._cb.getOpcodeDisplayLength.__class__(self._get_opcode_display_length)
+ self._cb.getAssociatedArchitectureByAddress = self._cb.getAssociatedArchitectureByAddress.__class__(
+ self._get_associated_arch_by_address)
self._cb.getInstructionInfo = self._cb.getInstructionInfo.__class__(self._get_instruction_info)
self._cb.getInstructionText = self._cb.getInstructionText.__class__(self._get_instruction_text)
self._cb.freeInstructionText = self._cb.freeInstructionText.__class__(self._free_instruction_text)
@@ -6200,6 +6202,15 @@ class Architecture(object):
log_error(traceback.format_exc())
return 8
+ def _get_associated_arch_by_address(self, ctxt, addr):
+ try:
+ result, new_addr = self.perform_get_associated_arch_by_address(addr[0])
+ addr[0] = new_addr
+ return ctypes.cast(result.handle, ctypes.c_void_p).value
+ except:
+ log_error(traceback.format_exc())
+ return ctypes.cast(self.handle, ctypes.c_void_p).value
+
def _get_instruction_info(self, ctxt, data, addr, max_len, result):
try:
buf = ctypes.create_string_buffer(max_len)
@@ -6609,6 +6620,9 @@ class Architecture(object):
log_error(traceback.format_exc())
return False
+ def perform_get_associated_arch_by_address(self, addr):
+ return self, addr
+
@abc.abstractmethod
def perform_get_instruction_info(self, data, addr):
"""
@@ -6859,6 +6873,12 @@ class Architecture(object):
"""
return None
+ def get_associated_arch_by_address(self, addr):
+ new_addr = ctypes.c_ulonglong()
+ new_addr.value = addr
+ result = core.BNGetAssociatedArchitectureByAddress(self.handle, new_addr)
+ return Architecture(handle = result), new_addr.value
+
def get_instruction_info(self, data, addr):
"""
``get_instruction_info`` returns an InstructionInfo object for the instruction at the given virtual address