From 9ca13512527ca62effce85bfcd9c41b8ed9cb86c Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Tue, 21 May 2024 13:25:03 -0300 Subject: Implement python MLIL related functions add `MediumLevelILInstruction::tokens` add `MediumLevelILInstruction::value` add `MediumLevelILInstruction::possible_values` add `MediumLevelILInstruction::branch_dependence` add `MediumLevelILInstruction::ssa_memory_version` add `MediumLevelILInstruction::expr_type` add `MediumLevelILInstruction::possible_values_with_options` add `MediumLevelILInstruction::possible_ssa_variable_values` add `MediumLevelILInstruction::ssa_variable_version` add `MediumLevelILInstruction::variable_for_register` add `MediumLevelILInstruction::variable_for_flag` add `MediumLevelILInstruction::variable_for_stack_location` add `MediumLevelILInstruction::register_value` add `MediumLevelILInstruction::register_value_after` add `MediumLevelILInstruction::possible_register_values` add `MediumLevelILInstruction::possible_register_values_after` add `MediumLevelILInstruction::flag_value` add `MediumLevelILInstruction::flag_value_after` add `MediumLevelILInstruction::possible_flag_values` add `MediumLevelILInstruction::possible_flag_values_after` add `MediumLevelILInstruction::stack_contents` add `MediumLevelILInstruction::stack_contents_after` add `MediumLevelILInstruction::possible_stack_contents` add `MediumLevelILInstruction::possible_stack_contents_after` add `MediumLevelILInstruction::branch_dependence_at` add `MediumLevelILInstruction::split_var_for_definition` move functions add `MediumLevelILFunction::current_address` add `MediumLevelILFunction::set_current_address` add `MediumLevelILFunction::basic_block_containing` add `MediumLevelILFunction::finalize` add `MediumLevelILFunction::generate_ssa_form` add `MediumLevelILFunction::ssa_variable_definition` add `MediumLevelILFunction::ssa_memory_definition` add `MediumLevelILFunction::ssa_variable_uses` add `MediumLevelILFunction::ssa_memory_uses` add `MediumLevelILFunction::is_ssa_variable_live` add `MediumLevelILFunction::variable_definitions` add `MediumLevelILFunction::variable_uses` add `MediumLevelILFunction::live_instruction_for_variable` add `MediumLevelILFunction::ssa_variable_value` add `MediumLevelILFunction::create_graph` add `MediumLevelILFunction::variables` add `MediumLevelILFunction::aliased_variables` add `MediumLevelILFunction::ssa_variables` add `MediumLevelILInstruction::set_expr_type` fix `MediumLevelILInstruction::generate_ssa_form` redundant type --- rust/src/types.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'rust/src/types.rs') diff --git a/rust/src/types.rs b/rust/src/types.rs index 7adc449e..29cdb2d3 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -24,6 +24,7 @@ use crate::{ callingconvention::CallingConvention, filemetadata::FileMetadata, function::Function, + mlil::MediumLevelILFunction, rc::*, string::{raw_to_string, BnStrCompatible, BnString}, symbol::Symbol, @@ -51,6 +52,8 @@ pub type TypeClass = BNTypeClass; pub type NamedTypeReferenceClass = BNNamedTypeReferenceClass; pub type MemberAccess = BNMemberAccess; pub type MemberScope = BNMemberScope; +pub type ILBranchDependence = BNILBranchDependence; +pub type DataFlowQueryOption = BNDataFlowQueryOption; //////////////// // Confidence @@ -1442,6 +1445,41 @@ impl SSAVariable { } } +impl CoreArrayProvider for SSAVariable { + type Raw = usize; + type Context = Variable; + type Wrapped<'a> = Self; +} + +unsafe impl CoreArrayProviderInner for SSAVariable { + unsafe fn free(raw: *mut Self::Raw, _count: usize, _context: &Self::Context) { + BNFreeILInstructionList(raw) + } + + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { + SSAVariable::new(*context, *raw) + } +} + +impl CoreArrayProvider for Array { + type Raw = BNVariable; + type Context = Ref; + type Wrapped<'a> = Self; +} + +unsafe impl CoreArrayProviderInner for Array { + unsafe fn free(raw: *mut Self::Raw, _count: usize, _context: &Self::Context) { + BNFreeVariableList(raw) + } + + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { + let mut count = 0; + let versions = + unsafe { BNGetMediumLevelILVariableSSAVersions(context.handle, raw, &mut count) }; + Array::new(versions, count, Variable::from_raw(*raw)) + } +} + /////////////// // NamedVariable -- cgit v1.3.1