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

Method set_user_var_value

rust/src/medium_level_il/function.rs:203–228  ·  view source on GitHub ↗

Allows the user to specify a PossibleValueSet value for an MLIL variable at its definition site. .. warning:: Setting the variable value, triggers a reanalysis of the function and allows the dataflow to compute and propagate values which depend on the current variable. This implies that branch conditions whose values can be determined statically will be computed, leading to potential branch elimi

(
        &self,
        var: &Variable,
        addr: u64,
        value: PossibleValueSet,
        after: bool,
    )

Source from the content-addressed store, hash-verified

201 /// .unwrap();
202 /// ```
203 pub fn set_user_var_value(
204 &self,
205 var: &Variable,
206 addr: u64,
207 value: PossibleValueSet,
208 after: bool,
209 ) -> Result<(), ()> {
210 let Some(_def_site) = self
211 .var_definitions(var)
212 .iter()
213 .find(|def| def.address == addr)
214 else {
215 // Error "No definition for Variable found at given address"
216 return Err(());
217 };
218 let function = self.function();
219 let def_site = BNArchitectureAndAddress {
220 arch: function.arch().handle,
221 address: addr,
222 };
223 let raw_var = BNVariable::from(var);
224 let raw_value = PossibleValueSet::into_raw(value);
225 unsafe { BNSetUserVariableValue(function.handle, &raw_var, &def_site, after, &raw_value) }
226 PossibleValueSet::free_owned_raw(raw_value);
227 Ok(())
228 }
229
230 /// Clears a previously defined user variable value.
231 ///

Callers

nothing calls this directly

Calls 5

findMethod · 0.80
var_definitionsMethod · 0.80
iterMethod · 0.45
functionMethod · 0.45
archMethod · 0.45

Tested by

no test coverage detected