Python idaapi 模块,install_hexrays_callback() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用idaapi.install_hexrays_callback()

项目:bap-ida-python    作者:BinaryAnalysisPlatform    | 项目源码 | 文件源码
def init(self):
        """
        Ensure plugin's line modification function is called whenever needed.

        If Hex-Rays is not installed, or is not initialized yet, then plugin
        will not load. To ensure that the plugin loads after Hex-Rays, please
        name your plugin's .py file with a name that starts lexicographically
        after "hexx86f"
        """
        try:
            if idaapi.init_hexrays_plugin():
                def hexrays_event_callback(event, *args):
                    if event == idaapi.hxe_refresh_pseudocode:
                        # We use this event instead of hxe_text_ready because
                        #   MacOSX doesn't seem to work well with it
                        # TODO: Look into this
                        vu, = args
                        self.visit_func(vu.cfunc)
                    return 0
                idaapi.install_hexrays_callback(hexrays_event_callback)
            else:
                return idaapi.PLUGIN_SKIP
        except AttributeError:
            idc.Warning('''init_hexrays_plugin() not found.
            Skipping Hex-Rays plugin.''')
        return idaapi.PLUGIN_KEEP
项目:prefix    作者:gaasedelen    | 项目源码 | 文件源码
def _init_hexrays_hooks(self):
        """
        Install Hex-Rrays hooks (when available).

        NOTE: This is called when the ui_ready_to_run event fires.
        """
        if idaapi.init_hexrays_plugin():
            idaapi.install_hexrays_callback(self._hooks.hxe_callback)

    #--------------------------------------------------------------------------
    # IDA Actions
    #--------------------------------------------------------------------------
项目:lighthouse    作者:gaasedelen    | 项目源码 | 文件源码
def _init_hexrays_hooks(self):
        """
        Install Hex-Rrays hooks (when available).
        """
        result = False

        if idaapi.init_hexrays_plugin():
            logger.debug("HexRays present, installing hooks...")
            result = idaapi.install_hexrays_callback(self._hxe_callback)

        logger.debug("HexRays hooked: %r" % result)

    #------------------------------------------------------------------------------
    # Painting
    #------------------------------------------------------------------------------
项目:HexRaysPyTools    作者:igogo-x86    | 项目源码 | 文件源码
def init():
        if not idaapi.init_hexrays_plugin():
            print "[ERROR] Failed to initialize Hex-Rays SDK"
            return idaapi.PLUGIN_SKIP

        Helper.temporary_structure = TemporaryStructureModel()
        # Actions.register(Actions.CreateVtable)
        Actions.register(Actions.ShowGraph)
        Actions.register(Actions.ShowClasses)
        Actions.register(Actions.GetStructureBySize)
        Actions.register(Actions.RemoveArgument)
        Actions.register(Actions.AddRemoveReturn)
        Actions.register(Actions.ConvertToUsercall)
        Actions.register(Actions.ShallowScanVariable, Helper.temporary_structure)
        Actions.register(Actions.DeepScanVariable, Helper.temporary_structure)
        Actions.register(Actions.DeepScanReturn, Helper.temporary_structure)
        Actions.register(Actions.DeepScanFunctions, Helper.temporary_structure)
        Actions.register(Actions.RecognizeShape)
        Actions.register(Actions.CreateNewField)
        Actions.register(Actions.SelectContainingStructure, potential_negatives)
        Actions.register(Actions.ResetContainingStructure)
        Actions.register(Actions.RecastItemRight)
        Actions.register(Actions.RecastItemLeft)
        Actions.register(Actions.RenameOther)
        Actions.register(Actions.RenameInside)
        Actions.register(Actions.RenameOutside)
        Actions.register(Actions.SwapThenElse)

        idaapi.attach_action_to_menu('View/Open subviews/Local types', Actions.ShowClasses.name, idaapi.SETMENU_APP)
        idaapi.install_hexrays_callback(hexrays_events_callback)

        Helper.touched_functions.clear()
        Const.init()

        return idaapi.PLUGIN_KEEP
项目:ida_func_ptr    作者:HandsomeMatt    | 项目源码 | 文件源码
def _init_hooks(self):
        self._hooks = Hooks()
        self._hooks.hook()

        if not idaapi.init_hexrays_plugin():
            idaapi.msg("[ERROR] Failed to initialize Hex-Rays SDK")
        else:
            idaapi.install_hexrays_callback(self._hooks.hxe_callback)

    #--------------------------------------------------------------------------
    # IDA Actions
    #--------------------------------------------------------------------------
项目:devirtualize    作者:ALSchwalm    | 项目源码 | 文件源码
def register_vptr_translator():
    idaapi.install_hexrays_callback(translator_callback)
项目:devirtualize    作者:ALSchwalm    | 项目源码 | 文件源码
def register_actions():
    AncestorGraphHandler = OpenGraphHandler()

    def type_of_current_var(vdui):
        var = vdui.item.get_lvar()
        if var is None:
            return None
        return get_type_by_tinfo(var.type())

    def graph_callback(event, *args):
        if event == idaapi.hxe_curpos:
            vdui = args[0]
            type = type_of_current_var(vdui)
            AncestorGraphHandler.target_type = type
        elif event == idaapi.hxe_populating_popup:
            form, popup, vdui = args
            if AncestorGraphHandler.target_type is None:
                return 0
            action_desc = idaapi.action_desc_t(
                None,
                'Open Ancestor Type Graph',
                AncestorGraphHandler)
            idaapi.attach_dynamic_action_to_popup(form, popup, action_desc, None)
        return 0

    action_desc = idaapi.action_desc_t(
        'devirtualize:open_ancestor_type_graph',
        'Open Ancestor Type Graph',
        AncestorGraphHandler,
        None,
        'Open Ancestor Type Graph',
        199)

    idaapi.register_action(action_desc)

    idaapi.attach_action_to_menu(
        'View/Graphs/User xrefs char...',
        'devirtualize:open_ancestor_type_graph',
        idaapi.SETMENU_APP)

    idaapi.install_hexrays_callback(graph_callback)


#TODO: Show diamond inheritance as a diamond