Exemplo n.º 1
0
    def callback(self, event, *args):
        if event == idaapi.hxe_populating_popup:
            form, phandle, vu = args
            if vu.item.citype == idaapi.VDI_FUNC or ( vu.item.citype == idaapi.VDI_EXPR and vu.item.e.is_expr() and vu.item.e.type.is_funcptr() ):
                idaapi.attach_action_to_popup(form, phandle, ACTION_HX_REMOVERETTYPE, None)

        return 0
Exemplo n.º 2
0
    def callback(self, event, *args):
        if event == idaapi.hxe_populating_popup:
            form, phandle, vu = args
            if vu.item.citype == idaapi.VDI_FUNC or (vu.item.citype == idaapi.VDI_EXPR and vu.item.e.is_expr() and vu.item.e.type.is_funcptr()):
                idaapi.attach_action_to_popup(form, phandle, ACTION_HX_REMOVERETTYPE, None)
        elif event == idaapi.hxe_double_click:
            vu, shift_state = args
            # auto jump to target if clicked item is xxx->func();
            if vu.item.citype == idaapi.VDI_EXPR and vu.item.e.is_expr():
                expr = idaapi.tag_remove(vu.item.e.print1(None))
                if "->" in expr:
                    # find target function
                    name = expr.split("->")[-1]
                    addr = LocByName(name)
                    if addr == idaapi.BADADDR:
                        # try class::function
                        e = vu.item.e
                        while e.x:
                            e = e.x
                        addr = LocByName("%s::%s" % (str(e.type).split()[0], name))

                    if addr != idaapi.BADADDR:
                        Jump(addr)
                        return 1
        return 0
Exemplo n.º 3
0
def test_choose2(modal=False):
    global c
    c = MyChoose2("Choose2 - sample 1", nb=10, modal=modal)
    r = c.show()
    form = idaapi.get_current_tform()
    for thing in ["A", "B"]:
        idaapi.attach_action_to_popup(form, None, "choose2:act%s" % thing)
 def finish_populating_tform_popup(self, form, popup):
     if idaapi.get_tform_title(form).startswith("IDA View"):
         idaapi.attach_action_to_popup(
             form,
             popup,
             "Kam1n0:indexCurrent",
             None)
         idaapi.attach_action_to_popup(
             form,
             popup,
             "Kam1n0:queryCurrent",
             None)
         idaapi.attach_action_to_popup(
             form,
             popup,
             "Kam1n0:queryFragment",
             None)
     if idaapi.get_tform_title(form) == "Functions window":
         idaapi.attach_action_to_popup(
             form,
             popup,
             "Kam1n0:querySelected",
             None)
         idaapi.attach_action_to_popup(
             form,
             popup,
             "Kam1n0:indexSelected",
             None)
Exemplo n.º 5
0
 def finish_populating_widget_popup(self, widget, popup):
     if self.form.title == idaapi.get_widget_title(widget):
         idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Update View", self.PopupActionHandler(self.form, self.form.menu_update),   None, None, -1))
         idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Lookup Instruction", self.PopupActionHandler(self.form, self.form.menu_lookup),   None, None, -1))
         idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Toggle Auto-refresh", self.PopupActionHandler(self.form, self.form.menu_autorefresh),   None, None, -1))
         idaapi.attach_action_to_popup(widget, popup, "-", None)
         idaapi.attach_dynamic_action_to_popup(widget, popup, idaapi.action_desc_t(None, "Change Architecture", self.PopupActionHandler(self.form, self.form.change_arch),  None, None, -1))
         idaapi.attach_action_to_popup(widget, popup, "-", None)        
Exemplo n.º 6
0
    def event_callback(self, event, *args):

        try:
            if event == idaapi.hxe_populating_popup:
                form, phandle, vu = args
                idaapi.attach_action_to_popup(form, phandle, "vdsxrefs:show", None)
        except:
            traceback.print_exc()

        return 0
