pub struct MediumLevelILFunction { /* private fields */ }
Implementations§
source§impl MediumLevelILFunction
impl MediumLevelILFunction
pub fn instruction_at<L: Into<Location>>( &self, loc: L, ) -> Option<MediumLevelILInstruction>
pub fn instruction_index_at<L: Into<Location>>( &self, loc: L, ) -> Option<MediumLevelInstructionIndex>
pub fn instruction_from_index( &self, index: MediumLevelInstructionIndex, ) -> Option<MediumLevelILInstruction>
pub fn instruction_from_expr_index( &self, expr_index: MediumLevelInstructionIndex, ) -> Option<MediumLevelILInstruction>
pub fn instruction_count(&self) -> usize
pub fn expression_count(&self) -> usize
pub fn ssa_form(&self) -> MediumLevelILFunction
pub fn function(&self) -> Ref<Function>
pub fn basic_blocks(&self) -> Array<BasicBlock<MediumLevelILBlock>>
pub fn var_definitions(&self, var: &Variable) -> Array<MediumLevelILInstruction>
pub fn create_user_stack_var<'a, S: BnStrCompatible, C: Into<Conf<&'a Type>>>( self, offset: i64, var_type: C, name: S, )
pub fn delete_user_stack_var(self, offset: i64)
pub fn create_user_var<'a, S: BnStrCompatible, C: Into<Conf<&'a Type>>>( &self, var: &Variable, var_type: C, name: S, ignore_disjoint_uses: bool, )
pub fn delete_user_var(&self, var: &Variable)
pub fn is_var_user_defined(&self, var: &Variable) -> bool
sourcepub fn set_user_var_value(
&self,
var: &Variable,
addr: u64,
value: PossibleValueSet,
after: bool,
) -> Result<(), ()>
pub fn set_user_var_value( &self, var: &Variable, addr: u64, value: PossibleValueSet, after: bool, ) -> Result<(), ()>
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 elimination at the HLIL layer.
var
- Variable for which the value is to be setaddr
- Address of the definition site of the variablevalue
- Informed value of the variable
§Example
let user_var_val = mlil_fun.user_var_values().iter().next().unwrap();
let def_address = user_var_val.def_site.addr;
let var_value = PossibleValueSet::ConstantValue { value: 5 };
mlil_fun
.set_user_var_value(&user_var_val.variable, def_address, var_value, false)
.unwrap();
sourcepub fn clear_user_var_value(
&self,
var: &Variable,
addr: u64,
after: bool,
) -> Result<(), ()>
pub fn clear_user_var_value( &self, var: &Variable, addr: u64, after: bool, ) -> Result<(), ()>
Clears a previously defined user variable value.
var
- Variable for which the value was informeddef_addr
- Address of the definition site of the variable
sourcepub fn user_var_values(&self) -> Array<UserVariableValue>
pub fn user_var_values(&self) -> Array<UserVariableValue>
Returns a map of current defined user variable values. Returns a Map of user current defined user variable values and their definition sites.
sourcepub fn clear_user_var_values(&self) -> Result<(), ()>
pub fn clear_user_var_values(&self) -> Result<(), ()>
Clear all user defined variable values.
pub fn create_auto_stack_var<'a, T: Into<Conf<&'a Type>>, S: BnStrCompatible>( &self, offset: i64, var_type: T, name: S, )
pub fn delete_auto_stack_var(&self, offset: i64)
pub fn create_auto_var<'a, S: BnStrCompatible, C: Into<Conf<&'a Type>>>( &self, var: &Variable, var_type: C, name: S, ignore_disjoint_uses: bool, )
sourcepub fn var_refs(&self, var: &Variable) -> Array<ILReferenceSource>
pub fn var_refs(&self, var: &Variable) -> Array<ILReferenceSource>
Returns a list of ILReferenceSource objects (IL xrefs or cross-references) that reference the given variable. The variable is a local variable that can be either on the stack, in a register, or in a flag. This function is related to get_hlil_var_refs(), which returns variable references collected from HLIL. The two can be different in several cases, e.g., multiple variables in MLIL can be merged into a single variable in HLIL.
var
- Variable for which to query the xref
§Example
let instr_idx = mlil_fun.var_refs(&mlil_var).get(0).expr_idx;
sourcepub fn var_refs_from(
&self,
location: impl Into<Location>,
length: Option<u64>,
) -> Array<VariableReferenceSource>
pub fn var_refs_from( &self, location: impl Into<Location>, length: Option<u64>, ) -> Array<VariableReferenceSource>
Retrieves variable references from a specified location or range within a medium-level IL function.
Passing in a length
will query a range for variable references, instead of just the address
specified in location
.
sourcepub fn current_address(&self) -> Location
pub fn current_address(&self) -> Location
Current IL Address
sourcepub fn set_current_address(&self, location: impl Into<Location>)
pub fn set_current_address(&self, location: impl Into<Location>)
Set the current IL Address
sourcepub fn basic_block_containing_index(
&self,
index: MediumLevelInstructionIndex,
) -> Option<Ref<BasicBlock<MediumLevelILBlock>>>
pub fn basic_block_containing_index( &self, index: MediumLevelInstructionIndex, ) -> Option<Ref<BasicBlock<MediumLevelILBlock>>>
Returns the BasicBlock
at the given instruction index
.
You can also retrieve this using MediumLevelILInstruction::basic_block
.
sourcepub fn finalize(&self)
pub fn finalize(&self)
Ends the function and computes the list of basic blocks.
NOTE: This should be called after updating MLIL.
sourcepub fn generate_ssa_form(
&self,
analyze_conditionals: bool,
handle_aliases: bool,
non_aliased_vars: impl IntoIterator<Item = Variable>,
aliased_vars: impl IntoIterator<Item = Variable>,
)
pub fn generate_ssa_form( &self, analyze_conditionals: bool, handle_aliases: bool, non_aliased_vars: impl IntoIterator<Item = Variable>, aliased_vars: impl IntoIterator<Item = Variable>, )
Generate SSA form given the current MLIL.
NOTE: This should be called after updating MLIL.
analyze_conditionals
- whether to analyze conditionalshandle_aliases
- whether to handle aliasesnon_aliased_vars
- optional list of variables known to be not aliasedaliased_vars
- optional list of variables known to be aliased
sourcepub fn ssa_variable_definition(
&self,
ssa_variable: &SSAVariable,
) -> Option<MediumLevelILInstruction>
pub fn ssa_variable_definition( &self, ssa_variable: &SSAVariable, ) -> Option<MediumLevelILInstruction>
Gets the instruction that contains the given SSA variable’s definition.
Since SSA variables can only be defined once, this will return the single instruction where that occurs.
For SSA variable version 0s, which don’t have definitions, this will return None
instead.
pub fn ssa_memory_definition( &self, version: usize, ) -> Option<MediumLevelILInstruction>
sourcepub fn ssa_variable_uses(
&self,
ssa_variable: &SSAVariable,
) -> Array<MediumLevelILInstruction>
pub fn ssa_variable_uses( &self, ssa_variable: &SSAVariable, ) -> Array<MediumLevelILInstruction>
Gets all the instructions that use the given SSA variable.
pub fn ssa_memory_uses(&self, version: usize) -> Array<MediumLevelILInstruction>
sourcepub fn is_ssa_variable_live(&self, ssa_variable: &SSAVariable) -> bool
pub fn is_ssa_variable_live(&self, ssa_variable: &SSAVariable) -> bool
Determines if variable
is live at any point in the function
pub fn variable_definitions( &self, variable: &Variable, ) -> Array<MediumLevelILInstruction>
pub fn variable_uses( &self, variable: &Variable, ) -> Array<MediumLevelILInstruction>
sourcepub fn live_instruction_for_variable(
&self,
variable: &Variable,
include_last_user: bool,
) -> Array<MediumLevelILInstruction>
pub fn live_instruction_for_variable( &self, variable: &Variable, include_last_user: bool, ) -> Array<MediumLevelILInstruction>
Computes the list of instructions for which var
is live.
If include_last_use
is false, the last use of the variable will not be included in the
list (this allows for easier computation of overlaps in liveness between two variables).
If the variable is never used, this function will return an empty list.
var
- the variable to query
include_last_use
- whether to include the last use of the variable in the list of instructions
pub fn ssa_variable_value(&self, ssa_variable: &SSAVariable) -> RegisterValue
pub fn create_graph( &self, settings: Option<DisassemblySettings>, ) -> Ref<FlowGraph>
sourcepub fn variables(&self) -> Array<Variable>
pub fn variables(&self) -> Array<Variable>
This gets just the MLIL variables - you may be interested in the union
of MediumLevelILFunction::aliased_variables
and Function::parameter_variables
for
all the variables used in the function
sourcepub fn aliased_variables(&self) -> Array<Variable>
pub fn aliased_variables(&self) -> Array<Variable>
This returns a list of Variables that are taken reference to and used
elsewhere. You may also wish to consider MediumLevelILFunction::variables
and Function::parameter_variables
sourcepub fn ssa_variables(&self, variable: &Variable) -> Array<SSAVariable>
pub fn ssa_variables(&self, variable: &Variable) -> Array<SSAVariable>
This gets the MLIL SSA variables for a given Variable
.