diff options
| -rw-r--r-- | python/binaryview.py | 14 | ||||
| -rw-r--r-- | python/function.py | 18 |
2 files changed, 23 insertions, 9 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 466f4e0f..a03cb7bc 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -2998,15 +2998,13 @@ class BinaryView: def mlil_basic_blocks(self) -> Generator['mediumlevelil.MediumLevelILBasicBlock', None, None]: """A generator of all MediumLevelILBasicBlock objects in the BinaryView""" for func in self.mlil_functions(): - if func is not None: - yield from func.basic_blocks + yield from func.basic_blocks @property def hlil_basic_blocks(self) -> Generator['highlevelil.HighLevelILBasicBlock', None, None]: """A generator of all HighLevelILBasicBlock objects in the BinaryView""" for func in self.hlil_functions(): - if func is not None: - yield from func.basic_blocks + yield from func.basic_blocks @property def instructions(self) -> InstructionsType: @@ -3195,7 +3193,9 @@ class BinaryView: for func in AdvancedILFunctionList( self, self.preload_limit if preload_limit is None else preload_limit, function_generator ): - yield func.mlil + mlil = func.mlil + if mlil is not None: + yield mlil def hlil_functions( self, preload_limit: Optional[int] = None, @@ -3208,7 +3208,9 @@ class BinaryView: for func in AdvancedILFunctionList( self, self.preload_limit if preload_limit is None else preload_limit, function_generator ): - yield func.hlil + hlil = func.hlil + if hlil is not None: + yield hlil @property def has_functions(self) -> bool: diff --git a/python/function.py b/python/function.py index cf8bafdd..126892ec 100644 --- a/python/function.py +++ b/python/function.py @@ -1549,13 +1549,21 @@ class Function: @property def llil_basic_blocks(self) -> Generator['lowlevelil.LowLevelILBasicBlock', None, None]: """A generator of all LowLevelILBasicBlock objects in the current function""" - for block in self.llil: + llil = self.llil + if llil is None: + return + + for block in llil: yield block @property def mlil_basic_blocks(self) -> Generator['mediumlevelil.MediumLevelILBasicBlock', None, None]: """A generator of all MediumLevelILBasicBlock objects in the current function""" - for block in self.mlil: + mlil = self.mlil + if mlil is None: + return + + for block in mlil: yield block @property @@ -1883,6 +1891,10 @@ class Function: >>> func.get_llils_at(func.start) [<il: push(rbp)>] """ + llil = self.llil + if llil is None: + return [] + if arch is None: arch = self.arch count = ctypes.c_ulonglong() @@ -1891,7 +1903,7 @@ class Function: try: result = [] for i in range(0, count.value): - result.append(self.llil[instrs[i]]) + result.append(llil[instrs[i]]) return result finally: core.BNFreeILInstructionList(instrs) |
