binaryninja.architecture.Architecture

class Architecture[source]

class Architecture is the parent class for all CPU architectures. Subclasses of Architecture implement assembly, disassembly, IL lifting, and patching.

class Architecture has a metaclass with the additional methods register, and supports iteration:

>>> #List the architectures
>>> list(Architecture)
[<arch: aarch64>, <arch: armv7>, <arch: armv7eb>, <arch: mipsel32>, <arch: mips32>, <arch: powerpc>,
<arch: x86>, <arch: x86_64>]
>>> #Register a new Architecture
>>> class MyArch(Architecture):
...  name = "MyArch"
...
>>> MyArch.register()
>>> list(Architecture)
[<arch: aarch64>, <arch: armv7>, <arch: armv7eb>, <arch: mipsel32>, <arch: mips32>, <arch: powerpc>,
<arch: x86>, <arch: x86_64>, <arch: MyArch>]
>>>

For the purposes of this documentation the variable arch will be used in the following context

>>> from binaryninja import *
>>> arch = Architecture['x86']
__init__()[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__() x.__init__(…) initializes x; see help(type(x)) for signature
always_branch(data, addr) always_branch reads the instruction(s) in data at virtual address addr and returns a string of bytes of the same length which always branches.
assemble(code[, addr]) assemble converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions.
convert_to_nop(data, addr) convert_to_nop reads the instruction(s) in data at virtual address addr and returns a string of nop instructions of the same length as data.
get_associated_arch_by_address(addr)
get_default_flag_condition_low_level_il(…)
param LowLevelILFlagCondition cond:
 
get_default_flag_write_low_level_il(op, …)
param LowLevelILOperation op:
 
get_flag_by_name(flag) get_flag_by_name get flag name for flag index.
get_flag_condition_low_level_il(cond, …)
param LowLevelILFlagCondition cond:
 Flag condition to be computed
get_flag_index(flag)
get_flag_name(flag) get_flag_name gets a flag name from a flag number.
get_flag_role(flag[, sem_class]) get_flag_role gets the role of a given flag.
get_flag_write_low_level_il(op, size, …)
param LowLevelILOperation op:
 
get_flag_write_type_by_name(write_type) get_flag_write_type_by_name gets the flag write type name for the flage write type.
get_flag_write_type_name(write_type) get_flag_write_type_name gets the flag write type name for the given flag.
get_flags_required_for_flag_condition(cond)
get_instruction_info(data, addr) get_instruction_info returns an InstructionInfo object for the instruction at the given virtual address addr with data data.
get_instruction_low_level_il(data, addr, il) get_instruction_low_level_il appends LowLevelILExpr objects to il for the instruction at the given virtual address addr with data data.
get_instruction_low_level_il_instruction(bv, …)
get_instruction_text(data, addr) get_instruction_text returns a list of InstructionTextToken objects for the instruction at the given virtual address addr with data data.
get_intrinsic_index(intrinsic)
get_intrinsic_name(intrinsic) get_intrinsic_name gets an intrinsic name from an intrinsic number.
get_low_level_il_from_bytes(data, addr) get_low_level_il_from_bytes converts the instruction in bytes to il at the given virtual address
get_modified_regs_on_write(reg) get_modified_regs_on_write returns a list of register names that are modified when reg is written.
get_reg_index(reg)
get_reg_name(reg) get_reg_name gets a register name from a register number.
get_reg_stack_for_reg(reg)
get_reg_stack_index(reg_stack)
get_reg_stack_name(reg_stack) get_reg_stack_name gets a register stack name from a register stack number.
get_semantic_flag_class_by_name(sem_class) get_semantic_flag_class_by_name gets the semantic flag class index by name.
get_semantic_flag_class_index(sem_class)
get_semantic_flag_class_name(class_index) get_semantic_flag_class_name gets the name of a semantic flag class from the index.
get_semantic_flag_group_by_name(sem_group) get_semantic_flag_group_by_name gets the semantic flag group index by name.
get_semantic_flag_group_index(sem_group)
get_semantic_flag_group_low_level_il(…)
param str sem_group:
 
get_semantic_flag_group_name(group_index) get_semantic_flag_group_name gets the name of a semantic flag group from the index.
get_view_type_constant(type_name, const_name) get_view_type_constant retrieves the view type constant for the given type_name and const_name.
invert_branch(data, addr) invert_branch reads the instruction(s) in data at virtual address addr and returns a string of bytes of the same length which inverts the branch of provided instruction.
is_always_branch_patch_available(data, addr) is_always_branch_patch_available determines if the instruction data at addr can be made to always branch.
is_invert_branch_patch_available(data, addr) is_always_branch_patch_available determines if the instruction data at addr can be inverted.
is_never_branch_patch_available(data, addr) is_never_branch_patch_available determines if the instruction data at addr can be made to never branch.
is_skip_and_return_value_patch_available(…) is_skip_and_return_value_patch_available determines if the instruction data at addr is a call-like instruction that can be made into an instruction returns a value.
is_skip_and_return_zero_patch_available(…) is_skip_and_return_zero_patch_available determines if the instruction data at addr is a call-like instruction that can be made into an instruction returns zero.
is_view_type_constant_defined(type_name, …)
param str type_name:
 the BinaryView type name of the constant to query
perform_always_branch(data, addr) Deprecated method provided for compatibility.
perform_assemble(code, addr) Deprecated method provided for compatibility.
perform_convert_to_nop(data, addr) Deprecated method provided for compatibility.
perform_get_associated_arch_by_address(addr) Deprecated method provided for compatibility.
perform_get_flag_condition_low_level_il(…) Deprecated method provided for compatibility.
perform_get_flag_role(flag, sem_class) Deprecated method provided for compatibility.
perform_get_flag_write_low_level_il(op, …) Deprecated method provided for compatibility.
perform_get_flags_required_for_flag_condition(…) Deprecated method provided for compatibility.
perform_get_instruction_info(data, addr) Deprecated method provided for compatibility.
perform_get_instruction_low_level_il(data, …) Deprecated method provided for compatibility.
perform_get_instruction_text(data, addr) Deprecated method provided for compatibility.
perform_get_semantic_flag_group_low_level_il(…) Deprecated method provided for compatibility.
perform_invert_branch(data, addr) Deprecated method provided for compatibility.
perform_is_always_branch_patch_available(…) Deprecated method provided for compatibility.
perform_is_invert_branch_patch_available(…) Deprecated method provided for compatibility.
perform_is_never_branch_patch_available(…) Deprecated method provided for compatibility.
perform_is_skip_and_return_value_patch_available(…) Deprecated method provided for compatibility.
perform_is_skip_and_return_zero_patch_available(…) Deprecated method provided for compatibility.
perform_skip_and_return_value(data, addr, value) Deprecated method provided for compatibility.
register_calling_convention(cc) register_calling_convention registers a new calling convention for the Architecture.
set_view_type_constant(type_name, …) set_view_type_constant creates a new binaryview type constant.
skip_and_return_value(data, addr, value) skip_and_return_value reads the instruction(s) in data at virtual address addr and returns a string of bytes of the same length which doesn’t call and instead return a value.

Attributes

address_size
calling_conventions Dict of CallingConvention objects (read-only)
default_int_size
endianness
flag_conditions_for_semantic_flag_group
flag_roles
flag_write_types
flags
flags_required_for_flag_condition
flags_required_for_semantic_flag_group
flags_written_by_flag_write_type
full_width_regs List of full width register strings (read-only)
global_regs
instr_alignment
intrinsics
link_reg
list
max_instr_length
name
next_address
opcode_display_length
reg_stacks
regs
semantic_class_for_flag_write_type
semantic_flag_classes
semantic_flag_groups
stack_pointer
standalone_platform Architecture standalone platform (read-only)