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,
)
| 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 | /// |
nothing calls this directly
no test coverage detected