Python idaapi.load_custom_icon() Examples

The following are 16 code examples of idaapi.load_custom_icon(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module idaapi , or try the search function .
Example #1
Source File: DIE.py    From DIE with MIT License 6 votes vote down vote up
def load_icon(self, icon_filename, icon_key_name):
        """
        Load a single custom icon
        @param icon_filename: Icon file name
        @param icon_key_name: The key value to store the icon with in the icon_list.
        """
        try:
            icons_path = self.die_config.icons_path

            icon_filename = os.path.join(icons_path, icon_filename)
            icon_num = idaapi.load_custom_icon(icon_filename)
            self.icon_list[icon_key_name.lower()] = icon_num
            return True

        except Exception as ex:
            self.logger.error("Failed to load icon %s: %s", icon_filename, ex)
            return False 
Example #2
Source File: ida_prefix.py    From prefix with MIT License 6 votes vote down vote up
def _init_action_bulk(self):
        """
        Register the bulk prefix action with IDA.
        """

        # load the icon for this action
        self._bulk_icon_id = idaapi.load_custom_icon(plugin_resource("bulk.png"))

        # describe the action
        action_desc = idaapi.action_desc_t(
            self.ACTION_BULK,                        # The action name.
            "Prefix selected functions",             # The action text.
            IDACtxEntry(bulk_prefix),                # The action handler.
            None,                                    # Optional: action shortcut
            "Assign a user prefix to the selected functions", # Optional: tooltip
            self._bulk_icon_id                       # Optional: the action icon
        )

        # register the action with IDA
        assert idaapi.register_action(action_desc), "Action registration failed" 
Example #3
Source File: ida_prefix.py    From prefix with MIT License 6 votes vote down vote up
def _init_action_clear(self):
        """
        Register the clear prefix action with IDA.
        """

        # load the icon for this action
        self._clear_icon_id = idaapi.load_custom_icon(plugin_resource("clear.png"))

        # describe the action
        action_desc = idaapi.action_desc_t(
            self.ACTION_CLEAR,                       # The action name.
            "Clear prefixes",                        # The action text.
            IDACtxEntry(clear_prefix),               # The action handler.
            None,                                    # Optional: action shortcut
            "Clear user prefixes from the selected functions", # Optional: tooltip
            self._clear_icon_id                      # Optional: the action icon
        )

        # register the action with IDA
        assert idaapi.register_action(action_desc), "Action registration failed" 
Example #4
Source File: ida_prefix.py    From prefix with MIT License 6 votes vote down vote up
def _init_action_recursive(self):
        """
        Register the recursive rename action with IDA.
        """

        # load the icon for this action
        self._recursive_icon_id = idaapi.load_custom_icon(plugin_resource("recursive.png"))

        # describe the action
        action_desc = idaapi.action_desc_t(
            self.ACTION_RECURSIVE,                   # The action name.
            "Recursive function prefix",             # The action text.
            IDACtxEntry(recursive_prefix_cursor),    # The action handler.
            None,                                    # Optional: action shortcut
            "Recursively prefix callees of this function", # Optional: tooltip
            self._recursive_icon_id                  # Optional: the action icon
        )

        # register the action with IDA
        assert idaapi.register_action(action_desc), "Action registration failed" 
Example #5
Source File: PatternGenerationWidget.py    From grap with MIT License 5 votes vote down vote up
def _createContextActions(self): 
        actions = [
            ("grap:pg:set_root", None, "[grap] Set root node", self._onSetRootNode),
            ("grap:pg:add_target", None, "[grap] Add target node", self._onAddTargetNode),
            ("grap:pg:match_default", config['icons_path'] + "icons8-asterisk-24.png", "[grap] Default match (apply options)", self._onSetMatchDefault),
            ("grap:pg:match_full", None, "[grap] Full match", self._onSetMatchFull),
            ("grap:pg:match_opcode_arg1", None, "[grap] Opcode+arg1", self._onSetMatchOpcodeArg1),
            ("grap:pg:match_opcode_arg2", None, "[grap] Opcode+arg2", self._onSetMatchOpcodeArg2),
            ("grap:pg:match_opcode_arg3", None, "[grap] Opcode+arg3", self._onSetMatchOpcodeArg3),
            ("grap:pg:match_opcode", None, "[grap] Opcode", self._onSetMatchOpcode),
            ("grap:pg:match_wildcard", None, "[grap] Wildcard: *", self._onSetMatchWildcard),
            ("grap:pg:remove_target", config['icons_path'] + "icons8-delete.png", "[grap] Remove target node", self._onRemoveTargetNode)
        ]

        for actionId, icon_path, text, method in (a for a in actions):
            if icon_path is not None and icon_path != "":
                icon_number = idaapi.load_custom_icon(icon_path)
                # Describe the action
                action_desc = idaapi.action_desc_t(
                    actionId,  # The action name. This acts like an ID and must be unique
                    text,  # The action text.
                    PatternGenerationHandler(method), # The action handler.
                    None,
                    None,
                    icon_number)  
            else:
                # Describe the action
                action_desc = idaapi.action_desc_t(
                    actionId,  # The action name. This acts like an ID and must be unique
                    text,  # The action text.
                    PatternGenerationHandler(method)) # The action handler.  

            # Register the action
            idaapi.register_action(action_desc)

        self.actionsDefined = True 
Example #6
Source File: PatternGenerationWidget.py    From grap with MIT License 5 votes vote down vote up
def __init__(self, cc):
        idaapi.UI_Hooks.__init__(self)
        self.cc = cc
        self.selected_icon_number = idaapi.load_custom_icon(config['icons_path'] + "icons8-asterisk-24.png") 
Example #7
Source File: brutal_ida.py    From BRUTAL-IDA with MIT License 5 votes vote down vote up
def get_brutal_icon_path(brutal_icon_name):
    return idaapi.load_custom_icon(os.path.join(os.path.dirname(__file__), 'BRUTAL-ICONS', brutal_icon_name)) 
Example #8
Source File: ida_integration.py    From lighthouse with MIT License 5 votes vote down vote up
def _install_load_file(self):
        """
        Install the 'File->Load->Code coverage file...' menu entry.
        """

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

        # describe a custom IDA UI action
        action_desc = idaapi.action_desc_t(
            self.ACTION_LOAD_FILE,                   # The action name
            "~C~ode coverage file...",               # The action text
            IDACtxEntry(self.interactive_load_file), # The action handler
            None,                                    # Optional: action shortcut
            "Load individual code coverage file(s)", # Optional: tooltip
            self._icon_id_file                       # Optional: the action icon
        )

        # register the action with IDA
        result = idaapi.register_action(action_desc)
        if not result:
            RuntimeError("Failed to register load_file 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_FILE,  # The action ID (see above)
            idaapi.SETMENU_APP      # We want to append the action after ^
        )
        if not result:
            RuntimeError("Failed action attach load_file")

        logger.info("Installed the 'Code coverage file' menu entry") 
Example #9
Source File: ida_integration.py    From lighthouse with MIT License 5 votes vote down vote up
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 = 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") 
Example #10
Source File: ida_integration.py    From lighthouse with MIT License 5 votes vote down vote up
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") 
Example #11
Source File: ida_integration.py    From lighthouse with MIT License 5 votes vote down vote up
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 = 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") 
Example #12
Source File: Reef.py    From Reef with GNU General Public License v3.0 5 votes vote down vote up
def init( self ):

        self.icon_id = idaapi.load_custom_icon( data = ReefConfig.PLUGIN_ICON_PNG, 
                                                format = "png"    )
        if self.icon_id == 0:
            raise RuntimeError("Failed to load icon data!")

        self.finder = XrefsFromFinder()

        return idaapi.PLUGIN_KEEP 
Example #13
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def AddMenuElements(self):
        idaapi.add_menu_item("File/", "Code editor", "Alt-E", 0, self.popeye, ())
        idaapi.set_menu_item_icon("File/Code editor", idaapi.load_custom_icon(":/ico/python.png")) 
Example #14
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def AddMenuElements(self):
        idaapi.add_menu_item("File/", "Code editor", "Alt-E", 0, self.popeye, ())
        idaapi.set_menu_item_icon("File/Code editor", idaapi.load_custom_icon(":/ico/python.png")) 
Example #15
Source File: Stingray.py    From Stingray with GNU General Public License v3.0 5 votes vote down vote up
def init( self ):

        self.icon_id = idaapi.load_custom_icon( data = ConfigStingray.PLUGIN_ICON_PNG, 
                                                format = "png"    )
        if self.icon_id == 0:
            raise RuntimeError("Failed to load icon data!")

        self.finder = StringFinder()

        ConfigStingray.init()

        return idaapi.PLUGIN_KEEP 
Example #16
Source File: neo4ida.py    From ida-scripts with The Unlicense 5 votes vote down vote up
def __init__(self, id, name, tooltip, menuPath, callback, icon):
        idaapi.action_handler_t.__init__(self)
        self.id = id
        self.name = name
        self.tooltip = tooltip
        self.menuPath = menuPath
        self.callback = callback
        scriptPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
        self.icon = idaapi.load_custom_icon(
            scriptPath + "/" + "icon" + ".png"
        )