Exemplo n.º 7
0
 def finish_populating_widget_popup(self, widget, popup):
     # We'll add our action to all "IDA View-*"s.
     # If we wanted to add it only to "IDA View-A", we could
     # also discriminate on the widget's title:
     #
     #  if idaapi.get_widget_title(widget) == "IDA View-A":
     #      ...
     #
     if idaapi.get_widget_type(widget) == idaapi.BWN_DISASM:
         idaapi.attach_action_to_popup(widget, popup, act_name, None)
Exemplo n.º 8
0
def show_win():
    x = mycv_t()
    if not x.Create():
        print "Failed to create!"
        return None
    x.Show()
    tcc = x.GetTCustomControl()

    # Register actions
    for thing in ["Hello", "World"]:
        actname = "custview:say_%s" % thing
        idaapi.register_action(idaapi.action_desc_t(actname, "Say %s" % thing, say_something_handler_t(thing)))
        idaapi.attach_action_to_popup(tcc, None, actname)
    return x
    def finish_populating_tform_popup(self, form, popup):
        # Or here, after the popup is done being populated by its owner.

        # We will attach our action to the context menu
        # for the 'Functions window' widget.
        # The action will be be inserted in a submenu of
        # the context menu, named 'Others'.
        if not self.is_closed and idaapi.get_tform_type(form) == idaapi.BWN_DISASMS:
            addr = idc.ScreenEA()
            for addr_from, addr_to in self.addrs:
                if addr == addr_from:
                    idaapi.attach_action_to_popup(
                        form, popup, "pyrebox:show_funcs", "PyREBox/")
                    break
Exemplo n.º 10
0
    def event_callback(self, event, *args):

        if event == idaapi.hxe_populating_popup:
            form, phandle, vu = args
            res = idaapi.attach_action_to_popup(vu.ct, None, inverter_actname)

        elif event == idaapi.hxe_maturity:
            cfunc, maturity = args
            if maturity == idaapi.CMAT_FINAL:
                self.restore(cfunc)

        return 0
Exemplo n.º 11
0
    def finish_populating_tform_popup(self, form, popup):
        form_type = idaapi.get_tform_type(form)

        if form_type == idaapi.BWN_DISASM or form_type == idaapi.BWN_DUMP:
            if idaapi.read_selection() or ItemSize(ScreenEA()) > 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)
Exemplo n.º 12
0
    def hxe_callback(self, event, *args):
        """
        HexRays event callback.

        We lump this under the (UI) Hooks class for organizational reasons.
        """

        #
        # if the event callback indicates that this is a popup menu event
        # (in the hexrays window), we may want to install our prefix menu
        # actions depending on what the cursor right clicked.
        #

        if event == idaapi.hxe_populating_popup:
            form, popup, vu = args

            #
            # if the user cursor isn't hovering over a function ref, there
            # is nothing for us to do
            #

            if get_cursor_func_ref() == idaapi.BADADDR:
                return 0

            #
            # the user cursor is hovering over a valid target for a recursive
            # function prefix. insert the prefix action entry into the menu
            #

            idaapi.attach_action_to_popup(
                form,
                popup,
                prefix_t.ACTION_RECURSIVE,
                "Rename global item",
                idaapi.SETMENU_APP
            )

        # done
        return 0
Exemplo n.º 13
0
 def finish_populating_tform_popup(self, form, popup):
     idaapi.attach_action_to_popup(form, popup, 'my:expand', None)
     idaapi.attach_action_to_popup(form, popup, 'my:translate', None)
