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

Method register

python/plugin.py:384–417  ·  view source on GitHub ↗

r""" ``register`` Register a plugin :param str name: name of the plugin (use 'Folder\\Name' to have the menu item nested in a folder) :param str description: description of the plugin :param callback action: function to call with the :class:`~binaryview.BinaryView` as an argument :param c

(
	    cls, name: str, description: str, action: Callable[['binaryview.BinaryView'], None],
	    is_valid: Optional[Callable[['binaryview.BinaryView'], bool]] = None
	)

Source from the content-addressed store, hash-verified

382
383 @classmethod
384 def register(
385 cls, name: str, description: str, action: Callable[['binaryview.BinaryView'], None],
386 is_valid: Optional[Callable[['binaryview.BinaryView'], bool]] = None
387 ):
388 r"""
389 ``register`` Register a plugin
390
391 :param str name: name of the plugin (use 'Folder\\Name' to have the menu item nested in a folder)
392 :param str description: description of the plugin
393 :param callback action: function to call with the :class:`~binaryview.BinaryView` as an argument
394 :param callback is_valid: optional argument of a function passed a :class:`~binaryview.BinaryView` to determine whether the plugin should be enabled for that view
395 :rtype: None
396 :Example:
397
398 >>> def my_plugin(bv: BinaryView):
399 >>> log_info(f"My plugin was called on bv: `{bv}`")
400 >>> PluginCommand.register("My Plugin", "My plugin description (not used)", my_plugin)
401 True
402 >>> def is_valid(bv: BinaryView) -> bool:
403 >>> return False
404 >>> PluginCommand.register("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
405 True
406
407 .. warning:: Calling ``register`` with the same function name will replace the existing function but will leak the memory of the original plugin.
408 """
409 binaryninja._init_plugins()
410 action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
411 ctypes.POINTER(core.BNBinaryView
412 ))(lambda ctxt, view: cls._default_action(view, action))
413 is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
414 ctypes.POINTER(core.BNBinaryView
415 ))(lambda ctxt, view: cls._default_is_valid(view, is_valid))
416 cls._registered_commands.append((action_obj, is_valid_obj))
417 core.BNRegisterPluginCommand(name, description, action_obj, is_valid_obj, None)
418
419 @classmethod
420 def register_for_address(

Callers

nothing calls this directly

Calls 3

_default_actionMethod · 0.80
_default_is_validMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected