MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / clear_user_var_value

Method clear_user_var_value

python/function.py:2951–2982  ·  view source on GitHub ↗

Clears a previously defined user variable value. :param Variable var: Variable for which the value was informed :param int def_addr: Address of the definition site of the variable :rtype: None

(self, var: 'variable.Variable', def_addr: int, after: bool = True)

Source from the content-addressed store, hash-verified

2949 core.BNSetUserVariableValue(self.handle, var.to_BNVariable(), def_site, after, value._to_core_struct())
2950
2951 def clear_user_var_value(self, var: 'variable.Variable', def_addr: int, after: bool = True) -> None:
2952 """
2953 Clears a previously defined user variable value.
2954
2955 :param Variable var: Variable for which the value was informed
2956 :param int def_addr: Address of the definition site of the variable
2957 :rtype: None
2958 """
2959 if var.index == 0:
2960 # Special case: function parameters have index 0 and are defined at the start of the function
2961 def_addr = self.start
2962 else:
2963 func_mlil = self.mlil
2964 if func_mlil is None:
2965 raise ValueError("Could not get definition for Variable")
2966
2967 var_defs = func_mlil.get_var_definitions(var)
2968 if var_defs is None:
2969 raise ValueError("Could not get definition for Variable")
2970
2971 found = False
2972 for site in var_defs:
2973 if site.address == def_addr:
2974 found = True
2975 break
2976 if not found:
2977 raise ValueError("No definition for Variable found at given address")
2978 def_site = core.BNArchitectureAndAddress()
2979 def_site.arch = self.arch.handle
2980 def_site.address = def_addr
2981
2982 core.BNClearUserVariableValue(self.handle, var.to_BNVariable(), def_site, after)
2983
2984 def get_all_user_var_values(
2985 self

Callers 1

Calls 2

to_BNVariableMethod · 0.80
get_var_definitionsMethod · 0.45

Tested by

no test coverage detected