Struct binaryninja::mlil::MediumLevelILFunction
source · 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_from_idx(&self, expr_idx: usize) -> MediumLevelILInstruction
pub fn lifted_instruction_from_idx( &self, expr_idx: usize ) -> MediumLevelILLiftedInstruction
pub fn instruction_from_instruction_idx( &self, instr_idx: usize ) -> MediumLevelILInstruction
pub fn lifted_instruction_from_instruction_idx( &self, instr_idx: usize ) -> MediumLevelILLiftedInstruction
pub fn instruction_count(&self) -> usize
pub fn ssa_form(&self) -> MediumLevelILFunction
pub fn get_function(&self) -> Ref<Function>
pub fn basic_blocks(&self) -> Array<BasicBlock<MediumLevelILBlock>>
pub fn get_var_definitions<'a>( &'a self, var: &Variable ) -> MediumLevelILInstructionList<'a> ⓘ
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
) -> Result<(), ()>
pub fn set_user_var_value( &self, var: &Variable, addr: u64, value: PossibleValueSet ) -> 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 (mlil_var, arch_addr, _val) = mlil_fun.user_var_values().all().next().unwrap();
let def_address = arch_addr.address;
let var_value = PossibleValueSet::ConstantValue{value: 5};
mlil_fun.set_user_var_value(&mlil_var, def_address, var_value).unwrap();
sourcepub fn clear_user_var_value(&self, var: &Variable, addr: u64) -> Result<(), ()>
pub fn clear_user_var_value(&self, var: &Variable, addr: u64) -> 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) -> UserVariableValues
pub fn user_var_values(&self) -> UserVariableValues
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 = mlil_fun.var_refs(&mlil_var).get(0).expr();
sourcepub fn var_refs_from(
&self,
addr: u64,
length: Option<u64>,
arch: Option<CoreArchitecture>
) -> Array<VariableReferenceSource>
pub fn var_refs_from( &self, addr: u64, length: Option<u64>, arch: Option<CoreArchitecture> ) -> Array<VariableReferenceSource>
Returns a list of variables referenced by code in the function func
,
of the architecture arch
, and at the address addr
. If no function is specified, references from
all functions and containing the address will be returned. If no architecture is specified, the
architecture of the function will be used.
This function is related to get_hlil_var_refs_from(), 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.
addr
- virtual address to query for variable referenceslength
- optional length of queryarch
- optional architecture of query
sourcepub fn current_address(&self) -> u64
pub fn current_address(&self) -> u64
Current IL Address
sourcepub fn set_current_address(&self, value: u64, arch: Option<CoreArchitecture>)
pub fn set_current_address(&self, value: u64, arch: Option<CoreArchitecture>)
Set the current IL Address
sourcepub fn basic_block_containing(
&self,
instruction: &MediumLevelILInstruction
) -> Option<BasicBlock<MediumLevelILBlock>>
pub fn basic_block_containing( &self, instruction: &MediumLevelILInstruction ) -> Option<BasicBlock<MediumLevelILBlock>>
Returns the BasicBlock at the given MLIL instruction
.
sourcepub fn generate_ssa_form(
&self,
analyze_conditionals: bool,
handle_aliases: bool,
known_not_aliases: impl IntoIterator<Item = Variable>,
known_aliases: impl IntoIterator<Item = Variable>
)
pub fn generate_ssa_form( &self, analyze_conditionals: bool, handle_aliases: bool, known_not_aliases: impl IntoIterator<Item = Variable>, known_aliases: impl IntoIterator<Item = Variable> )
Generate SSA form given the current MLIL
analyze_conditionals
- whether or not to analyze conditionalshandle_aliases
- whether or not to handle aliasesknown_not_aliases
- optional list of variables known to be not aliasedknown_aliases
- optional list of variables known to be aliased
sourcepub fn ssa_variable_definition(
&self,
var: SSAVariable
) -> Option<MediumLevelILInstruction>
pub fn ssa_variable_definition( &self, var: 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_var: SSAVariable
) -> Array<MediumLevelILInstruction>
pub fn ssa_variable_uses( &self, ssa_var: 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_var: SSAVariable) -> bool
pub fn is_ssa_variable_live(&self, ssa_var: SSAVariable) -> bool
determines if ssa_var
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_var: SSAVariable) -> RegisterValue
pub fn create_graph(&self, settings: Option<DisassemblySettings>) -> 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 crate::function::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 crate::function::Function::parameter_variables
sourcepub fn ssa_variables(&self) -> Array<Array<SSAVariable>>
pub fn ssa_variables(&self) -> Array<Array<SSAVariable>>
This gets just the MLIL SSA variables - you may be interested in the union of MediumLevelILFunction::aliased_variables and crate::function::Function::parameter_variables for all the variables used in the function.