MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / create_component

Method create_component

python/binaryview.py:7128–7157  ·  view source on GitHub ↗

Create a new component with an optional name and parent. The `parent` argument can be either a Component or the Guid of a component that the created component will be added as a child of :param name: Optional name to create the component with :param parent: Optional parent to which the

(self, name: Optional[str] = None, parent: Union[component.Component, str, None] = None)

Source from the content-addressed store, hash-verified

7126 return component.Component(core.BNGetRootComponent(self.handle))
7127
7128 def create_component(self, name: Optional[str] = None, parent: Union[component.Component, str, None] = None) -> component.Component:
7129 """
7130 Create a new component with an optional name and parent.
7131
7132 The `parent` argument can be either a Component or the Guid of a component that the created component will be
7133 added as a child of
7134
7135 :param name: Optional name to create the component with
7136 :param parent: Optional parent to which the component will be added
7137 :return: The created component
7138 """
7139
7140 if parent:
7141 if isinstance(parent, component.Component):
7142 if name:
7143 return component.Component(core.BNCreateComponentWithParentAndName(self.handle, parent.guid, name))
7144 else:
7145 return component.Component(core.BNCreateComponentWithParent(self.handle, parent.guid))
7146 elif isinstance(parent, str):
7147 if name:
7148 return component.Component(core.BNCreateComponentWithParentAndName(self.handle, parent, name))
7149 else:
7150 return component.Component(core.BNCreateComponentWithParent(self.handle, parent))
7151 else:
7152 raise TypeError("parent can only be a Component object or string GUID representing one")
7153 else:
7154 if name:
7155 return component.Component(core.BNCreateComponentWithName(self.handle, name))
7156 else:
7157 return component.Component(core.BNCreateComponent(self.handle))
7158
7159 def remove_component(self, _component: Union[component.Component, str]) -> bool:
7160 """

Callers

nothing calls this directly

Calls 1

ComponentMethod · 0.80

Tested by

no test coverage detected