def get_ssa_var_version(self, var): var_data = core.BNVariable() var_data.type = var.source_type var_data.index = var.index var_data.storage = var.storage return core.BNGetHighLevelILSSAVarVersionAtILInstruction( self._function.handle, var_data, self._instr_index)
def perform_get_parameter_var_for_incoming_var(self, in_var, func): in_buf = core.BNVariable() in_buf.type = in_var.source_type in_buf.index = in_var.index in_buf.storage = in_var.storage out_var = core.BNGetDefaultParameterVariableForIncomingVariable(self.handle, in_buf) return binaryninja.function.Variable(func, out_var.type, out_var.index, out_var.storage)
def get_ssa_var_value(self, ssa_var): var_data = core.BNVariable() var_data.type = ssa_var.var.source_type var_data.index = ssa_var.var.index var_data.storage = ssa_var.var.storage value = core.BNGetMediumLevelILSSAVarValue(self.handle, var_data, ssa_var.version) result = function.RegisterValue(self.arch, value) return result
def get_ssa_var_definition(self, ssa_var): var_data = core.BNVariable() var_data.type = ssa_var.var.source_type var_data.index = ssa_var.var.index var_data.storage = ssa_var.var.storage result = core.BNGetHighLevelILSSAVarDefinition(self.handle, var_data, ssa_var.version) if result >= core.BNGetHighLevelILExprCount(self.handle): return None return HighLevelILInstruction(self, result)
def get_ssa_var_possible_values(self, ssa_var): var_data = core.BNVariable() var_data.type = ssa_var.var.source_type var_data.index = ssa_var.var.index var_data.storage = ssa_var.var.storage value = core.BNGetMediumLevelILPossibleSSAVarValues(self.function.handle, var_data, ssa_var.version, self.instr_index) result = function.PossibleValueSet(self.function.arch, value) core.BNFreePossibleValueSet(value) return result
def perform_get_incoming_var_for_parameter_var(self, in_var, func): in_buf = core.BNVariable() in_buf.type = in_var.source_type in_buf.index = in_var.index in_buf.storage = in_var.storage out_var = core.BNGetDefaultIncomingVariableForParameterVariable(self.handle, in_buf) name = None if (func is not None) and (out_var.type == VariableSourceType.RegisterVariableSourceType): name = func.arch.get_reg_name(out_var.storage) return binaryninja.function.Variable(func, out_var.type, out_var.index, out_var.storage, name)
def get_parameter_var_for_incoming_var(self, in_var, func): in_buf = core.BNVariable() in_buf.type = in_var.source_type in_buf.index = in_var.index in_buf.storage = in_var.storage if func is None: func_obj = None else: func_obj = func.handle out_var = core.BNGetParameterVariableForIncomingVariable(self.handle, in_buf, func_obj) return binaryninja.function.Variable(func, out_var.type, out_var.index, out_var.storage)
def get_var_uses(self, var): count = ctypes.c_ulonglong() var_data = core.BNVariable() var_data.type = var.source_type var_data.index = var.index var_data.storage = var.storage instrs = core.BNGetHighLevelILVariableUses(self.handle, var_data, count) result = [] for i in range(0, count.value): result.append(HighLevelILInstruction(self, instrs[i])) core.BNFreeILInstructionList(instrs) return result
def get_ssa_var_uses(self, ssa_var): count = ctypes.c_ulonglong() var_data = core.BNVariable() var_data.type = ssa_var.var.source_type var_data.index = ssa_var.var.index var_data.storage = ssa_var.var.storage instrs = core.BNGetMediumLevelILSSAVarUses(self.handle, var_data, ssa_var.version, count) result = [] for i in range(0, count.value): result.append(instrs[i]) core.BNFreeILInstructionList(instrs) return result
def is_ssa_var_live(self, ssa_var): """ ``is_ssa_var_live`` determines if ``ssa_var`` is live at any point in the function :param SSAVariable ssa_var: the SSA variable to query :return: whether the variable is live at any point in the function :rtype: bool """ var_data = core.BNVariable() var_data.type = ssa_var.var.source_type var_data.index = ssa_var.var.index var_data.storage = ssa_var.var.storage return core.BNIsHighLevelILSSAVarLive(self.handle, var_data, ssa_var.version)