def zoom_and_dock(self, target): widget = ida_kernwin.get_current_widget() if widget and self.dock_position: gli = ida_moves.graph_location_info_t() if ida_graph.viewer_get_gli(gli, widget): gli.zoom = self.zoom ida_graph.viewer_set_gli(widget, gli) ida_kernwin.set_dock_pos(ida_kernwin.get_widget_title(widget), ida_kernwin.get_widget_title(target), self.dock_position) self.Refresh()
def __init__(self, parent_widget): self.parent_widget = parent_widget self.parent_title = kw.get_widget_title(self.parent_widget) i=1 while kw.find_widget("%s-%d" % (PLUGIN_NAME, i)): i+=1 self.idx = i __title = "%s-%s" % (PLUGIN_NAME, self.idx) self.options = (TEXT_INPUT_FORMS[self.parent_title].options if self.parent_title in TEXT_INPUT_FORMS.keys() else TextInputForm.SO_FILTER_TEXT | TextInputForm.SO_FIND_TEXT) self.query = (TEXT_INPUT_FORMS[self.parent_title].query if self.parent_title in TEXT_INPUT_FORMS.keys() else "") kw.Form.__init__(self, ("BUTTON YES NONE\n" "BUTTON NO NONE\n" "BUTTON CANCEL NONE\n" "%s\n\n" "{FormChangeCb}\n" "<##Enter text##Filter:{cbEditable}>" "|<##Filter type##ASCII:{rAscii}><Regex:{rRegex}>{cSearchOptions}>" "|<##Filter options##Text:{rText}><Color:{rColor}>{cFilterType}>\n" ) % (__title), {'FormChangeCb': kw.Form.FormChangeCb(self.OnFormChange), 'cbEditable': kw.Form.StringInput(value = self.query), 'cSearchOptions': kw.Form.RadGroupControl(("rAscii", "rRegex")), 'cFilterType': kw.Form.RadGroupControl(("rText", "rColor")), })
def pp_main(): global pp if pp and not pp.is_dead(): pp.die() pp = None return w = ida_kernwin.get_current_widget() title = "IDA View-A" if w: title = ida_kernwin.get_widget_title(w) title = ida_kernwin.ask_str(title, 0, "Please specify title of widget") if title: path = ida_kernwin.ask_str( "", ida_kernwin.HIST_DIR, "Please specify path containing png files to play back") if path and os.path.exists(path): files = find_files(path, "*.png") print("found %d files" % len(files)) if len(files): interval = ida_kernwin.ask_long( 100, "Please specify timer interval") if interval: pp = png_player_t(title, files, interval=interval) print("PNGs playing in widget %s" % title)
def touch_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 = ida_kernwin.get_current_widget() title = ida_kernwin.get_widget_title(twidget) # touch the target window by switching to it ida_kernwin.activate_widget(target, True) self.flush_ida_sync_requests() # locate our previous selection previous_twidget = ida_kernwin.find_widget(title) # return us to our previous selection ida_kernwin.activate_widget(previous_twidget, True) self.flush_ida_sync_requests()
def _dock_widgets(self, graph, dockpos=kw.DP_RIGHT): if graph: gv = graph.GetWidget() kw.set_dock_pos(kw.get_widget_title(gv), self.title, dockpos) gli = ida_moves.graph_location_info_t() if ida_graph.viewer_get_gli(gli, gv): gli.zoom = 0 # auto-position ida_graph.viewer_set_gli(gv, gli, ida_graph.GLICTL_CENTER) ida_graph.refresh_viewer(gv) return True return False
def _apply_query_filter(self, vu, pc): new_pc = [] title = kw.get_widget_title(vu.ct) if title in TEXT_INPUT_FORMS.keys() and pc: sq = TEXT_INPUT_FORMS[title] query = sq.query options = sq.options case_sensitive = options & TextInputForm.SO_FIND_CASE # TODO if options & TextInputForm.SO_FIND_TEXT: kw.set_highlight(vu.ct, query, HL_FLAGS) tmpquery = query.lower() if not case_sensitive else query for sl in pc: haystack = il.tag_remove(sl.line).lstrip().rstrip() haystack = haystack.lower( ) if not case_sensitive else haystack if tmpquery in haystack: new_pc.append(sl.line) else: if options & TextInputForm.SO_FILTER_COLOR: # add line but remove color new_pc.append(self._remove_color_tags(sl.line)) elif options & TextInputForm.SO_FILTER_TEXT: # do not add non-matching text pass elif options & TextInputForm.SO_FIND_REGEX: kw.set_highlight(vu.ct, None, 0) for sl in pc: try: if self._search(query, sl, case_sensitive): new_pc.append(sl.line) else: if options & TextInputForm.SO_FILTER_COLOR: new_pc.append(self._remove_color_tags(sl.line)) elif options & TextInputForm.SO_FILTER_TEXT: # do not add non-matching text pass except re.error as error: kw.msg("%s: %s: \"%s\"" % (PLUGIN_NAME, error, query)) return pc.clear() sl = kw.simpleline_t() for line in new_pc: sl.line = line pc.push_back(sl) return
def run(self, arg): w = ida_kernwin.get_current_widget() if ida_kernwin.get_widget_type(w) == ida_kernwin.BWN_PSEUDOCODE: vu = ida_hexrays.get_widget_vdui(w) vu_title = ida_kernwin.get_widget_title(w) if vu: vu.get_current_item(ida_hexrays.USE_KEYBOARD) highlight = vu.item.e if vu.item.is_citem() else None # create graphviewer cg = cfunc_graph_t(highlight, True) # build graph for current function gb = graph_builder_t(cg) gb.apply_to(vu.cfunc.body, None) # show graph cg.Show() # set zoom and dock position cg.zoom_and_dock(vu_title, ZOOM, DOCK_POSITION)
def _open_search_form(self, widget): global TEXT_INPUT_FORMS title = kw.get_widget_title(widget) if title not in TEXT_INPUT_FORMS.keys(): search_form = TextInputForm(widget) search_form.modal = False search_form.openform_flags = (kw.PluginForm.WOPN_DP_BOTTOM | kw.PluginForm.WOPN_PERSIST) search_form, _ = search_form.Compile() search_form.Open() TEXT_INPUT_FORMS[title] = search_form self._dirty_resize_hack(widget, search_form) else: search_form = TEXT_INPUT_FORMS[title] search_form.Open() search_form.init_controls() self._dirty_resize_hack(widget, search_form) return
def run(self, arg): w = ida_kernwin.get_current_widget() if ida_kernwin.get_widget_type(w) == ida_kernwin.BWN_PSEUDOCODE: vu = ida_hexrays.get_widget_vdui(w) vu_title = ida_kernwin.get_widget_title(w) if vu: vu.get_current_item(ida_hexrays.USE_KEYBOARD) focusitem = vu.item.e if vu.item.is_citem() else None # create graphviewer cg = cfunc_graph_t(focusitem, self.config, close_open=True) # build graph for current function gb = graph_builder_t(cg) gb.apply_to(vu.cfunc.body, None) # show graph cg.Show() # set zoom and dock position cg.zoom_and_dock(vu_title, self.config["options"]["zoom"], self.config["options"]["dockpos"])
def _apply_query_filter(self, vu, pc): new_pc = [] title = kw.get_widget_title(vu.ct) if title in TEXT_INPUT_FORMS.keys() and pc: sq = TEXT_INPUT_FORMS[title] query = sq.query options = sq.options # TODO if options & TextInputForm.SO_FIND_TEXT: kw.set_highlight(vu.ct, query, kw.HIF_LOCKED) for sl in pc: if query in il.tag_remove(sl.line).lstrip().rstrip(): new_pc.append(sl.line) else: if options & TextInputForm.SO_FILTER_COLOR: new_pc.append(self._remove_color_tags(sl.line)) elif options & TextInputForm.SO_FILTER_TEXT: # do not add non-matching text pass elif options & TextInputForm.SO_FIND_REGEX: kw.set_highlight(vu.ct, None, 0) for sl in pc: try: if self._search(query, sl): new_pc.append(sl.line) else: if options & TextInputForm.SO_FILTER_COLOR: new_pc.append(self._remove_color_tags(sl.line)) elif options & TextInputForm.SO_FILTER_TEXT: # do not add non-matching text pass except re.error as error: kw.msg("%s: %s: \"%s\"" % (PLUGIN_NAME, error, query)) return pc.clear() sl = kw.simpleline_t() for line in new_pc: sl.line = line pc.push_back(sl) return
def sr_main(): global sr if sr: del sr sr = None print("Stopped recording") else: w = ida_kernwin.get_current_widget() title = "IDA View-A" if w: title = ida_kernwin.get_widget_title(w) title = ida_kernwin.ask_str( title, 0, "Please specify title of widget to capture") if title: path = ida_kernwin.ask_str("", ida_kernwin.HIST_DIR, "Please specify destination path") if path and os.path.exists(path): sr = screen_record_t(title, path) print("Started recording")
def get_ctree_graph(ea): """ 在当前反编译窗口中创建当前函数的 ctree 图 """ vu = ida_hexrays.open_pseudocode(ea, 0) w = ida_kernwin.get_current_widget() vu_title = ida_kernwin.get_widget_title(w) vu.get_current_item(ida_hexrays.USE_KEYBOARD) focusitem = vu.item.e if vu.item.is_citem() else None # 创建 graphviewer cg = cfunc_graph_t(focusitem, CONFIG, close_open=True) # 为当前函数创建图像 gb = graph_builder_t(cg) gb.apply_to(vu.cfunc.body, None) # 显示图像 cg.Show() # 设置窗口位置 cg.zoom_and_dock(vu_title, CONFIG["options"]["zoom"], CONFIG["options"]["dockpos"])