Python ida_kernwin.action_desc_t() Examples

The following are 8 code examples of ida_kernwin.action_desc_t(). 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 ida_kernwin , or try the search function .
Example #1
Source File: dep_graph.py    From UEFI_RETool with MIT License 7 votes vote down vote up
def OnPopup(self, form, popup_handle):
        # graph closer
        actname = 'graph_closer:{}'.format(self.title)
        desc = ida_kernwin.action_desc_t(
            actname, 'Close: {}'.format(self.title), GraphCloser(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)

        # color changer
        actname = 'color_changer:{}'.format(self.title)
        desc = ida_kernwin.action_desc_t(
            actname, 'Change colors: {}'.format(self.title), ColorChanger(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)

        # selection printer
        actname = 'selection_printer:{}'.format(self.title)
        desc = ida_kernwin.action_desc_t(
            actname, 'Print selection: {}'.format(self.title), SelectionPrinter(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc) 
Example #2
Source File: Python_editor.py    From Python_editor with The Unlicense 6 votes vote down vote up
def editor_menuaction(self):
        action_desc = ida_kernwin.action_desc_t(
            'my:editoraction',  # The action name. This acts like an ID and must be unique
            'Python Editor!',  # The action text.
            MyEditorHandler(),  # The action handler.
            'Ctrl+H',  # Optional: the action shortcut DO IT  HERE!
            'Script editor',  # Optional: the action tooltip (available in menus/toolbar)
            ida_kernwin.load_custom_icon(":/ico/python.png")  # hackish load action icon , if no custom icon use number from 1-150 from internal ida
        )

        # 3) Register the action
        ida_kernwin.register_action(action_desc)

        ida_kernwin.attach_action_to_menu(
            'Edit/Editor...',  # The relative path of where to add the action
            'my:editoraction',  # The action ID (see above)
            ida_kernwin.SETMENU_APP)  # We want to append the action after the 'Manual instruction...

        form = ida_kernwin.get_current_tform()
        ida_kernwin.attach_action_to_popup(form, None, "my:editoraction", None) 
Example #3
Source File: hooks.py    From idapkg with MIT License 6 votes vote down vote up
def init_hooks(idausr):
    _setter = IdausrTemporarySetter(idausr)

    class ActionHandler(ida_kernwin.action_handler_t):
        def __init__(self, handler):
            ida_kernwin.action_handler_t.__init__(self)
            self.handler = handler

        def activate(self, ctx):
            with _setter:
                self.handler()

        def update(self, ctx):
            return ida_kernwin.AST_ENABLE_ALWAYS

    for name, label, handler, before in _HOOKS:
        if ida_kernwin.unregister_action(name):
            action = ida_kernwin.action_desc_t(name, label, ActionHandler(handler))
            ida_kernwin.register_action(action)
            ida_kernwin.attach_action_to_menu(before, name, ida_kernwin.SETMENU_INS) 
Example #4
Source File: stack_strings_helper.py    From flare-ida with Apache License 2.0 6 votes vote down vote up
def main():
    show_banner()

    print "Unregistering old action..."
    ida_kernwin.unregister_action(ACTION_NAME)

    if ida_hexrays.init_hexrays_plugin():
        ida_kernwin.register_action(
            ida_kernwin.action_desc_t(
                ACTION_NAME,
                "Keep sanity (stack strings)",
                stack_strings_ah_t(),
                None))

        print "Registered new action"

        idaapi.install_hexrays_callback(cb)

    else:
        print "[x] No decompiler found!"
        return 
Example #5
Source File: fn_fuzzy.py    From ida_haru with Apache License 2.0 5 votes vote down vote up
def OnPopup(self, form, popup_handle):
        actname = "choose:actFnFuzzyImport"
        desc = ida_kernwin.action_desc_t(actname, 'Import function name and prototype', import_handler_t(self.items, self.idb_path, self.title))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc) 
Example #6
Source File: actions.py    From IDArling with GNU General Public License v3.0 5 votes vote down vote up
def install(self):
        action_name = self.__class__.__name__

        # Read and load the icon file
        icon_data = open(self._icon, "rb").read()
        self._icon_id = ida_kernwin.load_custom_icon(data=icon_data)

        # Create the action descriptor
        action_desc = ida_kernwin.action_desc_t(
            self._ACTION_ID,
            self._text,
            self._handler,
            None,
            self._tooltip,
            self._icon_id,
        )

        # Register the action using its descriptor
        result = ida_kernwin.register_action(action_desc)
        if not result:
            raise RuntimeError("Failed to register action %s" % action_name)

        # Attach the action to the chosen menu
        result = ida_kernwin.attach_action_to_menu(
            self._menu, self._ACTION_ID, ida_kernwin.SETMENU_APP
        )
        if not result:
            action_name = self.__class__.__name__
            raise RuntimeError("Failed to install action %s" % action_name)

        self._plugin.logger.debug("Installed action %s" % action_name)
        return True 
Example #7
Source File: base.py    From rematch with GNU General Public License v3.0 5 votes vote down vote up
def get_desc(self):
    return ida_kernwin.action_desc_t(
      self.get_id(),
      self.get_text(),
      self,
      self.get_shortcut(),
      self.get_tooltip(),
      self.get_icon()) 
Example #8
Source File: util.py    From idapkg with MIT License 5 votes vote down vote up
def register_action(name, shortcut=''):
    def handler(f):
        # 1) Create the handler class
        class MyHandler(ida_kernwin.action_handler_t):
            def __init__(self):
                ida_kernwin.action_handler_t.__init__(self)

            # Say hello when invoked.
            def activate(self, ctx):
                t = threading.Thread(target=f)
                t.start()
                return 1

            # This action is always available.
            def update(self, ctx):
                return ida_kernwin.AST_ENABLE_ALWAYS

        # 2) Describe the action
        action_desc = ida_kernwin.action_desc_t(
            name,  # The action name. This acts like an ID and must be unique
            name,  # The action text.
            MyHandler(),  # The action handler.
            shortcut,  # Optional: the action shortcut
            name,  # Optional: the action tooltip (available in menus/toolbar)
            0)  # Optional: the action icon (shows when in menus/toolbars)

        # 3) Register the action
        ida_kernwin.register_action(action_desc)
        return f

    return handler