From 2c75c418ea472fca237df5b8f80e47c9cbe35467 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Mon, 1 Nov 2021 23:17:40 -0400 Subject: Adds MediumLevelILFunction.aliased_vars, HighLevelILFunction.aliased_vars, and the respective C and C++ functions; Addressed the API side of #2662 --- python/highlevelil.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'python/highlevelil.py') diff --git a/python/highlevelil.py b/python/highlevelil.py index a09da6f2..575fe025 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -2374,7 +2374,7 @@ class HighLevelILFunction: @property def vars(self) -> List["variable.Variable"]: - """This gets just the HLIL variables - you may be interested in the union of `HighLevelIlFunction.source_function.param_vars` for all the variables used in the function""" + """This gets just the HLIL variables - you may be interested in the union of `HighLevelIlFunction.source_function.param_vars` and `HighLevelIlFunction.aliased_vars` as well for all the variables used in the function""" if self.source_function is None: return [] @@ -2391,9 +2391,28 @@ class HighLevelILFunction: core.BNFreeVariableList(core_variables) return [] + @property + def aliased_vars(self) -> List["variable.Variable"]: + """This returns a list of Variables that are taken reference to and used elsewhere. You may also wish to consider `HighLevelIlFunction.vars` and `HighLevelIlFunction.source_function.param_vars`""" + if self.source_function is None: + return [] + + if self.il_form in [FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph]: + count = ctypes.c_ulonglong() + core_variables = core.BNGetHighLevelILAliasedVariables(self.handle, count) + assert core_variables is not None, "core.BNGetHighLevelILAliasedVariables returned None" + try: + result = [] + for var_i in range(count.value): + result.append(variable.Variable(self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage)) + return result + finally: + core.BNFreeVariableList(core_variables) + return [] + @property def ssa_vars(self) -> List["mediumlevelil.SSAVariable"]: - """This gets just the HLIL SSA variables - you may be interested in the union of `HighLevelIlFunction.source_function.param_vars` for all the variables used in the function""" + """This gets just the HLIL SSA variables - you may be interested in the union of `HighLevelIlFunction.source_function.param_vars` and `HighLevelIlFunction.aliased_vars` for all the variables used in the function""" if self.source_function is None: return [] -- cgit v1.3.1