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_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_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_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: Iterator[Component]

components is an iterator for all Components contained within this Component

Returns

An iterator containing Components

Return type

SubComponentIterator

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

Original Name of the component (read-only)

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: Optional[Component]

The component that contains this component, if it exists.

property view