def _install_load_batch(self):
        """
        Install the 'File->Load->Code coverage batch...' menu entry.
        """

        # create a custom IDA icon
        icon_path = plugin_resource(os.path.join("icons", "batch.png"))
        icon_data = str(open(icon_path, "rb").read())
        self._icon_id_batch = idaapi.load_custom_icon(data=icon_data)

        # describe a custom IDA UI action
        action_desc = idaapi.action_desc_t(
            self.ACTION_LOAD_BATCH,  # The action name
            "~C~ode coverage batch...",  # The action text
            IDACtxEntry(self.interactive_load_batch),  # The action handler
            None,  # Optional: action shortcut
            "Load and aggregate code coverage files",  # Optional: tooltip
            self._icon_id_batch  # Optional: the action icon
        )

        # register the action with IDA
        result = idaapi.register_action(action_desc)
        if not result:
            RuntimeError("Failed to register load_batch action with IDA")

        # attach the action to the File-> dropdown menu
        result = idaapi.attach_action_to_menu(
            "File/Load file/",  # Relative path of where to add the action
            self.ACTION_LOAD_BATCH,  # The action ID (see above)
            idaapi.SETMENU_APP  # We want to append the action after ^
        )
        if not result:
            RuntimeError("Failed action attach load_batch")

        logger.info("Installed the 'Code coverage batch' menu entry")
Ejemplo n.º 2
0
    def _install_open_coverage_xref(self):
        """
        Install the right click 'Coverage Xref' context menu entry.
        """

        # create a custom IDA icon
        icon_path = plugin_resource(os.path.join("icons", "batch.png"))
        icon_data = open(icon_path, "rb").read()
        self._icon_id_xref = idaapi.load_custom_icon(data=icon_data)

        # describe a custom IDA UI action
        action_desc = idaapi.action_desc_t(
            self.ACTION_COVERAGE_XREF,  # The action name
            "Xrefs coverage sets...",  # The action text
            IDACtxEntry(self._pre_open_coverage_xref),  # The action handler
            None,  # Optional: action shortcut
            "List coverage sets containing this address",  # Optional: tooltip
            self._icon_id_xref  # Optional: the action icon
        )

        # register the action with IDA
        result = idaapi.register_action(action_desc)
        if not result:
            RuntimeError("Failed to register coverage_xref action with IDA")

        self._ui_hooks.hook()
        logger.info("Installed the 'Coverage Xref' menu entry")
Ejemplo n.º 3
0
    def __init__(self, core):
        super(CoverageOverview, self).__init__(
            "Coverage Overview",
            plugin_resource(os.path.join("icons", "overview.png")))
        self._core = core
        self._visible = False

        # see the EventProxy class below for more details
        self._events = EventProxy(self)
        self._widget.installEventFilter(self._events)

        # initialize the plugin UI
        self._ui_init()

        # refresh the data UI such that it reflects the most recent data
        self.refresh()
    def _install_open_coverage_overview(self):
        """
        Install the 'View->Open subviews->Coverage Overview' menu entry.
        """

        # create a custom IDA icon
        icon_path = plugin_resource(os.path.join("icons", "overview.png"))
        icon_data = str(open(icon_path, "rb").read())
        self._icon_id_overview = idaapi.load_custom_icon(data=icon_data)

        # describe a custom IDA UI action
        action_desc = idaapi.action_desc_t(
            self.ACTION_COVERAGE_OVERVIEW,  # The action name
            "~C~overage Overview",  # The action text
            IDACtxEntry(self.open_coverage_overview),  # The action handler
            None,  # Optional: action shortcut
            "Open database code coverage overview",  # Optional: tooltip
            self._icon_id_overview  # Optional: the action icon
        )

        # register the action with IDA
        result = idaapi.register_action(action_desc)
        if not result:
            RuntimeError(
                "Failed to register open coverage overview action with IDA")

        # attach the action to the View-> dropdown menu
        result = idaapi.attach_action_to_menu(
            "View/Open subviews/Hex dump",  # Relative path of where to add the action
            self.ACTION_COVERAGE_OVERVIEW,  # The action ID (see above)
            idaapi.SETMENU_INS  # We want to insert the action before ^
        )
        if not result:
            RuntimeError(
                "Failed action attach to 'View/Open subviews' dropdown")

        logger.info("Installed the 'Coverage Overview' menu entry")