Exemplo n.º 14
0
 def finish_populating_tform_popup(form, popup):
     """
     Arguments:
     Return Value:
     Description:
         -
     TODO:
         - Doc String
     """
     if idaapi.get_tform_title(form) == "IDA View-A":
         idaapi.attach_action_to_popup(form, popup, "Finds:Set", "AngryIDA/Finds/")
         idaapi.attach_action_to_popup(form, popup, "Finds:Remove", "AngryIDA/Finds/")
         idaapi.attach_action_to_popup(form, popup, "Finds:Print", "AngryIDA/Finds/")
         idaapi.attach_action_to_popup(form, popup, "Avoids:Set", "AngryIDA/Avoids/")
         idaapi.attach_action_to_popup(form, popup, "Avoids:Remove", "AngryIDA/Avoids/")
         idaapi.attach_action_to_popup(form, popup, "Avoids:Print", "AngryIDA/Avoids/")
         idaapi.attach_action_to_popup(form, popup, "Explore:Run", "AngryIDA/Explore/")
         idaapi.attach_action_to_popup(form, popup, "Explore:Options", "AngryIDA/Explore/")
         idaapi.attach_action_to_popup(form, popup, "Refresh:Refresh", "AngryIDA/")
         idaapi.attach_action_to_popup(form, popup, "Quit:Quit", "AngryIDA/")
Exemplo n.º 15
0
        def finish_populating_widget_popup(self, form, popup):
            # Or here, after the popup is done being populated by its owner.

            # We will attach our action to the context menu
            # for the 'Functions window' widget.
            # The action will be be inserted in a submenu of
            # the context menu, named 'Others'.
            if idaversion.get_widget_type(form) == idaapi.BWN_CALL_STACK:
                #line = form.GetCurrentLine()
                pass
            elif idaversion.get_widget_type(form) == idaapi.BWN_DISASM or \
                 idaversion.get_widget_type(form) == idaapi.BWN_DUMP:
                #regs =['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp', 'esp', 'ax', 'bx', 'cx', 'dx', 'ah', 'al', 'bh', 'bl', 'ch', 'cl', 'dh', 'dl']


                regs = idaapi.ph_get_regnames()
                idaapi.attach_action_to_popup(form, popup, "revCursor:action", 'RESim/')
                idaapi.attach_action_to_popup(form, popup, "dis:action", 'RESim/')

                highlighted = idaversion.getHighlight()
                if highlighted is not None:
                    if highlighted in regs:
                        idaapi.attach_action_to_popup(form, popup, "modReg:action", 'RESim/')
                    else:
                        addr = getHex(highlighted)
                        if addr is not None or regFu.isHighlightedEffective():
                            idaapi.attach_action_to_popup(form, popup, "rev:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "dataWatch:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "revData:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "modMemory:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "stringMemory:action", 'RESim/')
                opnum = idaapi.get_opnum()
                if opnum >= 0:
                    idaapi.attach_action_to_popup(form, popup, "structField:action", 'RESim/')
Exemplo n.º 16
0
    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:
            idaapi.attach_action_to_popup(form, popup, ACTION_PASTE, None)
            idaapi.attach_action_to_popup(form, popup, ACTION_DUMPER, None)
            idaapi.attach_action_to_popup(form, popup, ACTION_JMP, None)
            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)
Exemplo n.º 17
0
def inject_prefix_actions(form, popup, form_type):
    """
    Inject prefix actions to popup menu(s) based on context.
    """

    #
    # disassembly window
    #

    if form_type == idaapi.BWN_DISASMS:

        #
        # if the user cursor isn't hovering over a function ref, there
        # is nothing for us to do
        #

        if get_cursor_func_ref() == idaapi.BADADDR:
            return

        #
        # the user cursor is hovering over a valid target for a recursive
        # function prefix. insert the prefix action entry into the menu
        #

        idaapi.attach_action_to_popup(
            form,
            popup,
            prefix_t.ACTION_RECURSIVE,
            "Rename",
            idaapi.SETMENU_APP
        )

    #
    # functions window
    #

    elif form_type == idaapi.BWN_FUNCS:

        # inject the 'Bulk' function prefix action
        idaapi.attach_action_to_popup(
            form,
            popup,
            prefix_t.ACTION_BULK,
            "Delete function(s)...",
            idaapi.SETMENU_INS
        )

        # inject the 'Clear prefix' action
        idaapi.attach_action_to_popup(
            form,
            popup,
            prefix_t.ACTION_CLEAR,
            "Delete function(s)...",
            idaapi.SETMENU_INS
        )

        # inject a menu separator
        idaapi.attach_action_to_popup(
            form,
            popup,
            None,
            "Delete function(s)...",
            idaapi.SETMENU_INS
        )

    # done
    return 0
