Class |
Description |
|---|---|
Bases: object
ArchAndAddr(arch: ‘architecture.Architecture’, addr: int)
arch (Architecture) –
addr (int) –
None
Bases: object
function (Function | LowLevelILFunction | MediumLevelILFunction | HighLevelILFunction) –
Bases: object
handle (LP_BNDisassemblySettings | None) –
option (DisassemblyOption) –
option (DisassemblyOption) –
state (bool) –
None
Bases: object
DisassemblyTextLine(tokens: List[ForwardRef(‘InstructionTextToken’)], address: Optional[int] = None, il_instr: Union[ForwardRef(‘lowlevelil.LowLevelILInstruction’), ForwardRef(‘mediumlevelil.MediumLevelILInstruction’), ForwardRef(‘highlevelil.HighLevelILInstruction’), NoneType] = None, color: Union[ForwardRef(‘_highlight.HighlightColor’), binaryninja.enums.HighlightStandardColor, NoneType] = None, tags: Optional[List[ForwardRef(‘binaryview.Tag’)]] = None, type_info: Optional[binaryninja.function.DisassemblyTextLineTypeInfo] = None)
tokens (List[InstructionTextToken]) –
address (int | None) –
il_instr (LowLevelILInstruction | MediumLevelILInstruction | HighLevelILInstruction | None) –
color (HighlightColor | HighlightStandardColor | None) –
type_info (DisassemblyTextLineTypeInfo | None) –
Bases: object
func (Function | LowLevelILFunction | MediumLevelILFunction | HighLevelILFunction | None) –
settings (DisassemblySettings | None) –
handle (BNDisassemblySettings | None) –
tokens (List[InstructionTextToken]) –
int_token (InstructionTextToken) –
addr (int) –
arch (Architecture | None) –
None
tokens (List[InstructionTextToken]) –
ref (StackVariableReference) –
None
addr (int) –
Generator[Tuple[DisassemblyTextLine | None, int], None, None]
addr (int) –
addr (int) –
Generator[Tuple[DisassemblyTextLine | None, int], None, None]
token (InstructionTextToken) –
lines (List[DisassemblyTextLine]) –
cur_line (DisassemblyTextLine) –
comment (str) –
has_auto_annotations (bool) –
leading_spaces (str) –
indent_spaces (str) –
None
Bases: object
view (BinaryView | None) –
handle (LP_BNFunction | None) –
add_guided_source_blocks adds blocks to the guided source block list for this function.
The specified blocks will have their direct outgoing branch targets analyzed. This automatically
enables the analysis.guided.enable setting if it is not already enabled.
addresses (List[Tuple[Architecture, int]]) – List of (architecture, address) tuples to add
addresses –
None
add_tag creates and adds a Tag object on either a function, or on
an address inside of a function.
“Function tags” appear at the top of a function and are a good way to label an entire function with some information. If you include an address when you call Function.add_tag, you’ll create an “address tag”. These are good for labeling specific instructions.
For tagging arbitrary data, consider add_tag.
tag_type (str) – The name of the tag type for this Tag
data (str) – additional data for the Tag
addr (int) – address at which to add the tag
auto (bool) – Whether or not an auto tag
arch (Architecture) – Architecture for the block in which the Tag is added (optional)
>>> current_function.add_tag("Important", "I think this is the main function")
>>> current_function.add_tag("Crashes", "Nullpointer dereference", here)
Warning: For performance reasons, this function does not ensure the address you have supplied is within the function’s bounds.
add_user_code_ref places a user-defined cross-reference from the instruction at
the given address and architecture to the specified target address. If the specified
source instruction is not contained within this function, no action is performed.
To remove the reference, use remove_user_code_ref.
from_addr (int) – virtual address of the source instruction
to_addr (int) – virtual address of the xref’s destination.
arch (Architecture) – (optional) architecture of the source instruction
None
>>> current_function.add_user_code_ref(here, 0x400000)
add_user_type_field_ref places a user-defined type field cross-reference from the
instruction at the given address and architecture to the specified type. If the specified
source instruction is not contained within this function, no action is performed.
To remove the reference, use remove_user_type_field_ref.
from_addr (int) – virtual address of the source instruction
name (QualifiedName) – name of the referenced type
offset (int) – offset of the field, relative to the type
from_arch (Architecture) – (optional) architecture of the source instruction
size (int) – (optional) the size of the access
None
>>> current_function.add_user_type_field_ref(here, 'A', 0x8)
add_user_type_ref places a user-defined type cross-reference from the instruction at
the given address and architecture to the specified type. If the specified
source instruction is not contained within this function, no action is performed.
To remove the reference, use remove_user_type_ref.
from_addr (int) – virtual address of the source instruction
name (QualifiedName) – name of the referenced type
from_arch (Architecture) – (optional) architecture of the source instruction
None
>>> current_function.add_user_code_ref(here, 'A')
analyze causes this function to be analyzed if it’s out of date. This function does not wait for the analysis to finish.
None
func_type (str | Type | TypeBuilder) –
None
sym (CoreSymbol) –
type (str | Type | TypeBuilder | None) –
None
check_for_debug_report checks if a function has had a debug report requested
with the given name, and then, if one has been requested, clears the request internally
so that future calls to this function for that report will return False.
If a function has had a debug report requested, it is the caller of this function’s
responsibility to actually generate and show the debug report.
You can use binaryninja.interaction.show_report_collection
for showing a debug report from a workflow activity.
Clears a previously defined user variable value.
offset (int) –
var_type (str | Type | TypeBuilder) –
name (str) –
None
Create a flow graph with the disassembly of this function.
Note
This graph waits for function analysis, so Workflow Activities should instead use
create_graph_immediate to create graphs with the function contents as-is.
graph_type (FunctionViewType | FunctionGraphType | str) – IL form of the disassembly in the graph
settings (DisassemblySettings | None) – Optional settings for the disassembly text renderer
Flow graph object
Create a flow graph with the disassembly of this function, specifically using the instructions as they are in the function when this is called. You probably want to use this if you are creating a Debug Report in a Workflow Activity.
graph_type (FunctionViewType | FunctionGraphType | str) – IL form of the disassembly in the graph
settings (DisassemblySettings | None) – Optional settings for the disassembly text renderer
Flow graph object
offset (int) –
var_type (str | Type | TypeBuilder) –
name (str) –
None
Un-collapse a region during rendering :param hash: Hash value of region
Returns a map of current defined user variable values.
Map of user current defined user variable values and their definition sites.
dict of (Variable, dict of (ArchAndAddr, PossibleValueSet))
get_basic_block_at returns the BasicBlock of the optionally specified Architecture arch at the given
address addr.
addr (int) – Address of the BasicBlock to retrieve.
arch (Architecture) – (optional) Architecture of the basic block if different from the Function’s self.arch
>>> current_function.get_basic_block_at(current_function.start)
<block: x86_64@0x100000f30-0x100000f50>
BasicBlock | None
addr (int) –
arch (Architecture | None) –
addr (int) –
arch (Architecture | None) –
Dict[RegisterStackName, RegisterStackAdjustmentWithConfidence]
addr (int) –
reg_stack (RegisterStackName | ILRegisterStack | RegisterStackIndex) –
arch (Architecture | None) –
addr (int) –
arch (Architecture | None) –
addr (int) –
arch (Architecture | None) –
Type | None
get_callee_for_analysis retrieves the callee function for the specified address and platform.
Note
This method is intended for use by architecture plugins only.
state (RegisterValueType) –
value (int) –
size (int) –
state (RegisterValueType) –
value (int) –
size (int) –
addr (int) –
arch (Architecture | None) –
addr (int) –
arch (Architecture | None) –
addr (int | HighLevelILInstruction) –
addr (int | HighLevelILInstruction) –
i (InstructionIndex) –
List[FlagName]
i (InstructionIndex) –
List[FlagName]
get_function_tags gets a list of function Tags for the function.
get_guided_source_blocks returns the current list of guided source blocks for this function.
These blocks have their direct outgoing branch targets analyzed.
List[Tuple[Architecture, int]]
List of (architecture, address) tuples representing current guided source blocks
get_hlil_var_refs returns a list of ILReferenceSource objects (IL xrefs or cross-references)
that reference the given variable. The variable is a local variable that can be either on the stack,
in a register, or in a flag.
var (Variable) – Variable for which to query the xref
List of IL References for the given variable
>>> mlil_var = current_hlil[0].operands[0]
>>> current_function.get_hlil_var_refs(mlil_var)
get_hlil_var_refs_from returns a list of variables referenced by code in the function func,
of the architecture arch, and at the address addr. If no function is specified, references from
all functions and containing the address will be returned. If no architecture is specified, the
architecture of the function will be used.
addr (int) – virtual address to query for variable references
length (int) – optional length of query
arch (Architecture) – optional architecture of query
list of variables reference sources
addr (int) –
arch (Architecture | None) –
>>> current_function.set_user_instr_highlight(here, highlight.HighlightColor(red=0xff, blue=0xff, green=0))
>>> current_function.get_instr_highlight(here)
<color: #ff00ff>
addr (int) –
arch (Architecture | None) –
addr (int) –
arch (Architecture | None) –
int | None
Get the current text display type for an integer token in the disassembly or IL views
See also see get_int_display_type_and_typeid
instr_addr (int) – Address of the instruction or IL line containing the token
value (int) – value field of the InstructionTextToken object for the token, usually the constant displayed
operand (int) – Operand index of the token, defined as the number of OperandSeparatorTokens in the disassembly line before the token
arch (Architecture) – (optional) Architecture of the instruction or IL line containing the token
Get the current text display type for an integer token in the disassembly or IL views
instr_addr (int) – Address of the instruction or IL line containing the token
value (int) – value field of the InstructionTextToken object for the token, usually the constant displayed
operand (int) – Operand index of the token, defined as the number of OperandSeparatorTokens in the disassembly line before the token
arch (Architecture) – (optional) Architecture of the instruction or IL line containing the token
(<enum ‘IntegerDisplayType’>, <class ‘str’>)
Get the current text display enum type for an integer token in the disassembly or IL views.
See also see get_int_display_type_and_typeid
instr_addr (int) – Address of the instruction or IL line containing the token
value (int) – value field of the InstructionTextToken object for the token, usually the constant displayed
operand (int) – Operand index of the token, defined as the number of OperandSeparatorTokens in the disassembly line before the token
arch (Architecture) – (optional) Architecture of the instruction or IL line containing the token
TypeID for the integer token
addr (int) –
arch (Architecture | None) –
LowLevelILInstruction | None
i (InstructionIndex) –
flag (FlagName | ILFlag | FlagIndex) –
get_lifted_ils_at gets the Lifted IL Instruction(s) corresponding to the given virtual address
addr (int) – virtual address of the function to be queried
arch (Architecture) – (optional) Architecture for the given function
>>> func = next(bv.functions)
>>> func.get_lifted_ils_at(func.start)
[<il: push(rbp)>]
get_llil_at gets the LowLevelILInstruction corresponding to the given virtual address
addr (int) – virtual address of the instruction to be queried
arch (Architecture) – (optional) Architecture for the given function
>>> func = next(bv.functions)
>>> func.get_llil_at(func.start)
<il: push(rbp)>
get_llils_at gets the LowLevelILInstruction(s) corresponding to the given virtual address
See the developer docs for more information.
addr (int) – virtual address of the instruction to be queried
arch (Architecture) – (optional) Architecture for the given function
>>> func = next(bv.functions)
>>> func.get_llils_at(func.start)
[<il: push(rbp)>]
get_low_level_il_at gets the LowLevelILInstruction corresponding to the given virtual address
addr (int) – virtual address of the function to be queried
arch (Architecture) – (optional) Architecture for the given function
>>> func = next(bv.functions)
>>> func.get_low_level_il_at(func.start)
<il: push(rbp)>
addr (int) –
arch (Architecture | None) –
get_low_level_ils_at gets the LowLevelILInstruction(s) corresponding to the given virtual address
See the developer docs for more information.
addr (int) – virtual address of the instruction to be queried
arch (Architecture) – (optional) Architecture for the given function
>>> func = next(bv.functions)
>>> func.get_low_level_ils_at(func.start)
[<il: push(rbp)>]
get_metadata retrieves a metadata value associated with the given key stored in the current Function.
This method behaves like dict.get():
If the key exists, its metadata value is returned.
If the key does not exist and default is not provided, None is returned.
If the key does not exist and default is provided, default is returned.
metadata associated with the key or the default value
>>> current_function.store_metadata("integer", 1337)
>>> current_function.get_metadata("integer")
1337L
>>> current_function.get_metadata("missing")
None
>>> current_function.get_metadata("missing", 42)
42
get_mlil_var_refs returns a list of ILReferenceSource objects (IL xrefs or cross-references)
that reference the given variable. The variable is a local variable that can be either on the stack,
in a register, or in a flag.
This function is related to get_hlil_var_refs(), which returns variable references collected
from HLIL. The two can be different in several cases, e.g., multiple variables in MLIL can be merged
into a single variable in HLIL.
var (Variable) – Variable for which to query the xref
List of IL References for the given variable
>>> mlil_var = current_mlil[0].operands[0]
>>> current_function.get_mlil_var_refs(mlil_var)
get_mlil_var_refs_from returns a list of variables referenced by code in the function func,
of the architecture arch, and at the address addr. If no function is specified, references from
all functions and containing the address will be returned. If no architecture is specified, the
architecture of the function will be used.
This function is related to get_hlil_var_refs_from(), which returns variable references collected
from HLIL. The two can be different in several cases, e.g., multiple variables in MLIL can be merged
into a single variable in HLIL.
addr (int) – virtual address to query for variable references
length (int) – optional length of query
arch (Architecture) – optional architecture of query
list of variable reference sources
addr (int) –
func_type (Type | None) –
i (int) –
arch (Architecture | None) –
get_reg_value_after gets the value instruction address corresponding to the given virtual address
addr (int) – virtual address of the instruction to query
reg (str) – string value of native register to query
arch (Architecture) – (optional) Architecture for the given function
>>> current_function.get_reg_value_after(0x400dbe, 'rdi')
<undetermined>
get_reg_value_at gets the value the provided string register address corresponding to the given virtual address
addr (int) – virtual address of the instruction to query
reg (str) – string value of native register to query
arch (Architecture) – (optional) Architecture for the given function
>>> current_function.get_reg_value_at(0x400dbe, 'rdi')
<const 0x2>
reg (RegisterName | ILRegister | RegisterIndex) –
addr (int) –
arch (Architecture | None) –
List[RegisterName]
addr (int) –
arch (Architecture | None) –
List[RegisterName]
addr (int) –
offset (int) –
size (int) –
arch (Architecture | None) –
get_stack_contents_at returns the RegisterValue for the item on the stack in the current function at the
given virtual address addr, stack offset offset and size of size. Optionally specifying the architecture.
addr (int) – virtual address of the instruction to query
offset (int) – stack offset base of stack
size (int) – size of memory to query
arch (Architecture) – (optional) Architecture for the given function
Note
Stack base is zero on entry into the function unless the architecture places the return address on the stack as in (x86/x86_64) where the stack base will start at address_size
>>> current_function.get_stack_contents_at(0x400fad, -16, 4)
<range: 0x8 to 0xffffffff>
addr (int) –
offset (int) –
size (int) –
arch (Architecture | None) –
offset (int) –
addr (int) –
arch (Architecture | None) –
Variable | None
offset (int) –
addr (int) –
arch (Architecture | None) –
Variable | None
addr (int) –
arch (Architecture | None) –
addr (int) –
arch (Architecture | None) –
addr (int | HighLevelILInstruction) –
get_tags gets a list of Tags (but not function tags).
addr (int) – Address to get tags from.
auto (bool) – If None, gets all tags, if True, gets auto tags, if False, gets user tags
arch (Architecture | None) –
list((Architecture, int, Tag))
get_address_tags_in_range gets a list of all Tags in the function at a given address.
Range is inclusive at the start, exclusive at the end.
address_range (AddressRange) – Address range from which to get tags
arch (Architecture) – Architecture for the block in which the Tag is located (optional)
auto (bool) – If None, gets all tags, if True, gets auto tags, if False, gets user tags
A list of (arch, address, Tag) tuples
list((Architecture, int, Tag))
settings (DisassemblySettings | None) –
Get a specific variable or None if it doesn’t exist
has_guided_source_blocks checks if this function has any guided source blocks configured.
This indicates whether guided analysis is active for this function.
True if the function has guided source blocks, False otherwise
addr (int) –
arch (Architecture | None) –
addr (int | HighLevelILInstruction) –
is_guided_source_block checks if the given address is a guided source block.
arch (Architecture) – Architecture of the address to check
addr (int) – Address to check
Determine if a given HLIL instruction (with discriminator) is collapsed during rendering. :param instr: Instruction which might be collapsed :param discriminator: Unique discriminator id for the region :return: True if the instruction should be rendered as collapsed
instr (HighLevelILInstruction) –
discriminator (int) –
Determine if a given region is collapsed during rendering. :param hash: Hash value of region :return: True if the region should be rendered as collapsed
language (str) –
language (str) –
mark_caller_updates_required indicates that callers of this function need to be reanalyzed during the next update cycle
update_type (FunctionUpdateType) – (optional) Desired update type
None
mark_updates_required indicates that this function needs to be reanalyzed during the next update cycle
update_type (FunctionUpdateType) – (optional) Desired update type
None
merge_vars merges one or more variables in sources into the target variable. All
variable accesses to the variables in sources will be rewritten to use target.
query_metadata retrieves metadata associated with the given key stored in the current Function.
key (str) – key to query
metadata associated with the key
reanalyze causes this function to be reanalyzed. This function does not wait for the analysis to finish.
update_type (FunctionUpdateType) – (optional) Desired update type
None
Warning
If analysis_skipped is True, using this API will not trigger re-analysis. Instead, set analysis_skipped to False.
None
update_type (FunctionUpdateType) –
remove_auto_address_tag removes a Tag object at a given address.
addr (int) – Address at which to add the tag
tag (Tag) – Tag object to be added
arch (Architecture) – Architecture for the block in which the Tag is added (optional)
None
remove_auto_address_tags_of_type removes all tags at the given address of the given type.
addr (int) – Address at which to remove the tags
tag_type (Tag) – TagType object to match for removing
arch (Architecture) – Architecture for the block in which the Tags is located (optional)
None
remove_user_function_tag removes a Tag object as a function tag.
tag (Tag) – Tag object to be added
None
remove_user_function_tags_of_type removes all function Tag objects on a function of a given type
tag_type (TagType) – TagType object to match for removing
None
remove_guided_source_blocks removes blocks from the guided source block list for this function.
The specified blocks will no longer have their direct outgoing branch targets analyzed.
This automatically enables the analysis.guided.enable setting if it is not already enabled.
addresses (List[Tuple[Architecture, int]]) – List of (architecture, address) tuples to remove
addresses –
None
remove_metadata removes the metadata associated with key from the current function.
key (str) – key associated with metadata to remove from the function
None
remove_user_address_tag removes a Tag object at a given address.
Since this removes a user tag, it will be added to the current undo buffer.
addr (int) – Address at which to remove the tag
tag (Tag) – Tag object to be added
arch (Architecture) – Architecture for the block in which the Tag is added (optional)
None
remove_user_address_tags_of_type removes all tags at the given address of the given type.
Since this removes user tags, it will be added to the current undo buffer.
addr (int) – Address at which to remove the tag
tag_type (Tag) – TagType object to match for removing
arch (Architecture) – Architecture for the block in which the Tags is located (optional)
None
remove_user_code_ref removes a user-defined cross-reference.
If the given address is not contained within this function, or if there is no
such user-defined cross-reference, no action is performed.
from_addr (int) – virtual address of the source instruction
to_addr (int) – virtual address of the xref’s destination.
from_arch (Architecture) – (optional) architecture of the source instruction
None
>>> current_function.remove_user_code_ref(here, 0x400000)
remove_user_function_tag removes a Tag object as a function tag.
Since this removes a user tag, it will be added to the current undo buffer.
tag (Tag) – Tag object to be added
None
remove_user_function_tags_of_type removes all function Tag objects on a function of a given type
Since this removes user tags, it will be added to the current undo buffer.
tag_type (TagType) – TagType object to match for removing
None
remove_user_type_field_ref removes a user-defined type field cross-reference.
If the given address is not contained within this function, or if there is no
such user-defined cross-reference, no action is performed.
from_addr (int) – virtual address of the source instruction
name (QualifiedName) – name of the referenced type
offset (int) – offset of the field, relative to the type
from_arch (Architecture) – (optional) architecture of the source instruction
size (int) – (optional) the size of the access
None
>>> current_function.remove_user_type_field_ref(here, 'A', 0x8)
remove_user_type_ref removes a user-defined type cross-reference.
If the given address is not contained within this function, or if there is no
such user-defined cross-reference, no action is performed.
from_addr (int) – virtual address of the source instruction
name (QualifiedName) – name of the referenced type
from_arch (Architecture) – (optional) architecture of the source instruction
None
>>> current_function.remove_user_type_ref(here, 'A')
request_debug_report can generate internal debug reports for a variety of analysis.
Current list of possible values include:
mlil_translator
stack_adjust_graph
high_level_il
name (str) – Name of the debug report
None
addr (int) –
arch (Architecture | None) –
None
addr (int) –
reg_stack (RegisterStackName | ILRegisterStack | RegisterStackIndex) –
arch (Architecture | None) –
None
addr (int) –
adjust (int | OffsetWithConfidence) –
arch (Architecture | None) –
None
value (CallingConvention) –
None
value (bool | BoolWithConfidence) –
None
value (List[RegisterName | ILRegister | RegisterIndex]) –
None
value (bool | BoolWithConfidence) –
None
source (int) –
branches (List[Tuple[Architecture, int]]) –
source_arch (Architecture | None) –
None
value (InlineDuringAnalysis | InlineDuringAnalysisWithConfidence | bool | BoolWithConfidence) –
set_auto_instr_highlight highlights the instruction at the specified address with the supplied color
Warning
Use only in analysis plugins. Do not use in regular plugins, as colors won’t be saved to the database.
addr (int) – virtual address of the instruction to be highlighted
color (HighlightStandardColor|HighlightColor) – Color value to use for highlighting
arch (Architecture) – (optional) Architecture of the instruction if different from self.arch
value (List[Variable] | Variable | ParameterVariables | None) –
None
value (bool | BoolWithConfidence) –
None
value (Mapping[RegisterStackName, RegisterStackAdjustmentWithConfidence]) –
value (RegisterSet | List[RegisterName | ILRegister | RegisterIndex]) –
None
value (str | Type | TypeBuilder) –
None
value (int | OffsetWithConfidence) –
None
value (str | Type | TypeBuilder) –
None
addr (int) –
adjust (Mapping[RegisterStackName, int | RegisterStackAdjustmentWithConfidence]) –
arch (Architecture | None) –
None
addr (int) –
reg_stack (RegisterStackName | ILRegisterStack | RegisterStackIndex) –
adjust (int | RegisterStackAdjustmentWithConfidence) –
arch (Architecture | None) –
None
addr (int) –
adjust (int | OffsetWithConfidence) –
arch (Architecture | None) –
set_call_type_adjustment sets or removes the call type override at a call site to the given type.
addr (int) – virtual address of the call instruction to adjust
adjust_type (str|Type|TypeBuilder) – (optional) overridden call type, or None to remove an existing adjustment
arch (Architecture) – (optional) Architecture of the instruction if different from self.arch
>>> # Change the current call site to no-return
>>> target = bv.get_function_at(list(filter(lambda ref: ref.address == here, current_function.call_sites))[0].mlil.dest.value.value)
>>> ft = target.type.mutable_copy()
>>> ft.can_return = False
>>> current_function.set_call_type_adjustment(here, ft)
None
set_comment_at sets a comment for the current function at the address specified
addr (int | HighLevelILInstruction) –
invert (bool) –
name (str) –
None
addr (int | HighLevelILInstruction) –
value (EarlyReturn) –
addr (int | HighLevelILInstruction) –
value (ExprFolding) –
set_guided_source_blocks sets the complete list of guided source blocks for this function.
Only blocks in this set will have their direct outgoing branch targets analyzed. This replaces
any existing guided source blocks and automatically enables or disables the analysis.guided.enable
setting based on whether addresses are provided.
addresses (List[Tuple[Architecture, int]]) – List of (architecture, address) tuples
addresses –
None
Change the text display type for an integer token in the disassembly or IL views
instr_addr (int) – Address of the instruction or IL line containing the token
value (int) – value field of the InstructionTextToken object for the token, usually the constant displayed
operand (int) – Operand index of the token, defined as the number of OperandSeparatorTokens in the disassembly line before the token
display_type (IntegerDisplayType) – Desired display type
arch (Architecture) – (optional) Architecture of the instruction or IL line containing the token
enum_display_typeid (str) – (optional) Whenever passing EnumDisplayType to display_type, passing a type ID here will specify the Enumeration display type. Must be a valid type ID and resolve to an enumeration type.
None
addr (int | HighLevelILInstruction) –
value (SwitchRecovery) –
source (int) –
branches (List[Tuple[Architecture, int]]) –
source_arch (Architecture | None) –
None
value (InlineDuringAnalysis | InlineDuringAnalysisWithConfidence | bool | BoolWithConfidence) –
set_user_instr_highlight highlights the instruction at the specified address with the supplied color
addr (int) – virtual address of the instruction to be highlighted
color (HighlightStandardColor|HighlightColor) – Color value to use for highlighting
arch (Architecture) – (optional) Architecture of the instruction if different from self.arch
>>> current_function.set_user_instr_highlight(here, HighlightStandardColor.BlueHighlightColor)
>>> current_function.set_user_instr_highlight(here, highlight.HighlightColor(red=0xff, blue=0xff, green=0))
Warning: For performance reasons, this function does not ensure the address you have supplied is within the function’s bounds.
value (str | Type | TypeBuilder) –
None
set_user_var_value allows the user to specify a PossibleValueSet value for an MLIL variable at its definition site.
Warning
Setting the variable value, triggers a reanalysis of the function and allows the dataflow to compute and propagate values which depend on the current variable. This implies that branch conditions whose values can be determined statically will be computed, leading to potential branch elimination at the HLIL layer.
var (Variable) – Variable for which the value is to be set
def_addr (int) – Address where the variable is set
value (PossibleValueSet) – Informed value of the variable
after (bool) – Whether the value happens before or after the instruction
None
>>> mlil_var = current_mlil[0].operands[0]
>>> def_address = 0x40108d
>>> var_value = PossibleValueSet.constant(5)
>>> current_function.set_user_var_value(mlil_var, def_address, var_value)
split_var splits a variable at the definition site. The given var must be the
variable unique to the definition and should be obtained by using
MediumLevelILInstruction.get_split_var_for_definition at the definition site.
This function is not meant to split variables that have been previously merged. Use
unmerge_vars to split previously merged variables.
Warning
Binary Ninja automatically splits all variables that the analysis determines to be safely splittable. Splitting a variable manually with split_var can cause IL and decompilation to be incorrect. There are some patterns where variables can be safely split semantically but analysis cannot determine that it is safe. This function is provided to allow variable splitting to be performed in these cases by plugins or by the user.
var (Variable) – variable to split
None
store_metadata stores an object for the given key in the current Function. Objects stored using store_metadata can be retrieved when the database is reopened unless isAuto is set to True.
Toggle the collapsed state of a region during rendering, by hash value :param hash: Hash value of region
unmerge_vars undoes variable merging performed with merge_vars. The variables in
sources will no longer be merged into the target variable.
unsplit_var undoes variable splitting performed with split_var. The given var
must be the variable unique to the definition and should be obtained by using
MediumLevelILInstruction.get_split_var_for_definition at the definition site.
var (Variable) – variable to unsplit
None
All of the address ranges covered by a function
Override for skipping of automatic analysis
Function analysis skip reason
Whether automatic analysis was skipped for this function. Can be set to false to re-enable analysis.
Function architecture (read-only)
Whether function was automatically discovered (read-only) as a result of some creation of a ‘user’ function. ‘user’ functions may or may not have been created by a user through the or API. For instance the entry point into a function is always created a ‘user’ function. ‘user’ functions should be considered the root of auto analysis.
metadata retrieves the metadata associated with the current function.
metadata associated with the function
function.BasicBlockList of BasicBlocks in the current function (read-only)
call_sites returns a list of possible call sites contained in this function.
This includes ordinary calls, tail calls, and indirect jumps. Not all of the returned call sites
are necessarily true call sites; some may simply be unresolved indirect jumps, for example.
List of References that represent the sources of possible calls in this function
callee_addresses returns a list of start addresses for functions that this function calls.
Does not point to the actual address where the call occurs, just the start of the function that contains the reference.
callees returns a list of functions that this function calls
This does not include the address of those calls, rather just the function objects themselves. Use call_sites to identify the location of these calls.
This does not include calls to imported functions, as they do not have a function object, use callee_addresses for that.
caller_sites returns a list of ReferenceSource objects corresponding to the addresses
in functions which call this function
List of ReferenceSource objects of the call sites to this function
callers returns a list of functions that call this function
Does not point to the actual address where the call occurs, just the start of the function that contains the call.
Calling convention used by the function
Whether function can return
Registers that are modified by this function
List of function stack variables (read-only)
List of CoreVariable objects
Discovered value of the global pointer register, if the function uses one (read-only)
Whether function has explicitly defined types (read-only)
Whether the function takes a variable number of arguments
returns HighLevelILFunction used to represent high level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes high level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
returns HighLevelILFunction used to represent high level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes high level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
returns HighLevelILFunction used to represent high level IL, or None if not loaded or it cannot be generated (read-only)
Note
This function can be used to check if high level IL is available without generating it.
List of indirect branches (read-only)
Whether the function’s IL should be inlined into all callers’ IL
A generator of instruction tokens and their start addresses for the current function
If the entire function is collapsed during rendering.
Whether the function is exported (read-only).
A function is considered exported when its symbol binding is global or weak.
Whether function is pure
returns LowLevelILFunction used to represent lifted IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes lifted IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
returns LowLevelILFunction used to represent lifted IL, or None if not loaded or it cannot be generated (read-only)
Note
This function can be used to check if lifted IL is available without generating it.
returns LowLevelILFunction used to represent low level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes low level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
A generator of all LowLevelILBasicBlock objects in the current function
returns LowLevelILFunction used to represent low level IL, or None if not loaded or it cannot be generated (read-only)
Note
This function can be used to check if low level IL is available without generating it.
returns LowLevelILFunction used to represent low level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes low level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
returns MediumLevelILFunction used to represent mapped medium level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes mapped medium level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
returns MediumLevelILFunction used to represent medium level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes medium level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
Map of merged variables, organized by target variable (read-only). Use merge_vars and
unmerge_vars to update merged variables.
metadata retrieves the metadata associated with the current function.
metadata associated with the function
returns MediumLevelILFunction used to represent medium level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes medium level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
A generator of all MediumLevelILBasicBlock objects in the current function
returns MediumLevelILFunction used to represent medium level IL, or None if not loaded or it cannot be generated (read-only)
Note
This function can be used to check if medium level IL is available without generating it.
returns MediumLevelILFunction used to represent mapped medium level IL, or None if an error occurs while loading the IL (read-only)
Note
This function causes mapped medium level IL to be generated if it has not been already. It is recommended to generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
returns MediumLevelILFunction used to represent mapped medium level IL, or None if not loaded or it cannot be generated (read-only)
Note
This function can be used to check if mapped medium level IL is available without generating it.
List of variables for the incoming function parameters
provenance returns a string representing the provenance. This portion of the API is under development.
Currently the provenance information is undocumented, not persistent, and not saved to a database.
string representation of the provenance
Number of entries removed from each register stack after return
Registers that are used for the return value
Dictionary object where plugins can store arbitrary data associated with the function
Set of variables that have been split with split_var. These variables correspond
to those unique to each definition site and are obtained by using
MediumLevelILInstruction.get_split_var_for_definition at the definitions.
Number of bytes removed from the stack after return
Function symbol(read-only)
tags gets a TagList of all Tags in the function (but not “function tags”).
Tags are returned as an iterable indexable object TagList of (arch, address, Tag) tuples.
TagList((Architecture, int, Tag))
Whether the function is too large to automatically perform analysis (read-only)
Total bytes of a function calculated by summing each basic_block. Because basic blocks can overlap and have gaps between them this may or may not be equivalent to a .size property.
Function type object, can be set with either a string representing the function prototype
(str(function) shows examples) or a Type object
Text tokens for this function’s prototype
List of unresolved indirect branches (read-only)
Flow graph of unresolved stack adjustments (read-only)
Whether the function uses the incoming global pointer value
Function view (read-only)
Bases: object
FunctionViewType(view_type: Union[ForwardRef(‘FunctionViewType’), binaryninja.enums.FunctionGraphType, str])
view_type (FunctionViewType | FunctionGraphType | str) –
Bases: BasicBlockList
Bases: object
ILReferenceSource(func: Optional[ForwardRef(‘Function’)], arch: Optional[ForwardRef(‘architecture.Architecture’)], address: int, il_type: binaryninja.enums.FunctionGraphType, expr_id: int)
func (Function | None) –
arch (Architecture | None) –
address (int) –
il_type (FunctionGraphType) –
expr_id (int) –
None
il_type (FunctionGraphType) –
Bases: BasicBlockList
Bases: BasicBlockList
Bases: object
VariableReferenceSource(var: ‘variable.Variable’, src: binaryninja.function.ILReferenceSource)
var (Variable) –
src (ILReferenceSource) –
None