diff options
| author | KyleMiles <krm504@nyu.edu> | 2021-11-01 23:17:40 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2021-11-11 16:16:37 -0500 |
| commit | 2c75c418ea472fca237df5b8f80e47c9cbe35467 (patch) | |
| tree | 57b1967f3105246c2b027cb5294cd9813937e543 /python | |
| parent | 53640fb603ef58baf02bb43746046f9f62603f30 (diff) | |
Adds MediumLevelILFunction.aliased_vars, HighLevelILFunction.aliased_vars, and the respective C and C++ functions; Addressed the API side of #2662
Diffstat (limited to 'python')
| -rw-r--r-- | python/highlevelil.py | 23 | ||||
| -rw-r--r-- | python/mediumlevelil.py | 23 |
2 files changed, 42 insertions, 4 deletions
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 [] @@ -2392,8 +2392,27 @@ class HighLevelILFunction: 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 [] diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index 8f079bfe..0474fcea 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -3019,7 +3019,7 @@ class MediumLevelILFunction: @property def vars(self) -> List['variable.Variable']: - """This gets just the MLIL variables - you may be interested in the union of `MediumLevelIlFunction.source_function.param_vars` for all the variables used in the function""" + """This gets just the MLIL variables - you may be interested in the union of `MediumLevelIlFunction.aliased_vars` and `MediumLevelIlFunction.source_function.param_vars` for all the variables used in the function""" if self.source_function is None: return [] @@ -3037,8 +3037,27 @@ class MediumLevelILFunction: 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 `MediumLevelIlFunction.vars` and `MediumLevelIlFunction.source_function.param_vars`""" + if self.source_function is None: + return [] + + if self.il_form in [FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph]: + count = ctypes.c_ulonglong() + core_variables = core.BNGetMediumLevelILAliasedVariables(self.handle, count) + assert core_variables is not None, "core.BNGetMediumLevelILAliasedVariables 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[SSAVariable]: - """This gets just the MLIL SSA variables - you may be interested in the union of `MediumLevelIlFunction.source_function.param_vars` for all the variables used in the function""" + """This gets just the MLIL SSA variables - you may be interested in the union of `MediumLevelIlFunction.aliased_vars` and `MediumLevelIlFunction.source_function.param_vars` for all the variables used in the function""" if self.source_function is None: return [] |