Exemplo n.º 18
0
 def _attach_to_popup(self, action_name):
     idaapi.attach_action_to_popup(self.GetTCustomControl(), None, action_name)
Exemplo n.º 19
0
 def finish_populating_tform_popup(form, popup):
     idaapi.attach_action_to_popup(form, popup, "Find", "IDAngr/")
     idaapi.attach_action_to_popup(form, popup, "Avoid", "IDAngr/")
     idaapi.attach_action_to_popup(form, popup, "Symbolic", "IDAngr/")
Exemplo n.º 20
0
 def update(self, ctx):
     if ctx.widget_type == idaapi.BWN_LOCTYPS:
         idaapi.attach_action_to_popup(ctx.widget, None, self.name)
         return idaapi.AST_ENABLE_FOR_WIDGET
     return idaapi.AST_DISABLE_FOR_WIDGET
Exemplo n.º 21
0
 def populating_tform_popup(self, form, popup):
     print "populating"
     if idaapi.get_tform_type(form) == idaapi.BWN_DISASM or idaapi.get_tform_type(form) == idaapi.BWN_DISASMS:
         idaapi.attach_action_to_popup(form, popup, "mee:DeepDecompile1", None)
         idaapi.attach_action_to_popup(form, popup, "mee:DeepDecompile3", None)
Exemplo n.º 22
0
    def finish_populating_tform_popup(self, form, popup):
        """
        A right click menu is about to be shown.
        """

        #
        # disassembly window
        #

        if idaapi.get_tform_type(form) == idaapi.BWN_DISASMS:

            #
            # if the user cursor isn't hovering over a function ref, there
            # is nothing for us to do
            #

            if get_cursor_func_ref() == idaapi.BADADDR:
                return

            #
            # the user cursor is hovering over a valid target for a recursive
            # function prefix. insert the prefix action entry into the menu
            #

            idaapi.attach_action_to_popup(
                form,
                popup,
                prefix_t.ACTION_RECURSIVE,
                "Rename",
                idaapi.SETMENU_APP
            )

        #
        # functions window
        #

        elif idaapi.get_tform_type(form) == idaapi.BWN_FUNCS:

            # inject the 'Bulk' function prefix action
            idaapi.attach_action_to_popup(
                form,
                popup,
                prefix_t.ACTION_BULK,
                "Delete function(s)...",
                idaapi.SETMENU_INS
            )

            # inject the 'Clear prefix' action
            idaapi.attach_action_to_popup(
                form,
                popup,
                prefix_t.ACTION_CLEAR,
                "Delete function(s)...",
                idaapi.SETMENU_INS
            )

            # inject a menu separator
            idaapi.attach_action_to_popup(
                form,
                popup,
                None,
                "Delete function(s)...",
                idaapi.SETMENU_INS
            )

        # done
        return 0
Exemplo n.º 23
0
 def finish_populating_tform_popup(self, form, popup):
     # Or here, after the popup is done being populated by its owner.
     idaapi.attach_action_to_popup(form, popup, "my:InHeader", "Rename global items", idaapi.SETMENU_APP)
     idaapi.attach_action_to_popup(form, popup, "my:PacketStruct", "Rename global items", idaapi.SETMENU_APP)
     idaapi.attach_action_to_popup(form, popup, "my:OutPacket", "Rename global items", idaapi.SETMENU_APP)
     idaapi.attach_action_to_popup(form, popup, "my:OpenFile", "Rename global items", idaapi.SETMENU_APP)
