Python idaapi.get_screen_ea() Examples

The following are 19 code examples for showing how to use idaapi.get_screen_ea(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module idaapi , or try the search function .

Example 1
Project: grap   Author: AirbusCyber   File: PatternGenerationWidget.py    License: MIT License 6 votes vote down vote up
def _onFuncButtonClicked(self):
        if not self.cc.PatternGenerator.graph.graph:
            print("WARNING: Unloaded CFG. Make sure to first \"Load the CFG\"")
            return

        ea = idaapi.get_screen_ea()
        if ea:
            func = idaapi.ida_funcs.get_func(ea)
            if func:
                if self.cc.PatternGenerator.rootNode is None:
                    print("[I] Adding root node as function entrypoint: %x", func.start_ea)
                    self.cc.PatternGenerator.setRootNode(func.start_ea)

                print("[I] Adding nodes to cover whole function")
                flowchart = idaapi.FlowChart(func)
                for bb in flowchart:
                    last_inst_addr = idc.prev_head(bb.end_ea)
                    self.cc.PatternGenerator.addTargetNode(last_inst_addr)

                self._render_if_real_time() 
Example 2
Project: LazyIDA   Author: L4ys   File: LazyIDA.py    License: MIT License 6 votes vote down vote up
def activate(self, ctx):
        if self.action == ACTION_HX_REMOVERETTYPE:
            vdui = idaapi.get_widget_vdui(ctx.widget)
            self.remove_rettype(vdui)
            vdui.refresh_ctext()
        elif self.action == ACTION_HX_COPYEA:
            ea = idaapi.get_screen_ea()
            if ea != idaapi.BADADDR:
                copy_to_clip("0x%X" % ea)
                print("Address 0x%X has been copied to clipboard" % ea)
        elif self.action == ACTION_HX_COPYNAME:
            name = idaapi.get_highlight(idaapi.get_current_viewer())[0]
            if name:
                copy_to_clip(name)
                print("%s has been copied to clipboard" % name)
        elif self.action == ACTION_HX_GOTOCLIP:
            loc = parse_location(clip_text())
            print("Goto location 0x%x" % loc)
            idc.jumpto(loc)
        else:
            return 0

        return 1 
Example 3
Project: IDAngr   Author: andreafioraldi   File: main_gui.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def activate(self, ctx):
        global _idangr_ctx, _idangr_panel
        if self.action == "Find":
            addr = idaapi.get_screen_ea()
            if addr in _idangr_ctx.avoid:
                _idangr_ctx.avoid.remove(addr)
                _idangr_panel.remove_avoid(addr)
            if addr in _idangr_ctx.find:
                return
            _idangr_ctx.find.append(addr)
            _idangr_panel.add_find(addr)
        elif self.action == "Avoid":
            addr = idaapi.get_screen_ea()
            if addr in _idangr_ctx.find:
                _idangr_ctx.find.remove(addr)
                _idangr_panel.remove_find(addr)
            if addr in _idangr_ctx.avoid:
                return
            _idangr_ctx.avoid.append(addr)
            _idangr_panel.add_avoid(addr)
        elif self.action == "Symbolic":
            addr = idaapi.get_screen_ea()
            #if addr in _idangr_ctx.simmem:
            #    return
            m = IDAngrAddMemDialog.get_mem(addr)
            if m != None:
                _idangr_panel.add_mem(m[0], m[1])
                #_idangr_ctx.simmem.append(m) 
Example 4
Project: grap   Author: AirbusCyber   File: PatternGenerationWidget.py    License: MIT License 5 votes vote down vote up
def _onSetRootNode(self):
        try:
            self.cc.PatternGenerator.setRootNode(idc.get_screen_ea())
        except:
            self.cc.PatternGenerator.setRootNode(idc.ScreenEA())

        self._render_if_real_time() 
Example 5
Project: grap   Author: AirbusCyber   File: PatternGenerationWidget.py    License: MIT License 5 votes vote down vote up
def _onAddTargetNode(self):
        try:
            self.cc.PatternGenerator.addTargetNode(idc.get_screen_ea())
        except:
            self.cc.PatternGenerator.addTargetNode(idc.ScreenEA())

        self._render_if_real_time() 
Example 6
Project: grap   Author: AirbusCyber   File: PatternGenerationWidget.py    License: MIT License 5 votes vote down vote up
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 7
Project: grap   Author: AirbusCyber   File: PatternGenerationWidget.py    License: MIT License 5 votes vote down vote up
def _onRemoveTargetNode(self):
        try:
            self.cc.PatternGenerator.removeTargetNode(idc.get_screen_ea())
        except:
            self.cc.PatternGenerator.removeTargetNode(idc.ScreenEA())

        self._render_if_real_time() 
Example 8
Project: Sark   Author: tmr232   File: codeblock.py    License: MIT License 5 votes vote down vote up
def __init__(self, id_ea=None, bb=None, fc=None):
        if bb is None and fc is None:
            if id_ea is None:
                id_ea = idaapi.get_screen_ea()
            temp_codeblock = get_codeblock(id_ea)
            self.__dict__.update(temp_codeblock.__dict__)
        else:
            super(CodeBlock, self).__init__(id=id_ea, bb=bb, fc=fc) 
Example 9
Project: Sark   Author: tmr232   File: codeblock.py    License: MIT License 5 votes vote down vote up
def __init__(self, f=None, bounds=None, flags=idaapi.FC_PREDS, ignore_external=False):
        if f is None and bounds is None:
            f = idaapi.get_screen_ea()
        if f is not None:
            f = get_func(f)
        if ignore_external:
            flags |= idaapi.FC_NOEXT

        super(FlowChart, self).__init__(f=f, bounds=bounds, flags=flags) 
Example 10
Project: Sark   Author: tmr232   File: codeblock.py    License: MIT License 5 votes vote down vote up
def get_flowchart(ea=None):
    if ea is None:
        ea = idaapi.get_screen_ea()
    func = idaapi.get_func(ea)
    flowchart_ = FlowChart(func)
    return flowchart_ 
Example 11
Project: Sark   Author: tmr232   File: codeblock.py    License: MIT License 5 votes vote down vote up
def get_codeblock(ea=None):
    if ea is None:
        ea = idaapi.get_screen_ea()
    flowchart_ = get_flowchart(ea)
    for code_block in flowchart_:
        if code_block.start_ea == ea: # External blocks can be zero-sized.
            return code_block
        if code_block.start_ea <= ea < code_block.end_ea:
            return code_block 
Example 12
Project: lighthouse   Author: gaasedelen   File: ida_integration.py    License: MIT License 5 votes vote down vote up
def _pre_open_coverage_xref(self):
        """
        Grab a contextual address before opening the coverage xref dialog.
        """
        self.open_coverage_xref(idaapi.get_screen_ea())

#------------------------------------------------------------------------------
# IDA UI Helpers
#------------------------------------------------------------------------------ 
Example 13
Project: lighthouse   Author: gaasedelen   File: ida_api.py    License: MIT License 5 votes vote down vote up
def get_current_address(self):
        return idaapi.get_screen_ea() 
Example 14
Project: LazyIDA   Author: L4ys   File: LazyIDA.py    License: MIT License 5 votes vote down vote up
def activate(self, ctx):
        if self.action == ACTION_COPYEA:
            ea = idc.get_screen_ea()
            if ea != idaapi.BADADDR:
                copy_to_clip("0x%X" % ea)
                print("Address 0x%X has been copied to clipboard" % ea)
        elif self.action == ACTION_GOTOCLIP:
            loc = parse_location(clip_text())
            if loc != idaapi.BADADDR:
                print("Goto location 0x%x" % loc)
                idc.jumpto(loc)
        return 1 
Example 15
Project: LazyIDA   Author: L4ys   File: LazyIDA.py    License: MIT License 5 votes vote down vote up
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 16
Project: source   Author: daenerys-sre   File: idc.py    License: MIT License 5 votes vote down vote up
def ScreenEA(): 
	return idaapi.get_screen_ea() 
Example 17
Project: source   Author: daenerys-sre   File: idc.py    License: MIT License 5 votes vote down vote up
def here(): 
	return idaapi.get_screen_ea() 
Example 18
Project: ida-minsc   Author: arizvisa   File: ui.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def address(cls):
        '''Return the current address.'''
        return idaapi.get_screen_ea() 
Example 19
Project: prefix   Author: gaasedelen   File: ida_prefix.py    License: MIT License 4 votes vote down vote up
def get_cursor_func_ref():
    """
    Get the function reference under the user cursor.

    Returns BADADDR or a valid function address.
    """
    current_widget = idaapi.get_current_widget()
    form_type      = idaapi.get_widget_type(current_widget)
    vu = idaapi.get_widget_vdui(current_widget)

    #
    # hexrays view is active
    #

    if vu:
        cursor_addr = vu.item.get_ea()

    #
    # disassembly view is active
    #

    elif form_type == idaapi.BWN_DISASM:
        cursor_addr = idaapi.get_screen_ea()
        opnum = idaapi.get_opnum()

        if opnum != -1:

            #
            # if the cursor is over an operand value that has a function ref,
            # use that as a valid rename target
            #

            op_addr = idc.get_operand_value(cursor_addr, opnum)
            op_func = idaapi.get_func(op_addr)

            if op_func and op_func.start_ea == op_addr:
                return op_addr

    # unsupported/unknown view is active
    else:
        return idaapi.BADADDR

    #
    # if the cursor is over a function definition or other reference, use that
    # as a valid rename target
    #

    cursor_func = idaapi.get_func(cursor_addr)
    if cursor_func and cursor_func.start_ea == cursor_addr:
        return cursor_addr

    # fail
    return idaapi.BADADDR