我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用idaapi.BWN_DISASM。
def finish_populating_tform_popup(self, form, popup): tft = idaapi.get_tform_type(form) if tft != idaapi.BWN_DISASM: return if not device_type.is_driver(): return pos = idc.ScreenEA() # If the second argument to the current selected instruction is an immediately # then give the option to decode it. if idc.GetOpType(pos, 1) == 5: register_dynamic_action(form, popup, 'Decode IOCTL', DecodeHandler()) if pos in ioctl_tracker.ioctl_locs: register_dynamic_action(form, popup, 'Invalid IOCTL', InvalidHandler()) register_dynamic_action(form, popup, 'Decode All IOCTLs in Function', DecodeAllHandler()) if len(ioctl_tracker.ioctl_locs) > 0: register_dynamic_action(form, popup, 'Show All IOCTLs', ShowAllHandler())
def activate(self, ctx): CTRL = None modifiers = QtWidgets.QApplication.keyboardModifiers() if modifiers == QtCore.Qt.AltModifier: ALT = True elif modifiers == QtCore.Qt.ControlModifier: CTRL = True if ctx.form_type == BWN_DISASM: self.actionHandler.handleIdaViewMenuAction(self.actionType) elif ctx.form_type == BWN_IMPORTS: idx = ctx.chooser_selection.at(0) self.actionHandler.handleImportViewMenuAction(self.actionType, idx-1) elif ctx.form_type == BWN_FUNCS: idx = ctx.chooser_selection.at(0) self.actionHandler.handleFuncViewMenuAction(self.actionType, idx-1) return 1 # This action is always available.
def get_cursor_func_ref(): current_tform = idaapi.get_current_tform() tform_type = idaapi.get_tform_type(current_tform) # get the hexrays vdui (if available) vu = idaapi.get_tform_vdui(current_tform) if vu: cursor_addr = vu.item.get_ea() elif tform_type == idaapi.BWN_DISASM: cursor_addr = idaapi.get_screen_ea() op_addr = idc.GetOperandValue(cursor_addr, idaapi.get_opnum()) op_func = idaapi.get_func(op_addr) if op_func and op_func.startEA == op_addr: return op_addr else: return idaapi.BADADDR cursor_func = idaapi.get_func(cursor_addr) if cursor_func and cursor_func.startEA == cursor_addr: return cursor_addr return idaapi.BADADDR
def get_custom_viewer_hint(self, view, place): try: tform = idaapi.get_current_tform() if idaapi.get_tform_type(tform) != idaapi.BWN_DISASM: return None curline = idaapi.get_custom_viewer_curline(view, True) # sometimes get_custom_viewer_place() returns [x, y] and sometimes [place_t, x, y]. # we want the place_t. viewer_place = idaapi.get_custom_viewer_place(view, True) if len(viewer_place) != 3: return None _, x, y = viewer_place ea = place.toea() # "color" is a bit of misnomer: its the type of the symbol currently hinted color = get_color_at_char(curline, x) if color != idaapi.COLOR_ADDR: return None # grab the FAR references to code (not necessarilty a branch/call/jump by itself) far_code_references = [xref.to for xref in idautils.XrefsFrom(ea, ida_xref.XREF_FAR) if idc.isCode(idc.GetFlags(xref.to))] if len(far_code_references) != 1: return None fva = far_code_references[0] # ensure its actually a function if not idaapi.get_func(fva): return None # this magic constant is the number of "important lines" to display by default. # the remaining lines get shown if you scroll down while the hint is displayed, revealing more lines. return render_function_hint(fva), DEFAULT_IMPORTANT_LINES_NUM except Exception as e: logger.warning('unexpected exception: %s. Get in touch with @williballenthin.', e, exc_info=True) return None
def update(self, ctx): if ctx.form_type == idaapi.BWN_DISASM: idaapi.attach_action_to_popup(ctx.form, None, self.name) return idaapi.AST_ENABLE_FOR_FORM return idaapi.AST_DISABLE_FOR_FORM
def updating_actions(self, ctx): if ctx.form_type == idaapi.BWN_DISASM: with ignored(sark.exceptions.SarkNoFunction): self.lines.update(highlight_calls_in_function(ctx.cur_ea)) return super(UiHooks, self).updating_actions(ctx)