mediumlevelil module

binaryninja.mediumlevelil.MediumLevelILBasicBlock(…)
binaryninja.mediumlevelil.MediumLevelILExpr(index) class MediumLevelILExpr hold the index of IL Expressions.
binaryninja.mediumlevelil.MediumLevelILFunction(arch) class MediumLevelILFunction contains the list of MediumLevelILExpr objects that make up a function. MediumLevelILExpr
binaryninja.mediumlevelil.MediumLevelILInstruction(…) class MediumLevelILInstruction Medium Level Intermediate Language Instructions are infinite length tree-based
binaryninja.mediumlevelil.MediumLevelILLabel([…])
binaryninja.mediumlevelil.MediumLevelILOperationAndSize(…)
binaryninja.mediumlevelil.SSAVariable(var, …)
class binaryninja.mediumlevelil.MediumLevelILBasicBlock(view, handle, owner)[source]

Bases: binaryninja.basicblock.BasicBlock

class binaryninja.mediumlevelil.MediumLevelILExpr(index)[source]

Bases: object

class MediumLevelILExpr hold the index of IL Expressions.

Note

This class shouldn’t be instantiated directly. Rather the helper members of MediumLevelILFunction should be used instead.

class binaryninja.mediumlevelil.MediumLevelILFunction(arch, handle=None, source_func=None)[source]

Bases: object

class MediumLevelILFunction contains the list of MediumLevelILExpr objects that make up a function. MediumLevelILExpr objects can be added to the MediumLevelILFunction by calling append and passing the result of the various class methods which return MediumLevelILExpr objects.

add_label_list(labels)[source]

add_label_list returns a label list expression for the given list of MediumLevelILLabel objects.

Parameters:lables (list(MediumLevelILLabel)) – the list of MediumLevelILLabel to get a label list expression from
Returns:the label list expression
Return type:MediumLevelILExpr
add_operand_list(operands)[source]

add_operand_list returns an operand list expression for the given list of integer operands.

Parameters:operands (list(int)) – list of operand numbers
Returns:an operand list expression
Return type:MediumLevelILExpr
append(expr)[source]

append adds the MediumLevelILExpr expr to the current MediumLevelILFunction.

Parameters:expr (MediumLevelILExpr) – the MediumLevelILExpr to add to the current MediumLevelILFunction
Returns:number of MediumLevelILExpr in the current function
Return type:int
basic_blocks

list of MediumLevelILBasicBlock objects (read-only)

current_address

Current IL Address (read/write)

expr(operation, a=0, b=0, c=0, d=0, e=0, size=0)[source]
finalize()[source]

finalize ends the function and computes the list of basic blocks.

Return type:None
get_instruction_start(addr, arch=None)[source]
get_low_level_il_expr_index(expr)[source]
get_low_level_il_instruction_index(instr)[source]
get_non_ssa_instruction_index(instr)[source]
get_ssa_instruction_index(instr)[source]
get_ssa_memory_definition(version)[source]
get_ssa_memory_uses(version)[source]
get_ssa_var_definition(ssa_var)[source]
get_ssa_var_uses(ssa_var)[source]
get_ssa_var_value(ssa_var)[source]
get_var_definitions(var)[source]
get_var_uses(var)[source]
goto(label)[source]

goto returns a goto expression which jumps to the provided MediumLevelILLabel.

Parameters:label (MediumLevelILLabel) – Label to jump to
Returns:the MediumLevelILExpr that jumps to the provided label
Return type:MediumLevelILExpr
if_expr(operand, t, f)[source]

if_expr returns the if expression which depending on condition operand jumps to the MediumLevelILLabel t when the condition expression operand is non-zero and f when it’s zero.

Parameters:
Returns:

the MediumLevelILExpr for the if expression

Return type:

MediumLevelILExpr

low_level_il

Low level IL for this function

mark_label(label)[source]

mark_label assigns a MediumLevelILLabel to the current IL address.

Parameters:label (MediumLevelILLabel) –
Return type:None
non_ssa_form

Medium level IL in non-SSA (default) form (read-only)

operand(n, expr)[source]

operand sets the operand number of the expression expr and passes back expr without modification.

Parameters:
Returns:

returns the expression expr unmodified

Return type:

MediumLevelILExpr

set_current_address(value, arch=None)[source]
ssa_form

Medium level IL in SSA form (read-only)

