Python idaapi.read_selection() Examples
The following are 5
code examples of idaapi.read_selection().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
idaapi
, or try the search function
.
Example #1
Source File: PatternGenerationWidget.py From grap with MIT License | 5 votes |
def setMatchType(self, type): try: selection, begin, end = None, None, None err = idaapi.read_selection(selection, begin, end) if err and selection: for ea in range(begin, end+1): self.cc.PatternGenerator.setMatchType(ea, type) else: self.cc.PatternGenerator.setMatchType(idc.get_screen_ea(), type) except: self.cc.PatternGenerator.setMatchType(idc.ScreenEA(), type) self._render_if_real_time()
Example #2
Source File: LazyIDA.py From LazyIDA with MIT License | 5 votes |
def finish_populating_widget_popup(self, form, popup): form_type = idaapi.get_widget_type(form) if form_type == idaapi.BWN_DISASM or form_type == idaapi.BWN_DUMP: t0, t1, view = idaapi.twinpos_t(), idaapi.twinpos_t(), idaapi.get_current_viewer() if idaapi.read_selection(view, t0, t1) or idc.get_item_size(idc.get_screen_ea()) > 1: idaapi.attach_action_to_popup(form, popup, ACTION_XORDATA, None) idaapi.attach_action_to_popup(form, popup, ACTION_FILLNOP, None) for action in ACTION_CONVERT: idaapi.attach_action_to_popup(form, popup, action, "Convert/") if form_type == idaapi.BWN_DISASM and (ARCH, BITS) in [(idaapi.PLFM_386, 32), (idaapi.PLFM_386, 64), (idaapi.PLFM_ARM, 32),]: idaapi.attach_action_to_popup(form, popup, ACTION_SCANVUL, None)
Example #3
Source File: ui.py From ida-minsc with BSD 3-Clause "New" or "Revised" License | 5 votes |
def selection(cls): '''Return the current address range of whatever is selected''' view = idaapi.get_current_viewer() left, right = idaapi.twinpos_t(), idaapi.twinpos_t() ok = idaapi.read_selection(view, left, right) if not ok: raise internal.exceptions.DisassemblerError(u"{:s}.selection() : Unable to read the current selection.".format('.'.join((__name__, cls.__name__)))) pl_l, pl_r = left.place(view), right.place(view) ea_l, ea_r = internal.interface.address.inside(pl_l.ea, pl_r.ea) return internal.interface.bounds_t(ea_l, ea_r)
Example #4
Source File: enumerators.py From idascripts with MIT License | 4 votes |
def getrange(args): """ Determines a address range. @param args: the argument list passed to the caller @return: a pair of addresses args can contain one of the following: 1) a tuple containing (first, last) 2) an area_t, containing (start_ea, end_ea) 3) nothing * if the user made a selection ( using Alt-L ), that selection is returned * otherwise from the cursor line until endoffile 4) one address: from address until the end of file 5) two addresses: the range between those addresses The range is specified as (first,last) meaning all addresses satisfying first <= addr < last """ selection, selfirst, sellast = idaapi.read_selection() if isinstance(args, idaapi.area_t): return (args.start_ea, args.end_ea) if len(args) and type(args[0])==types.TupleType: return args[0] if len(args) and isinstance(args[0], idaapi.area_t): return (args[0].start_ea, args[0].end_ea) argfirst = args[0] if len(args)>0 and type(args[0])==types.IntType else None arglast = args[1] if len(args)>1 and type(args[1])==types.IntType else None """ afirst alast sel None None 0 -> here, BADADDR None None 1 -> selection None + 0 -> here, BADADDR None + 1 -> selection + None 0 -> afirst, BADADDR + None 1 -> afirst, BADADDR + + 0 -> afirst, alast + + 1 -> afirst, alast """ if argfirst is None: if selection: return (selfirst, sellast) else: return (idc.here(), BADADDR) if arglast is None: return (argfirst, BADADDR) else: return (argfirst, arglast)
Example #5
Source File: wasm_emu.py From idawasm with Apache License 2.0 | 4 votes |
def main(): is_selected, sel_start, sel_end = idaapi.read_selection() if not is_selected: logger.error('range must be selected') return -1 sel_end = idc.NextHead(sel_end) buf = ida_bytes.get_bytes(sel_start, sel_end - sel_start) if buf is None: logger.error('failed to fetch instruction bytes') return -1 f = idaapi.get_func(sel_start) if f != idaapi.get_func(sel_end): logger.error('range must be within a single function') return -1 # find mappings from "$localN" to "custom_name" regvars = {} for i in range(0x1000): regvar = idaapi.find_regvar(f, sel_start, '$local%d' % (i)) if regvar is None: continue regvars[regvar.canon] = regvar.user if len(regvars) >= f.regvarqty: break globals_ = {} for i, offset in netnode.Netnode('$ wasm.offsets').get('globals', {}).items(): globals_['$global' + i] = ida_name.get_name(offset) frame = {} if f.frame != idc.BADADDR: names = set([]) for i in range(idc.GetStrucSize(f.frame)): name = idc.GetMemberName(f.frame, i) if not name: continue if name in names: continue frame[i] = name names.add(name) emu = Emulator(buf) emu.run() print(emu.render(ctx={ 'regvars': regvars, 'frame': frame, 'globals': globals_, }))