我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用idaapi.get_tform_type()。
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 finish_populating_tform_popup(self, form, popup): # disassembly window if idaapi.get_tform_type(form) == idaapi.BWN_DISASMS: if get_cursor_func_ref() == idaapi.BADADDR: return idaapi.attach_action_to_popup( form, popup, funcref_t.ACTION_COPY ) # functions window elif idaapi.get_tform_type(form) == idaapi.BWN_FUNCS: idaapi.attach_action_to_popup(form, popup, funcref_t.ACTION_BULK, "Copy All", idaapi.SETMENU_INS) return 0
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 finish_populating_tform_popup(self, form, popup): """ A right click menu is about to be shown. (IDA 6.x) """ inject_prefix_actions(form, popup, idaapi.get_tform_type(form)) return 0
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