def register_handlers(): """ Register the handlers for the pop-up menu to interact with the UI """ print("GhIDA:: [DEBUG] Registering handlers") # Load a custom icon icon_path = gl.plugin_resource("ghida.png") icon_data = str(open(icon_path, "rb").read()) icon_ghida = idaapi.load_custom_icon(data=icon_data) idaapi.register_action( idaapi.action_desc_t("my:disasmsaction", "Decompile function with GhIDA", DisasmsHandler(), None, 'IDA plugin for Ghidra decompiler', icon_ghida)) disasmtracker_action = idaapi.action_desc_t( "my:disasmtracker", "Disable decompile view synchronization", DisasmTracker(), None, None, icon_ghida) idaapi.register_action(disasmtracker_action) idaapi.register_action( idaapi.action_desc_t("my:invalidatecache", "Clear cache for current function", InvalidateCache(), None, None, icon_ghida)) # Add the settings item in the menu show_settings_action = idaapi.action_desc_t('my:showsettingsaction', 'GhIDA Settings', ShowSettingsHandler(), None, 'GhIDA Settings', icon_ghida) idaapi.register_action(show_settings_action) idaapi.attach_action_to_menu('Edit/Settings/GhIDA Settings', 'my:showsettingsaction', idaapi.SETMENU_APP) # Add the view decompile window in the menu show_decomp_window_action = idaapi.action_desc_t( 'my:showdecompilewindowaction', 'GhIDA decomp view', ShowDecompWindowHandler(), None, 'GhIDA decomp view', icon_ghida) idaapi.register_action(show_decomp_window_action) idaapi.attach_action_to_menu('View/Open subviews/GhIDA', 'my:showdecompilewindowaction', idaapi.SETMENU_APP) return
def register_actions_and_handlers_decompile_view(): """ Attach the following actions in the pop-up menu of the decompiled view. """ # Load a custom icon icon_path = gl.plugin_resource("ghida.png") icon_data = str(open(icon_path, "rb").read()) icon_ghida = idaapi.load_custom_icon(data=icon_data) decompiler_widget = idaapi.find_widget('Decompiled Function') # TODO alternative # decompiler_widget = idaapi.get_current_tform() # Add Rename to the pop-up action_renamecustviewer = idaapi.action_desc_t( 'my:renamecustviewerhandler', 'Rename', RenameCustViewerHandler(DECOMP_VIEW), None, None, icon_ghida) decompiler_widget = idaapi.find_widget('Decompiled Function') idaapi.register_action(action_renamecustviewer) idaapi.attach_action_to_popup(decompiler_widget, None, "my:renamecustviewerhandler", None) # Add add-comment to the pop-up action_addcommentcustviewer = idaapi.action_desc_t( 'my:addcommentcustviewer', 'Add comment', AddCommentCustViewerHandler(DECOMP_VIEW), None, None, icon_ghida) idaapi.register_action(action_addcommentcustviewer) idaapi.attach_action_to_popup(decompiler_widget, None, "my:addcommentcustviewer", None) # Add goto to the pop-up action_gotocustviewerhandler = idaapi.action_desc_t( 'my:gotocustviewerhandler', 'Goto', GoToCustViewerHandler(DECOMP_VIEW), None, None, icon_ghida) idaapi.register_action(action_gotocustviewerhandler) idaapi.attach_action_to_popup(decompiler_widget, None, "my:gotocustviewerhandler", None) return