Python idaapi.find_widget() Examples
The following are 15
code examples of idaapi.find_widget().
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: ida_helper.py From grap with MIT License | 6 votes |
def ida_get_cfg_raw(existing_cfg=None): if "idaapi" not in sys.modules: print("ERROR: idaapi not loaded") return None import idaapi tw = idaapi.find_widget("IDAgrap") if tw is not None: import idagrap # Get CFG from existing loaded IDAgrap w = idaapi.PluginForm.FormToPyQtWidget(tw) pgw=w.findChild(idagrap.ui.widgets.PatternGenerationWidget.PatternGenerationWidget) cfg = pgw.cc.PatternGenerator.graph return cfg, True else: # If necessary, load grap and creates new CFG object if existing_cfg is None: fp, pathname, description = imp.find_module("grap") _mod = imp.load_module("grap", fp, pathname, description) cfg = _mod.CFG() return cfg, False return existing_cfg, False
Example #2
Source File: ui.py From Sark with MIT License | 6 votes |
def _make_unique_title(self, title): """Make the title unique. Adds a counter to the title to prevent duplicates. Prior to IDA 6.8, two graphs with the same title could crash IDA. This has been fixed (https://www.hex-rays.com/products/ida/6.8/index.shtml). The code will not change for support of older versions and as it is more usable this way. """ unique_title = title for counter in itertools.count(): unique_title = "{}-{}".format(title, counter) if not idaapi.find_widget(unique_title): break return unique_title
Example #3
Source File: registers.py From deREferencing with GNU General Public License v3.0 | 6 votes |
def set_window_position(self): ref_widgets = [ ("Modules", idaapi.DP_TOP), ("Threads", idaapi.DP_TOP), ("IDA View-EIP", idaapi.DP_RIGHT), ("Stack view", idaapi.DP_TOP) ] plug_window_name = "Registers - %s" % PLUGIN_NAME regs_widget = idaapi.find_widget("General registers") if regs_widget: idaapi.set_dock_pos(REGS_WIDGET_TITLE, "General registers", idaapi.DP_INSIDE) #idaapi.close_widget(regs_widget, 0) else: found = False for wname, pos in ref_widgets: if idaapi.find_widget(wname): idaapi.set_dock_pos(REGS_WIDGET_TITLE, wname, pos) found = True break if not found: idaapi.set_dock_pos(REGS_WIDGET_TITLE, None, idaapi.DP_FLOATING)
Example #4
Source File: ui.py From GhIDA with Apache License 2.0 | 5 votes |
def highlight_symbol_in_DISASM(): """ Select a symbol in the DECOMP view, highlight the corresponding symbols in IDA DISASM view. """ # print("GhIDA:: [DEBUG] highlight_symbol_in_DISASM called") disasm_widget = idaapi.find_widget('IDA View-A') symbol = None ret = ida_kernwin.get_highlight(ida_kernwin.get_current_viewer()) if ret and ret[1]: symbol = ret[0] if not symbol: # TODO improve it # Highlight a non-existing symbole idaapi.set_highlight(disasm_widget, 'aaabbbccc', 1) return True converted_symbol = from_ghidra_to_ida_syntax_conversion(symbol) if converted_symbol: # Update IDA DISASM view idaapi.set_highlight(disasm_widget, converted_symbol, 1) else: # TODO improve it # Highlight a non-existing symbole idaapi.set_highlight(disasm_widget, 'aaabbbccc', 1) return True
Example #5
Source File: ui.py From GhIDA with Apache License 2.0 | 5 votes |
def highlight_symbol_in_DECOMP(): """ Select a symbol in the IDA DISASM view, highlight the corresponding symbol in DECOMP view. """ # print("GhIDA:: [DEBUG] highlight_symbol_in_DECOMP called") symbol = None ret = ida_kernwin.get_highlight(ida_kernwin.get_current_viewer()) if ret and ret[1]: symbol = ret[0] if not symbol: return converted_symbol = from_ida_to_ghidra_syntax_conversion(symbol) decompiler_widget = idaapi.find_widget('Decompiled Function') if converted_symbol: # Update IDA DECOMP view idaapi.set_highlight(decompiler_widget, converted_symbol, 1) else: idaapi.set_highlight(decompiler_widget, 'aaabbbccc', 1) return # ------------------------------------------------------------ # RENAME SYMBOLS FORM & utils # ------------------------------------------------------------
Example #6
Source File: qt.py From Sark with MIT License | 5 votes |
def get_widget(title): """Get the Qt widget of the IDA window with the given title.""" tform = idaapi.find_widget(title) if not tform: raise exceptions.FormNotFound("No form titled {!r} found.".format(title)) return idaapi.PluginForm.FormToPyQtWidget(tform)
Example #7
Source File: qt.py From Sark with MIT License | 5 votes |
def get_window(): """Get IDA's top level window.""" tform = idaapi.get_current_widget() # Required sometimes when closing IDBs and not IDA. if not tform: tform = idaapi.find_widget("Output window") widget = idaapi.PluginForm.FormToPyQtWidget(tform) window = widget.window() return window
Example #8
Source File: ida_prefix.py From prefix with MIT License | 5 votes |
def get_selected_funcs(): """ Return the list of function names selected in the Functions window. """ import sip twidget = idaapi.find_widget("Functions window") widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget) # TODO: test this if not widget: idaapi.warning("Unable to find 'Functions window'") return # # locate the table widget within the Functions window that actually holds # all the visible function metadata # table = widget.findChild(QtWidgets.QTableView) # # scrape the selected function names from the Functions window table # selected_funcs = [str(s.data()) for s in table.selectionModel().selectedRows()] # # re-map the scraped names as they appear in the function table, to their true # names as they are saved in the IDB. See the match_funcs(...) function # comment for more details # return match_funcs(selected_funcs)
Example #9
Source File: ida_api.py From lighthouse with MIT License | 5 votes |
def show_dockable(self, dockable_name): try: make_dockable = self._dockable_factory[dockable_name] except KeyError: return False parent, dctx = None, None # not used for IDA's integration widget = make_dockable(dockable_name, parent, dctx) # get the original twidget, so we can use it with the IDA API's #twidget = idaapi.TWidget__from_ptrval__(widget) NOTE: IDA 7.2+ only... twidget = self._dockable_widgets.pop(dockable_name) if not twidget: self.warning("Could not open dockable window, because its reference is gone?!?") return # show the dockable widget flags = idaapi.PluginForm.WOPN_TAB | idaapi.PluginForm.WOPN_RESTORE | idaapi.PluginForm.WOPN_PERSIST idaapi.display_widget(twidget, flags) widget.visible = True # attempt to 'dock' the widget in a reasonable location for target in ["IDA View-A", "Pseudocode-A"]: dwidget = idaapi.find_widget(target) if dwidget: idaapi.set_dock_pos(dockable_name, 'IDA View-A', idaapi.DP_RIGHT) break
Example #10
Source File: ida_api.py From lighthouse with MIT License | 5 votes |
def _get_ida_bg_color_from_view(self): """ Get the background color of the IDA disassembly views via widget inspection. """ logger.debug("Attempting to get IDA disassembly background color from view...") names = ["Enums", "Structures"] names += ["Hex View-%u" % i for i in range(5)] names += ["IDA View-%c" % chr(ord('A') + i) for i in range(5)] # find a form (eg, IDA view) to analyze colors from for window_name in names: twidget = idaapi.find_widget(window_name) if twidget: break else: logger.debug(" - Failed to find donor view...") return None # touch the target form so we know it is populated self._touch_ida_window(twidget) # locate the Qt Widget for a form and take 1px image slice of it import sip widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget) pixmap = widget.grab(QtCore.QRect(0, 10, widget.width(), 1)) # convert the raw pixmap into an image (easier to interface with) image = QtGui.QImage(pixmap.toImage()) # return the predicted background color return QtGui.QColor(predict_bg_color(image))
Example #11
Source File: ida_api.py From lighthouse with MIT License | 5 votes |
def _touch_ida_window(self, target): """ Touch a window/widget/form to ensure it gets drawn by IDA. XXX/HACK: We need to ensure that widget we will analyze actually gets drawn so that there are colors for us to steal. To do this, we switch to it, and switch back. I tried a few different ways to trigger this from Qt, but could only trigger the full painting by going through the IDA routines. """ # get the currently active widget/form title (the form itself seems transient...) twidget = idaapi.get_current_widget() title = idaapi.get_widget_title(twidget) # touch the target window by switching to it idaapi.activate_widget(target, True) flush_qt_events() # locate our previous selection previous_twidget = idaapi.find_widget(title) # return us to our previous selection idaapi.activate_widget(previous_twidget, True) flush_qt_events() #------------------------------------------------------------------------------ # Disassembler Context API (database-specific) #------------------------------------------------------------------------------
Example #12
Source File: custom.py From deREferencing with GNU General Public License v3.0 | 5 votes |
def find_disass_view(self): widget = idaapi.find_widget('IDA View-%s' % dbg.registers.pc) if widget: return widget for c in map(chr, range(65, 75)): widget = idaapi.find_widget('IDA View-%s' % c) if widget: return widget return None
Example #13
Source File: custom.py From deREferencing with GNU General Public License v3.0 | 5 votes |
def find_hex_view(self): for i in range(1, 10): widget = idaapi.find_widget('Hex View-%d' % i) if widget: return widget return None
Example #14
Source File: stack.py From deREferencing with GNU General Public License v3.0 | 5 votes |
def set_window_position(self): stack_view = idaapi.find_widget("Stack view") if stack_view: idaapi.set_dock_pos(STACK_WIDGET_TITLE, "Stack view", idaapi.DP_INSIDE) #idaapi.close_widget(stack_view, 0) else: idaapi.set_dock_pos(STACK_WIDGET_TITLE, REGS_WIDGET_TITLE, idaapi.DP_BOTTOM)
Example #15
Source File: dereferencing.py From deREferencing with GNU General Public License v3.0 | 5 votes |
def activate(self, ctx): if self.widget_title == REGS_WIDGET_TITLE: if idaapi.find_widget(self.widget_title) is None: w = RegsFlagsViewer() w.Show(REGS_WIDGET_TITLE) w.set_window_position() elif self.widget_title == STACK_WIDGET_TITLE: if idaapi.find_widget(self.widget_title) is None: w = StackViewer() w.Create(STACK_WIDGET_TITLE) w.Show() w.set_window_position() return 1