Changed the path splitting part to the way python's documentation recommends it. I got some errors trying to use that function on windows, because it didn't split correctly. I stumbled upon this in the python documentation: https://docs.python.org/2/library/os.html#os.sep I changed the relevant line using their recommendation. * Rename data to session_data, as this API is per-session and not stored in the db * get_basic_blocks_starting_at incorrectly in the docs * Update troubleshooting.md * Zoom * get_instruction_low_level_il tweak made api docs less ambiguous * documenting Type.int and Type.function * Update __init__.py * Add convenience API's for accessing blocks and instructions in Function
| -rw-r--r-- | python/function.py | 35 |
diff --git a/python/function.py b/python/function.py index 9aafdf52..cbbdf9bd 100644 --- a/python/function.py +++ b/python/function.py @@ -666,6 +666,41 @@ class Function(object): """Sets a comment for the current function""" return core.BNSetFunctionComment(self.handle, comment) + @property + def llil_basic_blocks(self): + """A generator of all LowLevelILBasicBlock objects in the current function""" + for block in self.low_level_il: + yield block + + @property + def mlil_basic_blocks(self): + """A generator of all MediumLevelILBasicBlock objects in the current function""" + for block in self.medium_level_il: + yield block + + @property + def instructions(self): + """A generator of instruction tokens and their start addresses for the current function""" + for block in self.basic_blocks: + start = block.start + for i in block: + yield (i[0], start) + start += i[1] + + @property + def llil_instructions(self): + """A generator of llil instructions of the current function""" + for block in self.llil_basic_blocks: + for i in block: + yield i + + @property + def mlil_instructions(self): + """A generator of mlil instructions of the current function""" + for block in self.mlil_basic_blocks: + for i in block: + yield i + def __iter__(self): count = ctypes.c_ulonglong() blocks = core.BNGetFunctionBasicBlockList(self.handle, count) |