binaryninja.architecture.Architecture

class binaryninja.architecture.Architecture(handle=None)[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__(handle=None)[source]

Methods

__init__([handle])
always_branch(data, addr) always_branch reads the instruction(s) in data at virtual address addr and returns a string of bytes
assemble(code[, addr]) assemble converts the string of assembly instructions code loaded at virtual address addr to the
convert_to_nop(data, addr) convert_to_nop reads the instruction(s) in data at virtual address addr and returns a string of nop
get_associated_arch_by_address(addr)
get_default_flag_condition_low_level_il(cond, 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, il)
param LowLevelILFlagCondition cond:
 
get_flag_index(flag)
get_flag_name(flag) get_flag_name gets a flag name from a flag number.
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_instruction_info(data, addr) get_instruction_info returns an InstructionInfo object for the instruction at the given virtual address
get_instruction_low_level_il(data, addr, il) get_instruction_low_level_il appends LowLevelILExpr objects to il for the instruction at the given
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
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_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
is_always_branch_patch_available(data, addr) is_always_branch_patch_available determines if the instruction data at addr can be made to
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_zero_patch_available determines if the instruction data at addr is a call-like
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
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) perform_always_branch implements a method which converts the branch represented by the bytes in data to
perform_assemble(code, addr) perform_assemble implements a method to convert the string of assembly instructions code loaded at
perform_convert_to_nop(data, addr) perform_convert_to_nop implements a method which returns a nop sequence of len(data) bytes long.
perform_get_associated_arch_by_address(addr)
perform_get_flag_condition_low_level_il(cond, il)

Note

Architecture subclasses should implement this method.

perform_get_flag_write_low_level_il(op, …)

Note

Architecture subclasses should implement this method.

perform_get_instruction_info(data, addr) perform_get_instruction_info implements a method which interpretes the bytes passed in data as an
perform_get_instruction_low_level_il(data, …) perform_get_instruction_low_level_il implements a method to interpret the bytes passed in data to
perform_get_instruction_text(data, addr) perform_get_instruction_text implements a method which interpretes the bytes passed in data as a
perform_invert_branch(data, addr) perform_invert_branch implements a method which inverts the branch represented by the bytes in data to
perform_is_always_branch_patch_available(…) perform_is_always_branch_patch_available implements a check to determine if the instruction represented by
perform_is_invert_branch_patch_available(…) perform_is_invert_branch_patch_available implements a check to determine if the instruction represented by
perform_is_never_branch_patch_available(…) perform_is_never_branch_patch_available implements a check to determine if the instruction represented by
perform_is_skip_and_return_value_patch_available(…) perform_is_skip_and_return_value_patch_available implements a check to determine if the instruction represented by
perform_is_skip_and_return_zero_patch_available(…) perform_is_skip_and_return_zero_patch_available implements a check to determine if the instruction represented by
perform_skip_and_return_value(data, addr, value) perform_skip_and_return_value implements a method which converts a call-like instruction represented by
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

Attributes

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