class binaryninja.mediumlevelil.MediumLevelILInstruction(func, expr_index, instr_index=None)[source]

Bases: object

class MediumLevelILInstruction Medium Level Intermediate Language Instructions are infinite length tree-based instructions. Tree-based instructions use infix notation with the left hand operand being the destination operand. Infix notation is thus more natural to read than other notations (e.g. x86 mov eax, 0 vs. MLIL eax = 0).

ILOperations = {<MediumLevelILOperation.MLIL_NOP: 0>: [], <MediumLevelILOperation.MLIL_SET_VAR: 1>: [('dest', 'var'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_FIELD: 2>: [('dest', 'var'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SPLIT: 3>: [('high', 'var'), ('low', 'var'), ('src', 'expr')], <MediumLevelILOperation.MLIL_LOAD: 4>: [('src', 'expr')], <MediumLevelILOperation.MLIL_LOAD_STRUCT: 5>: [('src', 'expr'), ('offset', 'int')], <MediumLevelILOperation.MLIL_STORE: 6>: [('dest', 'expr'), ('src', 'expr')], <MediumLevelILOperation.MLIL_STORE_STRUCT: 7>: [('dest', 'expr'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_VAR: 8>: [('src', 'var')], <MediumLevelILOperation.MLIL_VAR_FIELD: 9>: [('src', 'var'), ('offset', 'int')], <MediumLevelILOperation.MLIL_ADDRESS_OF: 10>: [('src', 'var')], <MediumLevelILOperation.MLIL_ADDRESS_OF_FIELD: 11>: [('src', 'var'), ('offset', 'int')], <MediumLevelILOperation.MLIL_CONST: 12>: [('constant', 'int')], <MediumLevelILOperation.MLIL_CONST_PTR: 13>: [('constant', 'int')], <MediumLevelILOperation.MLIL_IMPORT: 14>: [('constant', 'int')], <MediumLevelILOperation.MLIL_ADD: 15>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_ADC: 16>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_SUB: 17>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_SBB: 18>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_AND: 19>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_OR: 20>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_XOR: 21>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_LSL: 22>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_LSR: 23>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_ASR: 24>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_ROL: 25>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_RLC: 26>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_ROR: 27>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_RRC: 28>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_MUL: 29>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MULU_DP: 30>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MULS_DP: 31>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVU: 32>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVU_DP: 33>: [('hi', 'expr'), ('lo', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVS: 34>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVS_DP: 35>: [('hi', 'expr'), ('lo', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODU: 36>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODU_DP: 37>: [('hi', 'expr'), ('lo', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODS: 38>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODS_DP: 39>: [('hi', 'expr'), ('lo', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_NEG: 40>: [('src', 'expr')], <MediumLevelILOperation.MLIL_NOT: 41>: [('src', 'expr')], <MediumLevelILOperation.MLIL_SX: 42>: [('src', 'expr')], <MediumLevelILOperation.MLIL_ZX: 43>: [('src', 'expr')], <MediumLevelILOperation.MLIL_LOW_PART: 44>: [('src', 'expr')], <MediumLevelILOperation.MLIL_JUMP: 45>: [('dest', 'expr')], <MediumLevelILOperation.MLIL_JUMP_TO: 46>: [('dest', 'expr'), ('targets', 'int_list')], <MediumLevelILOperation.MLIL_CALL: 47>: [('output', 'var_list'), ('dest', 'expr'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_CALL_UNTYPED: 48>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_CALL_OUTPUT: 49>: [('dest', 'var_list')], <MediumLevelILOperation.MLIL_CALL_PARAM: 50>: [('src', 'var_list')], <MediumLevelILOperation.MLIL_RET: 51>: [('src', 'expr_list')], <MediumLevelILOperation.MLIL_NORET: 52>: [], <MediumLevelILOperation.MLIL_IF: 53>: [('condition', 'expr'), ('true', 'int'), ('false', 'int')], <MediumLevelILOperation.MLIL_GOTO: 54>: [('dest', 'int')], <MediumLevelILOperation.MLIL_CMP_E: 55>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_NE: 56>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SLT: 57>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_ULT: 58>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SLE: 59>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_ULE: 60>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SGE: 61>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_UGE: 62>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SGT: 63>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_UGT: 64>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_TEST_BIT: 65>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_BOOL_TO_INT: 66>: [('src', 'expr')], <MediumLevelILOperation.MLIL_ADD_OVERFLOW: 67>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_SYSCALL: 68>: [('output', 'var_list'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_SYSCALL_UNTYPED: 69>: [('output', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_BP: 70>: [], <MediumLevelILOperation.MLIL_TRAP: 71>: [('vector', 'int')], <MediumLevelILOperation.MLIL_UNDEF: 72>: [], <MediumLevelILOperation.MLIL_UNIMPL: 73>: [], <MediumLevelILOperation.MLIL_UNIMPL_MEM: 74>: [('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SSA: 75>: [('dest', 'var_ssa'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SSA_FIELD: 76>: [('prev', 'var_ssa_dest_and_src'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SPLIT_SSA: 77>: [('high', 'var_ssa'), ('low', 'var_ssa'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_ALIASED: 78>: [('prev', 'var_ssa_dest_and_src'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_ALIASED_FIELD: 79>: [('prev', 'var_ssa_dest_and_src'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_VAR_SSA: 80>: [('src', 'var_ssa')], <MediumLevelILOperation.MLIL_VAR_SSA_FIELD: 81>: [('src', 'var_ssa'), ('offset', 'int')], <MediumLevelILOperation.MLIL_VAR_ALIASED: 82>: [('src', 'var_ssa')], <MediumLevelILOperation.MLIL_VAR_ALIASED_FIELD: 83>: [('src', 'var_ssa'), ('offset', 'int')], <MediumLevelILOperation.MLIL_CALL_SSA: 84>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr_list'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_CALL_UNTYPED_SSA: 85>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_SYSCALL_SSA: 86>: [('output', 'expr'), ('params', 'expr_list'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_SYSCALL_UNTYPED_SSA: 87>: [('output', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_CALL_PARAM_SSA: 88>: [('src_memory', 'int'), ('src', 'var_ssa_list')], <MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA: 89>: [('dest_memory', 'int'), ('dest', 'var_ssa_list')], <MediumLevelILOperation.MLIL_LOAD_SSA: 90>: [('src', 'expr'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA: 91>: [('src', 'expr'), ('offset', 'int'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_STORE_SSA: 92>: [('dest', 'expr'), ('dest_memory', 'int'), ('src_memory', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_STORE_STRUCT_SSA: 93>: [('dest', 'expr'), ('offset', 'int'), ('dest_memory', 'int'), ('src_memory', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_VAR_PHI: 94>: [('dest', 'var_ssa'), ('src', 'var_ssa_list')], <MediumLevelILOperation.MLIL_MEM_PHI: 95>: [('dest_memory', 'int'), ('src_memory', 'int_list')]}
branch_dependence

Set of branching instructions that must take the true or false path to reach this instruction

expr_type

Type of expression

get_branch_dependence(branch_instr)[source]
get_flag_value(flag)[source]
get_flag_value_after(flag)[source]
get_possible_flag_values(flag)[source]
get_possible_flag_values_after(flag)[source]
get_possible_reg_values(reg)[source]
get_possible_reg_values_after(reg)[source]
get_possible_stack_contents(offset, size)[source]
get_possible_stack_contents_after(offset, size)[source]
get_reg_value(reg)[source]
get_reg_value_after(reg)[source]
get_ssa_var_possible_values(ssa_var)[source]
get_ssa_var_version(var)[source]
get_stack_contents(offset, size)[source]
get_stack_contents_after(offset, size)[source]
get_var_for_flag(flag)[source]
get_var_for_reg(reg)[source]
get_var_for_stack_location(offset)[source]
low_level_il

Low level IL form of this expression

non_ssa_form

Non-SSA form of expression (read-only)

possible_values

Possible values of expression using path-sensitive static data flow analysis (read-only)

postfix_operands

All operands in the expression tree in postfix order

prefix_operands

All operands in the expression tree in prefix order

ssa_form

SSA form of expression (read-only)

ssa_memory_version

Version of active memory contents in SSA form for this instruction

tokens

MLIL tokens (read-only)

value

Value of expression if constant or a known value (read-only)

vars_read

List of variables read by instruction

vars_written

List of variables written by instruction

class binaryninja.mediumlevelil.MediumLevelILLabel(handle=None)[source]

Bases: object

class binaryninja.mediumlevelil.MediumLevelILOperationAndSize(operation, size)[source]

Bases: object

class binaryninja.mediumlevelil.SSAVariable(var, version)[source]

Bases: object