Exemplo n.º 24
0
 def handle(self, event, *args):
     form, popup, hx_view = args
     if self.__action.check(hx_view):
         idaapi.attach_action_to_popup(form, popup, self.__action.name, None)
     return 0
 def finish_populating_tform_popup(self, form, popup):
     if idaapi.get_tform_type(form) == idaapi.BWN_DISASM:
         idaapi.attach_action_to_popup(form, popup, plugin.add_to_search_handler.get_name(), '')
         idaapi.attach_action_to_popup(form, popup, plugin.clear_search_handler.get_name(), '')
Exemplo n.º 26
0
        def finish_populating_tform_popup(self, form, popup):
            # Or here, after the popup is done being populated by its owner.

            if idaapi.get_tform_type(form) == idaapi.BWN_DISASM:
                idaapi.attach_action_to_popup(form, popup, MarkReachableNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkUnReachableNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkReachingNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkNotReachingNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkExits.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkClearHandler.get_name(), "Mark/")
Exemplo n.º 27
0
 def finish_populating_tform_popup(self, form, popup):
     idaapi.attach_action_to_popup(form, popup, 'my:expand', None)
     idaapi.attach_action_to_popup(form, popup, 'my:translate', None)
Exemplo n.º 28
0
 def populating_popup(self, widget, phandle, vu):
     idaapi.attach_action_to_popup(widget, phandle, "vdsxrefs:show", None)
     return 0
Exemplo n.º 29
0
 def finish_populating_tform_popup(self, form, popup):
     # print "Current Form", idaapi.get_tform_type(form)
     for f in alive_functions:
         for fmenu in f[2]:
             if idaapi.get_tform_type(form) == fmenu:
                 idaapi.attach_action_to_popup(form, popup, f[0], None) 
Exemplo n.º 30
0
 def populating_popup(self, widget, phandle, vu):
     idaapi.attach_action_to_popup(vu.ct, None, actname)
     return 0
Exemplo n.º 31
0
 def finish_populating_tform_popup(self, form, popup):
     if idaapi.get_tform_type(form) == idaapi.BWN_DISASM:
         idaapi.attach_action_to_popup(form, popup, idaview_handler.get_name(), "")
Exemplo n.º 32
0
 def finish_populating_widget_popup(self, form, popup):
     global popup_action_names
     form_type = idaapi.get_widget_type(form)
     if form_type == idaapi.BWN_DISASM:
         for action_name in popup_action_names:
             idaapi.attach_action_to_popup(form, popup, action_name, None)
