我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用idaapi.action_desc_t()。
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"
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"
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"
def _init_action_copy(self): # load the icon for this action self._copy_icon_id = 199 # describe the action action_desc = idaapi.action_desc_t( self.ACTION_COPY, # The action name. "Copy function reference", # The action text. IDACtxEntry(copy_function_cursor), # The action handler. None, # Optional: action shortcut "Copy reference of this function", # Optional: tooltip self._copy_icon_id # Optional: the action icon ) # register the action with IDA assert idaapi.register_action(action_desc), "Action registration failed"
def ui_init(self): """Initializes the plugins interface extensions.""" # Register menu entry. # @HR: I really preferred the pre-6.5 mechanic. zelf = self class MenuEntry(idaapi.action_handler_t): def activate(self, ctx): zelf.open_proj_creation_dialog() return 1 def update(self, ctx): return idaapi.AST_ENABLE_ALWAYS action = idaapi.action_desc_t( 'continuum_new_project', "New continuum project...", MenuEntry(), ) idaapi.register_action(action) idaapi.attach_action_to_menu("File/Open...", 'continuum_new_project', 0) # Alright, is an IDB loaded? Pretend IDB open event as we miss the callback # when it was loaded before our plugin was staged. if GetIdbPath(): self.core.handle_open_idb(None, None) # Register hotkeys. idaapi.add_hotkey('Shift+F', self.core.follow_extern) # Sign up for events. self.core.project_opened.connect(self.create_proj_explorer) self.core.project_closing.connect(self.close_proj_explorer) self.core.client_created.connect(self.subscribe_client_events) # Project / client already open? Fake events. if self.core.project: self.create_proj_explorer(self.core.project) if self.core.client: self.subscribe_client_events(self.core.client)
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 = str(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")
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")
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")
def register(action, *args): idaapi.register_action( idaapi.action_desc_t( action.name, action.description, action(*args), action.hotkey ) )
def init(self): self.lines = set() self.settings = IDASettings('HighlightCalls') try: self.set_color(self.settings['color']) except KeyError: self.settings.user['color'] = HIGHLIGHT_COLOR self.set_color(HIGHLIGHT_COLOR) self.ui_hooks = UiHooks(self.lines) self.toggle_action_desc = idaapi.action_desc_t('HighlightCalls:Toggle', 'Toggle call highlighting', ToggleHighlightHandler(self.enable_highlights, self.disable_highlights), '', 'Toggle call highlighting', -1) idaapi.register_action(self.toggle_action_desc) self.color_selector = idaapi.action_desc_t('HighlightCalls:SelectColor', 'Select highlight color', SelectColorHandler(set_color=self.set_color), '', 'Select highlight color', -1) idaapi.register_action(self.color_selector) idaapi.attach_action_to_menu('Edit/', self.toggle_action_desc.name, idaapi.SETMENU_APP) idaapi.attach_action_to_menu('Edit/', self.color_selector.name, idaapi.SETMENU_APP) return idaapi.PLUGIN_KEEP
def registerAction(self): action_desc = idaapi.action_desc_t( self.id, self.name, self, self.shortcut, self.tooltip, 0 ) if not idaapi.register_action(action_desc): return False if not idaapi.attach_action_to_menu(self.menuPath, self.id, 0): return False return True
def register_dynamic_action(form, popup, description, handler): """Registers a new item in a popup which will trigger a function when selected""" # Note the 'None' as action name (1st parameter). # That's because the action will be deleted immediately # after the context menu is hidden anyway, so there's # really no need giving it a valid ID. action = idaapi.action_desc_t(None, description, handler) idaapi.attach_dynamic_action_to_popup(form, popup, action, 'Driver Plugin/')
def create_ioctl_tab(tracker, modal=False): global ioctl_tracker ioctl_tracker = tracker items = get_all_defines() action = "send_ioctl" actname = "choose2:act%s" % action idaapi.register_action( idaapi.action_desc_t( actname, "Send IOCTL", send_ioctl_handler_t(items))) idaapi.register_action( idaapi.action_desc_t( "choose2:actcopy_defines", "Copy All Defines", copy_defines_handler_t(items))) idaapi.register_action( idaapi.action_desc_t( "choose2:actstop_unload", "Stop & Unload Driver", stop_unload_handler_t())) idaapi.register_action( idaapi.action_desc_t( "choose2:actstart_load", "Load & Start Driver", start_load_handler_t())) global c c = MyChoose2("IOCTL Code Viewer", items, modal=modal) r = c.show() form = idaapi.get_current_tform() idaapi.attach_action_to_popup(form, None, "choose2:act%s" % action) idaapi.attach_action_to_popup(form, None, "choose2:actcopy_defines") idaapi.attach_action_to_popup(form, None, "choose2:actstop_unload") idaapi.attach_action_to_popup(form, None, "choose2:actstart_load")
def RegisterAction(act_name, act_text, act_handler, shortcut, tooltip, icon): newAction = action_desc_t( act_name, # The action name. This acts like an ID and must be unique act_text, # The action text. act_handler, # The action handler. shortcut, # Optional: the action shortcut tooltip, # Optional: the action tooltip (available in menus/toolbar) icon) # Optional: the action icon (shows when in menus/toolbars) register_action(newAction)
def _init_action_bulk(self): """ Register the bulk prefix action with IDA. """ icon_data = "".join([ "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1F\xF3\xFF\x61\x00\x00\x02\xCA\x49\x44\x41\x54\x78\x5E\x65", "\x53\x6D\x48\x53\x6F\x14\x3F\xBA\xB5\xB7\xA0\x8D\x20\x41\xF2\xBA\x5D\xB6\x0F\x56\xF4\x41\xA2\xC0\x9C\xE9\xB4\x29\x4A\x7D\xB0\x22\x7A\x11\x02\x23\x48\x2A\xD4\x74\x53\x33\x3F\xD4", "\x3E\x4A\x50\x19\xE4\xB0\xD0\x22\xCD\x44\x45\x4A\x31\x8C\x92\xA2\x3E\x65\x0A\x4D\xCB\x96\x7E\xE8\xD5\x97\xCC\xFE\xFE\x37\xA7\x77\xDB\xBD\xA7\xE7\x3C\xBE\x05\x9E\xED\xB7\xB3\xF3", "\x7B\x39\xF7\xEE\x19\x17\xA8\xAC\x56\xDB\x54\x82\x60\x41\xB3\x59\xBC\xFF\xAC\xF9\xCA\xB5\xAE\x86\xCA\xF9\x4E\xAF\x1B\x3B\xEA\x5D\x48\x9D\x66\xE2\x49\x27\x9F\xD5\x66\x9B\xA2\x1C", "\x22\x02\xD0\x40\xE4\x81\x6C\x3B\x76\x37\x56\xE3\x37\x5F\x2F\x62\xE8\x0B\xD3\x66\x19\x7E\x53\xA7\x99\x78\xAE\x1F\x64\x3E\x21\x71\x69\x09\x5F\x20\x98\x2D\x58\x70\x24\x07\x07\x7B", "\x6F\xB0\x79\x82\x61\x81\x21\xCC\xDE\x21\x54\x16\x02\xD4\x69\x26\x9E\x74\xEE\xCB\xCF\x4D\xC7\x44\xB3\x88\x7C\x81\xC5\x22\xFE\x6C\xB9\xE9\x46\x67\x46\x1A\x8A\x16\x2B\x0A\x5B\x05", "\x74\x66\x65\xE1\x98\x6F\x00\x31\x32\x87\x9F\x59\x77\x66\x66\x61\x42\xBC\xC0\xF5\x6C\x47\x1A\x36\xD7\xB9\x51\x14\xC5\x1E\xBE\xA0\xC3\x5B\xD9\x98\x99\xE1\xC0\xCE\xBE\x57\x48\xD7", "\x9A\x63\x68\xEA\x7C\x8A\xF6\x14\x3B\x9F\xF6\xA6\xA4\x60\xEB\xE3\x3E\x9C\x5F\xD6\x5A\x7A\xFA\x71\xBF\xC3\x81\x3D\x4D\x35\x0D\x7C\xC1\xF3\x87\x57\x43\xF9\x87\x8F\x21\x95\x5E\xAB", "\x41\x83\x4E\x83\x54\xDB\x92\x76\x20\xCA\xBF\xD0\x99\x9D\xBB\x4E\xDB\xBD\xC7\x8E\x2F\x5A\x3D\x74\x3D\x50\x03\x80\x7E\x7A\x7A\x06\x46\x47\xFD\xA0\x33\x6C\x84\x18\x46\x0C\xBD\x1F", "\x86\x2D\x71\x71\x00\x52\x10\x16\x17\xE6\xC1\xE7\x1B\x61\x9A\x81\x69\x31\x30\xFC\x61\x14\xB4\x3A\x3D\x20\x82\x1E\x58\xA9\x15\x05\x41\x14\x05\xB8\x58\xEE\x82\x7D\xE9\x99\x20\xCB", "\x32\x94\x95\x95\xC3\xA5\xD2\x53\x00\x51\x09\xAA\x4B\x0B\xA1\xB8\xA4\x0C\x52\x53\x33\x40\xA5\x52\x81\xDB\x5D\x01\xA2\x45\x00\x45\x51\x80\x2A\x36\x12\x8D\x42\x49\x51\x01\x44\xE5", "\x18\x90\x22\x0A\x98\x8C\x46\xF0\x54\x14\x42\x6D\x7D\x3B\xE4\x1C\x75\x41\xAD\xB7\x1D\x3C\x55\x85\x60\x32\x19\x41\x8A\x2A\xDC\x57\x5C\x74\x12\x28\x47\xA5\x8E\x44\xE4\xF0\x76\x5B", "\x82\xA6\xCD\x5B\x0D\xB2\x12\xE6\xE4\x06\xB5\x1A\x66\xA7\x26\x41\x92\xC2\xA0\xD5\x6A\x60\x67\x92\x19\xAE\x7B\xCE\x70\x4D\x15\xAB\x01\xAD\xC1\x08\x3F\x46\x64\x6E\x8E\x9D\xF9\x13", "\xE8\x1A\xFF\xE4\x63\x8A\x0E\xE6\x02\x41\xF8\x3F\x18\x82\x40\x28\x04\xFD\xDD\x75\xF0\xB6\xFF\x2E\x75\x9A\x89\x27\x9D\xFB\xC8\x4F\x39\xBE\xE0\xB4\xAB\xCE\x35\xFE\x71\x00\x16\x17", "\x25\x76\x50\x26\x76\x6B\x61\x86\x08\xE4\x1D\xAF\x81\xBC\x13\x97\xA9\xD3\x4C\x3C\xE9\xDC\x47\x7E\xCA\xF1\x05\x0C\x5F\x7D\xFE\xEF\x35\x03\xAF\x9F\x00\xB0\x73\x30\x9A\xE2\x81\x0E", "\xF6\xC1\xED\x52\xB8\x77\xAB\x98\x3A\xCD\xC4\x73\x9D\x7C\x6F\xDE\xF9\xCF\x53\x0E\xFE\xA9\xCD\xAE\xB3\x87\xCE\x75\x35\x54\xE1\xD0\xCB\x47\x38\x39\x36\x88\xFF\x4D\xF8\x57\x41\x33", "\xF1\xA4\x93\x0F\x00\x36\xAD\x3E\x4C\x6B\xC5\xC9\x5D\x77\x6A\x2F\xB4\x31\xA3\xC4\x40\x4F\x21\x0F\xD1\x4C\x3C\xE9\x2B\xE1\xF5\x0B\xD6\x90\xC8\x90\x4C\xE6\x35\xD0\xCC\x79\x5E\xFF", "\x2E\xF8\x0B\x2F\x3D\xE5\xC3\x97\x06\xCF\xCF\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82"]) # load the icon for this action self._bulk_icon_id = idaapi.load_custom_icon(data=icon_data, format="png") # describe the action action_desc = idaapi.action_desc_t( self.ACTION_BULK, # The action name. "Copy function pointers to selected function(s)", # The action text. IDACtxEntry(bulk_function), # The action handler. None, # Optional: action shortcut "Copies a function pointer to the selected function(s)", # Optional: tooltip self._bulk_icon_id # Optional: the action icon ) # register the action with IDA assert idaapi.register_action(action_desc), "Action registration failed"
def register_actions(): AncestorGraphHandler = OpenGraphHandler() def type_of_current_var(vdui): var = vdui.item.get_lvar() if var is None: return None return get_type_by_tinfo(var.type()) def graph_callback(event, *args): if event == idaapi.hxe_curpos: vdui = args[0] type = type_of_current_var(vdui) AncestorGraphHandler.target_type = type elif event == idaapi.hxe_populating_popup: form, popup, vdui = args if AncestorGraphHandler.target_type is None: return 0 action_desc = idaapi.action_desc_t( None, 'Open Ancestor Type Graph', AncestorGraphHandler) idaapi.attach_dynamic_action_to_popup(form, popup, action_desc, None) return 0 action_desc = idaapi.action_desc_t( 'devirtualize:open_ancestor_type_graph', 'Open Ancestor Type Graph', AncestorGraphHandler, None, 'Open Ancestor Type Graph', 199) idaapi.register_action(action_desc) idaapi.attach_action_to_menu( 'View/Graphs/User xrefs char...', 'devirtualize:open_ancestor_type_graph', idaapi.SETMENU_APP) idaapi.install_hexrays_callback(graph_callback) #TODO: Show diamond inheritance as a diamond