From c36c2f555fae8b5a707193e8d5a0d0a0697e9451 Mon Sep 17 00:00:00 2001 From: Jon Palmisciano Date: Wed, 2 Jun 2021 16:38:01 -0400 Subject: Function: Added `BNGetFunctionILVariables()` / `get_il_vars()` method --- python/function.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'python/function.py') diff --git a/python/function.py b/python/function.py index 0ec6142d..b350046f 100644 --- a/python/function.py +++ b/python/function.py @@ -25,6 +25,7 @@ import traceback import ctypes import numbers import string +from typing import List # Binary Ninja components import binaryninja @@ -1934,6 +1935,23 @@ class Function(object): core.BNFreeVariableNameAndTypeList(v, count.value) return result + def get_il_vars(self, il_type: FunctionGraphType) -> List[Variable]: + """ + Get a (read-only) list of the variables used in the given IL. Only + accepts ``MediumLevelILFunctionGraph`` or ``HighLevelILFunctionGraph`` + for ``il_type``, otherwise nothing will be returned. + """ + + count = ctypes.c_ulonglong() + v = core.BNGetFunctionILVariables(self.handle, il_type, count) + + result = [] + for i in range(0, count.value): + result.append(Variable(self, v[i].type, v[i].index, v[i].storage)) + + core.BNFreeVariableList(v, count.value) + return result + @property def indirect_branches(self): """List of indirect branches (read-only)""" -- cgit v1.3.1