Exemplo n.º 33
0
def hexrays_events_callback(*args):
    global potential_negatives

    hexrays_event = args[0]

    if hexrays_event == idaapi.hxe_populating_popup:
        form, popup, hx_view = args[1:]
        item = hx_view.item  # current ctree_item_t

        idaapi.attach_action_to_popup(form, popup,
                                      Actions.GuessAllocation.name, None)

        if Actions.GuessAllocation.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RecastItemRight.name, None)

        if Actions.RecastItemRight.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RecastItemRight.name, None)

        if Actions.RecastItemLeft.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RecastItemLeft.name, None)

        if Actions.RenameOther.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RenameOther.name, None)

        if Actions.RenameInside.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RenameInside.name, None)

        if Actions.RenameOutside.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RenameOutside.name, None)

        if Actions.RenameUsingAssert.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RenameUsingAssert.name, None)

        if Actions.SwapThenElse.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.SwapThenElse.name, None)

        if Actions.ShallowScanVariable.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.ShallowScanVariable.name,
                                          None)
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.DeepScanVariable.name, None)
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.RecognizeShape.name, None)

        if Actions.CreateNewField.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.CreateNewField.name, None)

        if Actions.FindFieldXrefs.check(item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.FindFieldXrefs.name, None)

        if Actions.PropagateName.check(hx_view.cfunc, item):
            idaapi.attach_action_to_popup(form, popup,
                                          Actions.PropagateName.name, None)

        if item.citype == idaapi.VDI_FUNC:
            # If we clicked on function
            if not hx_view.cfunc.entry_ea == idaapi.BADADDR:  # Probably never happen
                idaapi.attach_action_to_popup(form, popup,
                                              Actions.AddRemoveReturn.name,
                                              None)
                idaapi.attach_action_to_popup(form, popup,
                                              Actions.ConvertToUsercall.name,
                                              None)
                if Actions.DeepScanReturn.check(hx_view):
                    idaapi.attach_action_to_popup(form, popup,
                                                  Actions.DeepScanReturn.name,
                                                  None)

        elif item.citype == idaapi.VDI_LVAR:
            # If we clicked on argument
            local_variable = hx_view.item.get_lvar()  # idaapi.lvar_t
            if local_variable.is_arg_var:
                idaapi.attach_action_to_popup(form, popup,
                                              Actions.RemoveArgument.name,
                                              None)

        elif item.citype == idaapi.VDI_EXPR:
            if item.e.op == idaapi.cot_num:
                # number_format = item.e.n.nf                       # idaapi.number_format_t
                # print "(number) flags: {0:#010X}, type_name: {1}, opnum: {2}".format(
                #     number_format.flags,
                #     number_format.type_name,
                #     number_format.opnum
                # )
                idaapi.attach_action_to_popup(form, popup,
                                              Actions.GetStructureBySize.name,
                                              None)
            elif item.e.op == idaapi.cot_var:
                # Check if we clicked on variable that is a pointer to a structure that is potentially part of
                # containing structure
                if item.e.v.idx in potential_negatives:
                    idaapi.attach_action_to_popup(
                        form, popup, Actions.SelectContainingStructure.name,
                        None)
                if Actions.ResetContainingStructure.check(
                        hx_view.cfunc.get_lvars()[item.e.v.idx]):
                    idaapi.attach_action_to_popup(
                        form, popup, Actions.ResetContainingStructure.name,
                        None)

    elif hexrays_event == idaapi.hxe_double_click:
        hx_view = args[1]
        item = hx_view.item
        if item.citype == idaapi.VDI_EXPR and item.e.op == idaapi.cot_memptr:
            # Look if we double clicked on expression that is member pointer. Then get tinfo_t of  the structure.
            # After that remove pointer and get member name with the same offset
            if item.e.x.op == idaapi.cot_memref and item.e.x.x.op == idaapi.cot_memptr:
                vtable_tinfo = item.e.x.type.get_pointed_object()
                method_offset = item.e.m
                class_tinfo = item.e.x.x.x.type.get_pointed_object()
                vtable_offset = item.e.x.x.m
            elif item.e.x.op == idaapi.cot_memptr:
                vtable_tinfo = item.e.x.type.get_pointed_object()
                method_offset = item.e.m
                class_tinfo = item.e.x.x.type.get_pointed_object()
                vtable_offset = item.e.x.m
            else:
                func_offset = item.e.m
                struct_tinfo = item.e.x.type.get_pointed_object()
                func_ea = Helper.get_virtual_func_address(
                    Helper.get_member_name(struct_tinfo, func_offset))
                if func_ea:
                    idaapi.jumpto(func_ea)
                return 0

            func_name = Helper.get_member_name(vtable_tinfo, method_offset)
            func_ea = Helper.get_virtual_func_address(func_name, class_tinfo,
                                                      vtable_offset)
            if func_ea:
                idaapi.open_pseudocode(func_ea, 0)
                return 1

    elif hexrays_event == idaapi.hxe_maturity:
        cfunc, level_of_maturity = args[1:]

        if level_of_maturity == idaapi.CMAT_BUILT:
            # print '=' * 40
            # print '=' * 15, "LEVEL", level_of_maturity, '=' * 16
            # print '=' * 40
            # print cfunc

            # First search for CONTAINING_RECORD made by Ida
            visitor = NegativeOffsets.SearchVisitor(cfunc)
            visitor.apply_to(cfunc.body, None)
            negative_lvars = visitor.result

            # Second get saved information from comments
            lvars = cfunc.get_lvars()
            for idx in xrange(len(lvars)):
                result = NegativeOffsets.parse_lvar_comment(lvars[idx])
                if result and result.tinfo.equals_to(
                        lvars[idx].type().get_pointed_object()):
                    negative_lvars[idx] = result

            # Third make an analysis of local variables that a structure pointers and have reference that pass
            # through structure boundaries. This variables will be considered as potential pointers to substructure
            # and will get a menu on right click that helps to select Containing Structure from different libraries

            structure_pointer_variables = {}
            for idx in set(range(len(lvars))) - set(negative_lvars.keys()):
                if lvars[idx].type().is_ptr():
                    pointed_tinfo = lvars[idx].type().get_pointed_object()
                    if pointed_tinfo.is_udt():
                        structure_pointer_variables[idx] = pointed_tinfo

            if structure_pointer_variables:
                visitor = NegativeOffsets.AnalyseVisitor(
                    structure_pointer_variables, potential_negatives)
                visitor.apply_to(cfunc.body, None)

            if negative_lvars:
                visitor = NegativeOffsets.ReplaceVisitor(negative_lvars)
                visitor.apply_to(cfunc.body, None)

        elif level_of_maturity == idaapi.CMAT_TRANS1:

            visitor = SwapThenElseVisitor(cfunc.entry_ea)
            visitor.apply_to(cfunc.body, None)

        elif level_of_maturity == idaapi.CMAT_TRANS2:
            # print '=' * 40
            # print '=' * 15, "LEVEL", level_of_maturity, '=' * 16
            # print '=' * 40
            # print cfunc
            visitor = SpaghettiVisitor()
            visitor.apply_to(cfunc.body, None)

        elif level_of_maturity == idaapi.CMAT_FINAL:
            StructXrefVisitor(cfunc).process()

    return 0
