component module

binaryninja.component.Component([handle])

Components are objects that can contain Functions and other Components.

class Component(handle=None)[source]

Bases: object

Components are objects that can contain Functions and other Components.

They can be queried for information about the functions contained within them.

Components have a Guid, which persistent across saves and loads of the database, and should be used for retrieving components when such is required and a reference to the Component cannot be held.

add_component(component: Component) bool[source]

Move component to this component. This will remove it from the old parent.

Parameters:

component (Component) – Component to add to this component.

Returns:

True if the component was successfully moved to this component

Return type:

bool

add_data_variable(data_variable)[source]
add_function(func: Function) bool[source]

Add function to this component.

Parameters:

func (Function) – Function to add

Returns:

True if function was successfully added.

Return type:

bool

contains_component(component: Component) bool[source]

Check whether this component contains a component.

Parameters:

component (Component) – Component to check

Returns:

True if this component contains the component.

Return type:

bool

contains_data_variable(data_variable)[source]
contains_function(func: Function) bool[source]

Check whether this component contains a function.

Parameters:

func (Function) – Function to check

Returns:

True if this component contains the function.

Return type:

bool

get_referenced_data_variables(recursive=False)[source]

Get data variables referenced by this component

Parameters:

recursive – Optional; Get all DataVariables referenced by this component and subcomponents.

Returns:

List of DataVariables

get_referenced_types(recursive=False)[source]

Get Types referenced by this component

Parameters:

recursive – Optional; Get all Types referenced by this component and subcomponents.

Returns:

List of Types

remove_component(component: Component) bool[source]

Remove a component from the current component, moving it to the root.

This function has no effect when used from the root component. Use BinaryView.remove_component to Remove a component from the tree entirely.

Parameters:

component (Component) – Component to remove

Returns:

Return type:

bool

remove_data_variable(data_variable)[source]
remove_function(func: Function) bool[source]

Remove function from this component.

Parameters:

func (Function) – Function to remove

Returns:

True if function was successfully removed.

Return type:

bool

property components: List[Component]

components is an iterator for all Components contained within this Component

Returns:

A list of components

Example:
>>> for subcomp in component.components:
...  print(repr(component))
property data_variable_list
property data_variables
property display_name: str

Original Name of the component (read-only)

property function_list: List[Function]

function_list List of all Functions contained within this Component

Warning:

.functions Should be used instead of this in any performance sensitive context.

Returns:

A list of functions

Example:
>>> for func in component.functions:
...  print(func.name)
property functions: Iterator[Function]

functions is an iterator for all Functions contained within this Component

Returns:

An iterator containing Components

Return type:

ComponentIterator

Example:
>>> for func in component.functions:
...  print(func.name)
property name: str

Original name set for this component

Note:

The .display_name property should be used for bv.get_component_by_path() lookups.

This can differ from the .display_name property if one of its sibling components has the same .original_name; In that case, .name will be an automatically generated unique name (e.g. “MyComponentName (1)”) while .original_name will remain what was originally set (e.g. “MyComponentName”)

If this component has a duplicate name and is moved to a component where none of its siblings share its name, the .name property will return the original “MyComponentName”

property parent: Component | None

The component that contains this component, if it exists.

property view