summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index d79e2984..07ca7a22 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -2758,6 +2758,25 @@ class MediumLevelILFunction:
def basic_blocks(self) -> 'function.MediumLevelILBasicBlockList':
return function.MediumLevelILBasicBlockList(self)
+ def get_basic_block_at(self, index: int) -> Optional['basicblock.BasicBlock']:
+ """
+ ``get_basic_block_at`` returns the BasicBlock at the given MLIL instruction ``index``.
+
+ :param int index: Index of the MLIL instruction of the BasicBlock to retrieve.
+ :Example:
+ >>> current_il_function.get_basic_block_at(current_il_index)
+ <mlil block: x86@40-60>
+ """
+ block = core.BNGetMediumLevelILBasicBlockForInstruction(self.handle, index)
+ if not block:
+ return None
+
+ view = None
+ if self._source_function is not None:
+ view = self._source_function.view
+
+ return MediumLevelILBasicBlock(block, self, view)
+
@property
def instructions(self) -> Generator[MediumLevelILInstruction, None, None]:
"""A generator of mlil instructions of the current function"""