diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2022-06-02 14:31:44 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2022-06-02 14:31:44 -0400 |
| commit | 4bb510c2e4456606e03acfc6970bf8697156769e (patch) | |
| tree | 74547a2acd0d5970ea88740b691e7efe6d26ad5a /python | |
| parent | f65fdfc1dad94ffca1d69c6a6599b3c626b2216b (diff) | |
Fix Python exceptions when accessing functions with skipped IL analysis
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 8 | ||||
| -rw-r--r-- | python/function.py | 31 |
2 files changed, 29 insertions, 10 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 9ce51386..cfafffb6 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -2258,7 +2258,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: + yield mlil def hlil_functions( self, preload_limit: Optional[int] = None, function_generator: Generator['_function.Function', None, @@ -2271,7 +2273,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: + yield hlil @property def has_functions(self) -> bool: diff --git a/python/function.py b/python/function.py index fc9ec860..2ebc5a0c 100644 --- a/python/function.py +++ b/python/function.py @@ -846,12 +846,15 @@ class Function: @property def low_level_il(self) -> 'lowlevelil.LowLevelILFunction': """returns LowLevelILFunction used to represent Function low level IL (read-only)""" - return lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLowLevelIL(self.handle), self) + return self.llil @property def llil(self) -> 'lowlevelil.LowLevelILFunction': """returns LowLevelILFunction used to represent Function low level IL (read-only)""" - return lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLowLevelIL(self.handle), self) + result = core.BNGetFunctionLowLevelIL(self.handle) + if not result: + return None + return lowlevelil.LowLevelILFunction(self.arch, result, self) @property def llil_if_available(self) -> Optional['lowlevelil.LowLevelILFunction']: @@ -864,7 +867,10 @@ class Function: @property def lifted_il(self) -> 'lowlevelil.LowLevelILFunction': """returns LowLevelILFunction used to represent lifted IL (read-only)""" - return lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLiftedIL(self.handle), self) + result = core.BNGetFunctionLiftedIL(self.handle) + if not result: + return None + return lowlevelil.LowLevelILFunction(self.arch, result, self) @property def lifted_il_if_available(self) -> Optional['lowlevelil.LowLevelILFunction']: @@ -877,12 +883,15 @@ class Function: @property def medium_level_il(self) -> 'mediumlevelil.MediumLevelILFunction': """Function medium level IL (read-only)""" - return mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelIL(self.handle), self) + return self.mlil @property def mlil(self) -> 'mediumlevelil.MediumLevelILFunction': """Function medium level IL (read-only)""" - return mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelIL(self.handle), self) + result = core.BNGetFunctionMediumLevelIL(self.handle) + if not result: + return None + return mediumlevelil.MediumLevelILFunction(self.arch, result, self) @property def mlil_if_available(self) -> Optional['mediumlevelil.MediumLevelILFunction']: @@ -895,7 +904,10 @@ class Function: @property def mmlil(self) -> 'mediumlevelil.MediumLevelILFunction': """Function mapped medium level IL (read-only)""" - return mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMappedMediumLevelIL(self.handle), self) + result = core.BNGetFunctionMappedMediumLevelIL(self.handle) + if not result: + return None + return mediumlevelil.MediumLevelILFunction(self.arch, result, self) @property def mapped_medium_level_il(self) -> 'mediumlevelil.MediumLevelILFunction': @@ -913,12 +925,15 @@ class Function: @property def high_level_il(self) -> 'highlevelil.HighLevelILFunction': """Function high level IL (read-only)""" - return highlevelil.HighLevelILFunction(self.arch, core.BNGetFunctionHighLevelIL(self.handle), self) + return self.hlil @property def hlil(self) -> 'highlevelil.HighLevelILFunction': """Function high level IL (read-only)""" - return highlevelil.HighLevelILFunction(self.arch, core.BNGetFunctionHighLevelIL(self.handle), self) + result = core.BNGetFunctionHighLevelIL(self.handle) + if not result: + return None + return highlevelil.HighLevelILFunction(self.arch, result, self) @property def hlil_if_available(self) -> Optional['highlevelil.HighLevelILFunction']: |