Exemplo n.º 34
0
 def finish_populating_widget_popup(self, widget, popup):
     if idaapi.get_widget_type(widget) == idaapi.BWN_FUNCS:
         idaapi.attach_action_to_popup(widget, popup, "BinaryAI:RetrieveSelected", "BinaryAI/")
Exemplo n.º 35
0
 def update(self, ctx):
     if ctx.form_type == idaapi.BWN_FUNCS:
         idaapi.attach_action_to_popup(ctx.widget, None, self.name)
         return idaapi.AST_ENABLE_FOR_FORM
     return idaapi.AST_DISABLE_FOR_FORM
Exemplo n.º 36
0
 def populating_popup(self, widget, phandle, vu):
     idaapi.attach_action_to_popup(widget, phandle, "vdsxrefs:show", None)
     return 0
Exemplo n.º 37
0
        def finish_populating_tform_popup(self, form, popup):
            # Or here, after the popup is done being populated by its owner.

            if idaapi.get_tform_type(form) == idaapi.BWN_DISASM:
                idaapi.attach_action_to_popup(form, popup, ShowXrefsGraphFrom.get_name(), '')
                idaapi.attach_action_to_popup(form, popup, ShowXrefsGraphTo.get_name(), '')
Exemplo n.º 38
0
        def finish_populating_tform_popup(self, form, popup):
            # Or here, after the popup is done being populated by its owner.

            if idaapi.get_tform_type(form) == idaapi.BWN_DISASM:
                idaapi.attach_action_to_popup(form, popup, MarkReachableNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkUnReachableNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkReachingNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkNotReachingNodesHandler.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkExits.get_name(), "Mark/")
                idaapi.attach_action_to_popup(form, popup, MarkClearHandler.get_name(), "Mark/")