summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2020-12-23 23:35:48 -0500
committerBrian Potchik <brian@vector35.com>2020-12-23 23:35:48 -0500
commitd27bf51d4b7c2170d00dca7cce97c7526c866868 (patch)
tree8eae0489f07d35127db322e6a70ac5eafab4c363 /python
parent30683cdc2892d7a1a8b6b9070fbbceb8981882a8 (diff)
Add GetLowLevelILInstructionsForAddress API to retrieve all LLIL for an address.
Diffstat (limited to 'python')
-rw-r--r--python/function.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/python/function.py b/python/function.py
index d986fcca..13d73435 100644
--- a/python/function.py
+++ b/python/function.py
@@ -2040,6 +2040,52 @@ class Function(object):
return self.llil[idx]
+ def get_llil_at(self, addr, arch=None):
+ """
+ ``get_llil_at`` gets the LowLevelILInstruction corresponding to the given virtual address
+
+ :param int addr: virtual address of the function to be queried
+ :param Architecture arch: (optional) Architecture for the given function
+ :rtype: LowLevelILInstruction
+ :Example:
+
+ >>> func = bv.functions[0]
+ >>> func.get_llil_at(func.start)
+ <il: push(rbp)>
+ """
+ if arch is None:
+ arch = self.arch
+
+ idx = core.BNGetLowLevelILForInstruction(self.handle, arch.handle, addr)
+
+ if idx == len(self.llil):
+ return None
+
+ return self.llil[idx]
+
+ def get_llils_at(self, addr, arch=None):
+ """
+ ``get_llils_at`` gets the LowLevelILInstruction(s) corresponding to the given virtual address
+
+ :param int addr: virtual address of the function to be queried
+ :param Architecture arch: (optional) Architecture for the given function
+ :rtype: list(LowLevelILInstruction)
+ :Example:
+
+ >>> func = bv.functions[0]
+ >>> func.get_llils_at(func.start)
+ [<il: push(rbp)>]
+ """
+ if arch is None:
+ arch = self.arch
+ count = ctypes.c_ulonglong()
+ instrs = core.BNGetLowLevelILInstructionsForAddress(self.handle, arch.handle, addr, count)
+ result = []
+ for i in range(0, count.value):
+ result.append(self.llil[instrs[i]])
+ core.BNFreeILInstructionList(instrs)
+ return result
+
def get_low_level_il_exits_at(self, addr, arch=None):
if arch is None:
arch = self.arch