コード例 #1
0
ファイル: Actions.py プロジェクト: ydc1992/HexRaysPyTools
    def activate(self, ctx):
        hx_view = idaapi.get_tform_vdui(ctx.form)
        address = hx_view.cfunc.entry_ea

        xref_ea = idaapi.get_first_cref_to(address)
        xrefs = set()
        while xref_ea != idaapi.BADADDR:
            xref_func_ea = idc.GetFunctionAttr(xref_ea, idc.FUNCATTR_START)
            if xref_func_ea != idaapi.BADADDR:
                xrefs.add(xref_func_ea)
            else:
                print "[Warning] Function not found at 0x{0:08X}".format(xref_ea)
            xref_ea = idaapi.get_next_cref_to(address, xref_ea)

        for func_ea in xrefs:
            visitor = VariableLookupVisitor(address)

            try:
                cfunc = idaapi.decompile(func_ea)
                if cfunc:
                    FunctionTouchVisitor(cfunc).process()
                    visitor.apply_to(cfunc.body, None)
                    for idx in visitor.result:
                        scanner = DeepSearchVisitor(cfunc, 0, idx)
                        scanner.process()
                        for field in scanner.candidates:
                            self.temporary_structure.add_row(field)

            except idaapi.DecompilationFailure:
                print "[Warning] Failed to decompile function at 0x{0:08X}".format(xref_ea)

        DeepSearchVisitor.clear()
コード例 #2
0
ファイル: Actions.py プロジェクト: zhkl0228/HexRaysPyTools
    def activate(self, ctx):
        hx_view = idaapi.get_tform_vdui(ctx.form)
        origin = self.temporary_structure.main_offset

        var_type = ShallowScanVariable.check(hx_view.item)
        if var_type == "LOCAL":
            variable = hx_view.item.get_lvar()  # lvar_t
            index = list(hx_view.cfunc.get_lvars()).index(variable)
            definition_address = None if variable.is_arg_var else variable.defea

            # index = list(hx_view.cfunc.get_lvars()).index(variable)
            if FunctionTouchVisitor(hx_view.cfunc).process():
                hx_view.refresh_view(True)

            # Because index of the variable can be changed after touching, we would like to calculate it appropriately
            lvars = hx_view.cfunc.get_lvars()

            if definition_address:
                index = next(x for x in xrange(len(lvars))
                             if lvars[x].defea == definition_address)

            scanner = DeepSearchVisitor(hx_view.cfunc, origin, index=index)

        elif var_type == "GLOBAL":
            gvar = hx_view.item.it.to_specific_type
            name = idc.GetTrueName(gvar.obj_ea)
            tinfo = gvar.type

            if FunctionTouchVisitor(hx_view.cfunc).process():
                hx_view.refresh_view(True)

            scanner = DeepSearchVisitor(hx_view.cfunc,
                                        origin,
                                        global_variable=(name, tinfo))

        else:
            return

        scanner.process()
        for field in scanner.candidates:
            self.temporary_structure.add_row(field)
        scanner.clear()
コード例 #3
0
ファイル: Actions.py プロジェクト: xqx12/HexRaysPyTools
    def activate(self, ctx):
        hx_view = idaapi.get_tform_vdui(ctx.form)
        variable = hx_view.item.get_lvar()  # lvar_t
        if variable and filter(lambda x: x.equals_to(variable.type()),
                               Const.LEGAL_TYPES):
            definition_address = variable.defea
            # index = list(hx_view.cfunc.get_lvars()).index(variable)
            if FunctionTouchVisitor(hx_view.cfunc).process():
                hx_view.refresh_view(True)

            # Because index of the variable can be changed after touching, we would like to calculate it appropriately
            lvars = hx_view.cfunc.get_lvars()
            index = next(x for x in xrange(len(lvars))
                         if lvars[x].defea == definition_address)
            scanner = DeepSearchVisitor(hx_view.cfunc,
                                        self.temporary_structure.main_offset,
                                        index)
            scanner.process()
            for field in scanner.candidates:
                self.temporary_structure.add_row(field)
コード例 #4
0
ファイル: Actions.py プロジェクト: ydc1992/HexRaysPyTools
    def activate(self, ctx):
        for idx in ctx.chooser_selection:
            func_ea = idaapi.getn_func(idx - 1).startEA
            try:
                cfunc = idaapi.decompile(func_ea)
                if cfunc is None:
                    continue

                FunctionTouchVisitor(cfunc).process()

                lvars = cfunc.get_lvars()
                if not (lvars and lvars[0].is_arg_var and Helper.is_legal_type(lvars[0].type())):
                    continue

                scanner = DeepSearchVisitor(cfunc, 0, 0)
                scanner.process()
                for field in scanner.candidates:
                    self.temporary_structure.add_row(field)

            except idaapi.DecompilationFailure:
                print "[Warning] Failed to decompile function at 0x{0:08X}".format(func_ea)
コード例 #5
0
    def scan(self, hx_view, variable):
        if variable and Helper.is_legal_type(variable.type()):

            definition_address = None if variable.is_arg_var else variable.defea
            index = list(hx_view.cfunc.get_lvars()).index(variable)

            # index = list(hx_view.cfunc.get_lvars()).index(variable)
            if FunctionTouchVisitor(hx_view.cfunc).process():
                hx_view.refresh_view(True)

            # Because index of the variable can be changed after touching, we would like to calculate it appropriately
            lvars = hx_view.cfunc.get_lvars()

            if definition_address:
                index = next(x for x in xrange(len(lvars))
                             if lvars[x].defea == definition_address)

            scanner = DeepSearchVisitor(hx_view.cfunc,
                                        self.temporary_structure.main_offset,
                                        index)
            scanner.process()
            for field in scanner.candidates:
                self.temporary_structure.add_row(field)
            scanner.clear()