@@ -5,12 +5,12 @@ use crate::architecture::{CoreIntrinsic, FlagId, IntrinsicId, RegisterId};
55use crate :: basic_block:: BasicBlock ;
66use crate :: confidence:: Conf ;
77use crate :: disassembly:: InstructionTextToken ;
8- use crate :: operand_iter:: OperandIter ;
98use crate :: rc:: { Array , CoreArrayProvider , CoreArrayProviderInner , Ref } ;
109use crate :: types:: Type ;
1110use crate :: variable:: { ConstantData , PossibleValueSet , RegisterValue , SSAVariable , Variable } ;
1211use crate :: { DataFlowQueryOption , ILBranchDependence } ;
1312use binaryninjacore_sys:: * ;
13+ use std:: collections:: BTreeMap ;
1414use std:: fmt;
1515use std:: fmt:: { Debug , Display , Formatter } ;
1616
@@ -411,6 +411,24 @@ impl MediumLevelILInstruction {
411411 num_params : op. operands [ 3 ] as usize ,
412412 first_param : op. operands [ 4 ] as usize ,
413413 } ) ,
414+ MLIL_CALL_OUTPUT => Op :: CallOutput ( CallOutput {
415+ first_output : op. operands [ 0 ] as usize ,
416+ num_outputs : op. operands [ 1 ] as usize ,
417+ } ) ,
418+ MLIL_CALL_PARAM => Op :: CallParam ( CallParam {
419+ first_param : op. operands [ 0 ] as usize ,
420+ num_params : op. operands [ 1 ] as usize ,
421+ } ) ,
422+ MLIL_CALL_OUTPUT_SSA => Op :: CallOutputSsa ( CallOutputSsa {
423+ dest_memory : op. operands [ 0 ] ,
424+ num_outputs : op. operands [ 1 ] as usize ,
425+ first_output : op. operands [ 2 ] as usize ,
426+ } ) ,
427+ MLIL_CALL_PARAM_SSA => Op :: CallParamSsa ( CallParamSsa {
428+ src_memory : op. operands [ 0 ] ,
429+ num_params : op. operands [ 1 ] as usize ,
430+ first_param : op. operands [ 2 ] as usize ,
431+ } ) ,
414432 MLIL_TAILCALL => Op :: Tailcall ( Call {
415433 num_outputs : op. operands [ 0 ] as usize ,
416434 first_output : op. operands [ 1 ] as usize ,
@@ -438,6 +456,20 @@ impl MediumLevelILInstruction {
438456 num_params : op. operands [ 3 ] as usize ,
439457 first_param : op. operands [ 4 ] as usize ,
440458 } ) ,
459+ MLIL_MEMORY_INTRINSIC_SSA => Op :: MemoryIntrinsicSsa ( MemoryIntrinsicSsa {
460+ output : op. operands [ 0 ] as usize ,
461+ intrinsic : op. operands [ 1 ] as u32 ,
462+ num_params : op. operands [ 2 ] as usize ,
463+ first_param : op. operands [ 3 ] as usize ,
464+ src_memory : op. operands [ 4 ] ,
465+ } ) ,
466+ MLIL_MEMORY_INTRINSIC_OUTPUT_SSA => {
467+ Op :: MemoryIntrinsicOutputSsa ( MemoryIntrinsicOutputSsa {
468+ dest_memory : op. operands [ 0 ] ,
469+ first_output : op. operands [ 1 ] as usize ,
470+ num_outputs : op. operands [ 2 ] as usize ,
471+ } )
472+ }
441473 MLIL_CALL_SSA => Op :: CallSsa ( CallSsa {
442474 output : op. operands [ 0 ] as usize ,
443475 dest : op. operands [ 1 ] as usize ,
@@ -602,14 +634,6 @@ impl MediumLevelILInstruction {
602634 MLIL_TRAP => Op :: Trap ( Trap {
603635 vector : op. operands [ 0 ] ,
604636 } ) ,
605- // translated directly into a list for Expression or Variables
606- // TODO MLIL_MEMORY_INTRINSIC_SSA needs to be handled properly
607- MLIL_CALL_OUTPUT
608- | MLIL_CALL_PARAM
609- | MLIL_CALL_PARAM_SSA
610- | MLIL_CALL_OUTPUT_SSA
611- | MLIL_MEMORY_INTRINSIC_OUTPUT_SSA
612- | MLIL_MEMORY_INTRINSIC_SSA => Op :: NotYetImplemented ,
613637 } ;
614638
615639 Self {
@@ -847,6 +871,21 @@ impl MediumLevelILInstruction {
847871 Rrc ( op) => Lifted :: Rrc ( self . lift_binary_op_carry ( op) ) ,
848872
849873 Call ( op) => Lifted :: Call ( self . lift_call ( op) ) ,
874+ CallOutput ( _op) => Lifted :: CallOutput ( LiftedCallOutput {
875+ output : self . get_var_list ( 0 ) ,
876+ } ) ,
877+ CallParam ( _op) => Lifted :: CallParam ( LiftedCallParam {
878+ params : self . get_expr_list ( 0 ) . iter ( ) . map ( |i| i. lift ( ) ) . collect ( ) ,
879+ } ) ,
880+ CallOutputSsa ( op) => Lifted :: CallOutputSsa ( LiftedCallOutputSsa {
881+ dest_memory : op. dest_memory ,
882+ output : self . get_ssa_var_list ( 1 ) ,
883+ } ) ,
884+ CallParamSsa ( op) => Lifted :: CallParamSsa ( LiftedCallParamSsa {
885+ src_memory : op. src_memory ,
886+ params : self . get_expr_list ( 1 ) . iter ( ) . map ( |i| i. lift ( ) ) . collect ( ) ,
887+ } ) ,
888+
850889 Tailcall ( op) => Lifted :: Tailcall ( self . lift_call ( op) ) ,
851890
852891 Intrinsic ( op) => Lifted :: Intrinsic ( LiftedIntrinsic {
@@ -1672,10 +1711,16 @@ pub enum MediumLevelILInstructionKind {
16721711 Rlc ( BinaryOpCarry ) ,
16731712 Rrc ( BinaryOpCarry ) ,
16741713 Call ( Call ) ,
1714+ CallOutput ( CallOutput ) ,
1715+ CallParam ( CallParam ) ,
1716+ CallOutputSsa ( CallOutputSsa ) ,
1717+ CallParamSsa ( CallParamSsa ) ,
16751718 Tailcall ( Call ) ,
16761719 Syscall ( Syscall ) ,
16771720 Intrinsic ( Intrinsic ) ,
16781721 IntrinsicSsa ( IntrinsicSsa ) ,
1722+ MemoryIntrinsicSsa ( MemoryIntrinsicSsa ) ,
1723+ MemoryIntrinsicOutputSsa ( MemoryIntrinsicOutputSsa ) ,
16791724 CallSsa ( CallSsa ) ,
16801725 TailcallSsa ( CallSsa ) ,
16811726 CallUntypedSsa ( CallUntypedSsa ) ,
0 commit comments