def Show(self): widget = idaapi.get_current_widget() if idaapi.get_widget_title(widget) != self.title: if idaapi.get_widget_type(widget) != idaapi.BWN_PSEUDOCODE: pseudo_view = idaapi.open_pseudocode(self.ea, 1) pseudo_view.refresh_view(1) widget = pseudo_view.toplevel pseudo_title = idaapi.get_widget_title(widget) idaapi.display_widget(self.GetWidget(), idaapi.PluginForm.WOPN_DP_TAB | idaapi.PluginForm.WOPN_RESTORE) idaapi.set_dock_pos(self.title, pseudo_title, idaapi.DP_RIGHT)
def finish_populating_widget_popup(self, widget, popup): if self.form.title == idaapi.get_widget_title(widget): idaapi.attach_dynamic_action_to_popup( widget, popup, idaapi.action_desc_t( None, "Update View", self.PopupActionHandler( self.form, self.form.menu_update), None, None, -1)) idaapi.attach_dynamic_action_to_popup( widget, popup, idaapi.action_desc_t( None, "Lookup Instruction", self.PopupActionHandler( self.form, self.form.menu_lookup), None, None, -1)) idaapi.attach_dynamic_action_to_popup( widget, popup, idaapi.action_desc_t( None, "Toggle Auto-refresh", self.PopupActionHandler( self.form, self.form.menu_autorefresh), None, None, -1)) idaapi.attach_action_to_popup( widget, popup, "-", None) idaapi.attach_dynamic_action_to_popup( widget, popup, idaapi.action_desc_t( None, "Change Architecture", self.PopupActionHandler( self.form, self.form.change_arch), None, None, -1)) idaapi.attach_action_to_popup( widget, popup, "-", None)
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()
def finish_populating_widget_popup(self, widget, popup): if self.form.title == idaapi.get_widget_title(widget): idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Update View", self.PopupActionHandler(self.form, self.form.menu_update), None, None, -1)) idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Lookup Instruction", self.PopupActionHandler(self.form, self.form.menu_lookup), None, None, -1)) idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Toggle Auto-refresh", self.PopupActionHandler(self.form, self.form.menu_autorefresh), None, None, -1)) idaapi.attach_action_to_popup(widget, popup, "-", None) idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Change Architecture", self.PopupActionHandler(self.form, self.form.change_arch), None, None, -1)) idaapi.attach_action_to_popup(widget, popup, "-", None)
def retrieve_function_callback(self, __, ea=None): if not self.check_before_use(): return funcset_ids = [self.funcset] if not self.cfg['usepublic'] else None func_ea = idaapi.get_screen_ea() if ea is None else ea func_name = idaapi.get_func_name(func_ea) targets = self.retrieve_function(func_ea, self.cfg['topk'], funcset_ids) succ, skip, fail = 0, 0, 0 if targets is None: print("[{}] {} failed because get function feature error".format( self.name, func_name)) fail += 1 else: if not (self.cview and self.cview.is_alive()): self.cview = SourceCodeViewer(self.name) # CDVF_STATUSBAR 0x04, keep the status bar in the custom viewer idaapi.set_code_viewer_is_source( idaapi.create_code_viewer(self.cview.GetWidget(), 0x4)) self.cview.set_user_data(func_ea, targets) widget = idaapi.get_current_widget() if idaapi.get_widget_title(widget) == self.name: skip += 1 else: if idaapi.get_widget_type(widget) != idaapi.BWN_PSEUDOCODE: pseudo_view = idaapi.open_pseudocode(func_ea, 1) pseudo_view.refresh_view(1) widget = pseudo_view.toplevel pseudo_title = idaapi.get_widget_title(widget) idaapi.display_widget( self.cview.GetWidget(), idaapi.PluginForm.WOPN_DP_TAB | idaapi.PluginForm.WOPN_RESTORE) idaapi.set_dock_pos(self.name, pseudo_title, idaapi.DP_RIGHT) succ += 1 print( "[{}] {} functions successfully retrieved, {} functions failed, {} functions skipped" .format(self.name, succ, fail, skip))
def touch_window(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...) if using_ida7api: twidget = idaapi.get_current_widget() title = idaapi.get_widget_title(twidget) else: form = idaapi.get_current_tform() title = idaapi.get_tform_title(form) # touch/draw the widget by playing musical chairs if using_ida7api: # touch the target window by switching to it idaapi.activate_widget(target, True) flush_ida_sync_requests() # locate our previous selection previous_twidget = idaapi.find_widget(title) # return us to our previous selection idaapi.activate_widget(previous_twidget, True) flush_ida_sync_requests() else: # touch the target window by switching to it idaapi.switchto_tform(target, True) flush_ida_sync_requests() # locate our previous selection previous_form = idaapi.find_tform(title) # lookup our original form and switch back to it idaapi.switchto_tform(previous_form, True) flush_ida_sync_requests()