def force_update(): """Forcefuly requests IDA kernel to update all widgets and views. Useful for when delayed actions modify the program and/or plugin state without IDA's awareness""" iwid_all = 0xFFFFFFFF ida_kernwin.request_refresh(iwid_all) ida_kernwin.refresh_idaview_anyway() log("utils").info("Requested forceful gui update")
def set_highlight_mutual(self, status): """ TODO/COMMENT """ if status: self.view._code_sync.hook() else: self.view._code_sync.unhook() ida_kernwin.refresh_idaview_anyway()
def set_highlight_mutual(self, status): """ Toggle the highlighting of lines containing the same active address. """ if status: self.view._code_sync.hook() else: self.view._code_sync.unhook() ida_kernwin.refresh_idaview_anyway()
def nop(): """Nops-out the current instruction and advance the cursor to the next instruction.""" ea = idaapi.get_screen_ea() num_bytes = idc.get_item_size(ea) for i in range(num_bytes): ida_bytes.patch_byte(ea, 0x90) ea += 1 ida_kernwin.refresh_idaview_anyway() ida_kernwin.jumpto(ea)
def color(self): """ Property deleter for removing the color of this basicblock. .. warning:: This will **not** clear the color set by the GUI. Probably a bug in IDA. However this will clear the color set using the setter of this property. """ ida_graph.clr_node_info(self.func.ea, self._id, ida_graph.NIF_BG_COLOR) ida_kernwin.refresh_idaview_anyway()
def screen_ea_changed_ev(self, ea, prev_ea): # react to screen ea changes issued by PSEUDOCODE and DISASM views if (ida_kernwin.get_widget_type(ida_kernwin.get_current_widget()) in [ida_kernwin.BWN_PSEUDOCODE, ida_kernwin.BWN_DISASM]): self.ea = ea # why does refresh_idaview_anyway() work but request_refresh() doesn't? #ida_kernwin.clear_refresh_request(ida_kernwin.IWID_PSEUDOCODE) #ida_kernwin.request_refresh(ida_kernwin.IWID_PSEUDOCODE, True) ida_kernwin.refresh_idaview_anyway() return
def decompile(self, ea): """ TODO/COMMENT """ func = ida_funcs.get_func(ea) if not func: return False for maturity in get_mmat_levels(): mba = get_microcode(func, maturity) mtext = MicrocodeText(mba, self.model.verbose) self.model.update_mtext(mtext, maturity) self.view.refresh() ida_kernwin.refresh_idaview_anyway() return True
def select_function(self, address): """ Switch the microcode view to the specified function. """ func = ida_funcs.get_func(address) if not func: return False for maturity in get_mmat_levels(): mba = get_microcode(func, maturity) mtext = MicrocodeText(mba, self.model.verbose) self.model.update_mtext(mtext, maturity) self.view.refresh() ida_kernwin.refresh_idaview_anyway() return True
def hxe_curpos(self, vdui): """ (Event) The user cursor position changed in a Hex-Rays pseudocode window. """ self._hexrays_origin = False self._hexrays_addresses = self._get_active_vdui_addresses(vdui) if self.model.current_function != vdui.cfunc.entry_ea: self._sync_microtext(vdui) if self._ignore_move: # TODO put a refresh here ? return 0 self._hexrays_origin = True if not self._hexrays_addresses: ida_kernwin.refresh_idaview_anyway() return 0 self.controller.select_address(self._hexrays_addresses[0]) return 0
def color(self, value): """ Property setter for changing the color of this basic block. .. warning:: This will **not** set correctly the color for a block which color has already been change using the GUI. Probably a bug in IDA or another item on top of it ? :param value: An integer representing the color to set at the BGR format. If value is ``None`` delete the color. """ if value is None: ida_graph.clr_node_info(self.func.ea, self._id, ida_graph.NIF_BG_COLOR) ida_kernwin.refresh_idaview_anyway() return ni = ida_graph.node_info_t() ni.bg_color = value ida_graph.set_node_info(self.func.ea, self._id, ni, ida_graph.NIF_BG_COLOR) ida_kernwin.refresh_idaview_anyway()
def refresh_hexrays_cursor(self): """ TODO """ self._hexrays_origin = False self._hexrays_addresses = [] if not (self._sync_status and self._last_vdui): ida_kernwin.refresh_idaview_anyway() # TODO should this be here? return if not self.model.current_line or self.model.current_line.type: # special line ida_kernwin.refresh_idaview_anyway() # TODO should this be here? return vdui = self._last_vdui addr_map = self._get_vdui_address_map(vdui) current_address = self.model.current_address for line_num, addresses in addr_map.items(): if current_address in addresses: break else: self._hexrays_addresses = [] ida_kernwin.refresh_idaview_anyway() # TODO should this be here? return place, x, y = ida_kernwin.get_custom_viewer_place( self._last_vdui.ct, False) splace = ida_kernwin.place_t_as_simpleline_place_t(place) splace.n = line_num self.model.ignore_move = True ida_kernwin.jumpto(self._last_vdui.ct, splace, x, y) self.model.ignore_move = False self._hexrays_addresses = addr_map[line_num] ida_kernwin.refresh_idaview_anyway() # TODO should this be here?
def set_verbose(self, status): """ TODO/COMMENT """ self.model.verbose = status ida_kernwin.refresh_idaview_anyway()
def refresh_idaview_anyway(): if idaapi.IDA_SDK_VERSION <= 699: idc.RefreshIdaView() else: ida_kernwin.refresh_idaview_anyway()
def set_verbose(self, status): """ Toggle the verbosity of the printed microcode text. """ self.model.verbose = status ida_kernwin.refresh_idaview_anyway()
(ida_kernwin.CK_EXTRA3, 22, 45), (ida_kernwin.CK_EXTRA4, 25, 45), ])) def get_lines_rendering_info(self, out, widget, rin): for section_lines in rin.sections_lines: for line in section_lines: line_ea = line.at.toea() for ea, directives in self.color_info: if ea == line_ea: if not isinstance(directives, list): directives = [directives] for directive in directives: e = ida_kernwin.line_rendering_output_entry_t(line) if isinstance(directive, tuple): color, cpx, nchars = directive e.bg_color = color e.cpx = cpx e.nchars = nchars e.flags |= ida_kernwin.LROEF_CPS_RANGE else: e.bg_color = directive out.entries.push_back(e) lrh = lines_rendering_hooks_t() lrh.hook() # Force a refresh of IDA View-A ida_kernwin.refresh_idaview_anyway()
def color_pseudocode(self, widget, clear_old): global filename global selected_pid global tainted_pcs vu = ida_hexrays.get_widget_vdui(widget) cfunc = vu.cfunc if cfunc is None: ida_kernwin.msg("hexrays_ida_taint2: Widget has no " + "decompiled pseudocode!\n") return True if (0 == len(tainted_pcs)): # get output of ida_taint2 plugin to determine which lines get # colored filename, _ = QFileDialog.getOpenFileName(None, "Open file", ".", "CSV Files (*.csv)") if filename == "": return ida_kernwin.msg("hexrays_ida_taint2: file selected is " + filename + "\n") processes = set() input_file = open(filename, "r") reader = csv.reader(input_file) self.skip_csv_header(reader, True) for row in reader: processes.add((row[0], int(row[1]))) input_file.close() selected_pid = HIT2_ProcessSelectDialog.selectProcess(processes) # N.B.: 0 is a valid process ID if (None == selected_pid): return input_file = open(filename, "r") reader = csv.reader(input_file) tainted_pcs = set() # skip header self.skip_csv_header(reader, True) for row in reader: pid = int(row[1]) pc = int(row[2], 16) if pid != selected_pid: continue if (pc not in tainted_pcs): tainted_pcs.add(pc) input_file.close() else: ida_kernwin.msg("hexrays_ida_taint2: reusing " + filename + " and process " + str(selected_pid) + "\n") if (clear_old): self.clear_colors(cfunc) if (len(tainted_pcs) > 0): self.color_eas(cfunc, tainted_pcs) ida_kernwin.refresh_idaview_anyway() else: if (clear_old): ida_kernwin.refresh_idaview_anyway() ida_kernwin.msg("hexrays_ida_taint2: no tainted PCs found " + "for selected process\n") return 1