コード例 #1
0
    def selectcontents(*tags, **boolean):
        '''Fetch all the functions containing the specified tags within it's contents'''
        boolean = dict((k, set(v) if type(v) is tuple else set((v, )))
                       for k, v in boolean.viewitems())
        if tags:
            boolean.setdefault(
                'And',
                set(boolean.get(
                    'And',
                    set())).union(set(tags) if len(tags) > 1 else set(tags, )))

        if not boolean:
            for ea in functions():
                res = function.tags(ea)
                if res: yield ea, res
            return

        for ea in functions():
            res, d = set(), function.tags(ea)

            Or = boolean.get('Or', set())
            res.update(Or.intersection(d))

            And = boolean.get('And', set())
            if And:
                if And.intersection(d) == And:
                    res.update(And)
                else:
                    continue
            if res: yield ea, res
        return
コード例 #2
0
ファイル: database.py プロジェクト: nihilus/idascripts-2
    def selectcontents(*tags, **boolean):
        '''Fetch all the functions containing the specified tags within it's contents'''
        boolean = dict((k,set(v) if type(v) is tuple else set((v,))) for k,v in boolean.viewitems())
        if tags:
            boolean.setdefault('And', set(boolean.get('And',set())).union(set(tags) if len(tags) > 1 else set(tags,)))

        if not boolean:
            for ea in functions():
                res = function.tags(ea)
                if res: yield ea, res
            return

        for ea in functions():
            res,d = set(),function.tags(ea)

            Or = boolean.get('Or', set())
            res.update(Or.intersection(d))

            And = boolean.get('And', set())
            if And:
                if And.intersection(d) == And:
                    res.update(And)
                else: continue
            if res: yield ea,res
        return
コード例 #3
0
    def tag(ea, *args, **kwds):
        '''tag(ea, key?, value?, repeatable=True/False) -> fetches/stores a tag from specified address'''
        # if not in a function, it could be a global, so make the tag repeatable
        #   otherwise, use a non-repeatable comment
        ea = int(ea)
        try:
            func = function.byAddress(ea)
        except Exception:
            func = None
        kwds.setdefault('repeatable', True if func is None else False)

        if len(args) < 2:
            return tag_read(ea, *args, **kwds)

        key, value = args
        result = tag_write(ea, key, value, **kwds)

        # add tag-name to function's cache
        if func is not None and value is not None and key is not '__tags__':
            top = func.startEA
            tags = function.tags(ea)
            tags.add(key)
            tag_write(top, '__tags__', tags)

        return result
コード例 #4
0
ファイル: database.py プロジェクト: nihilus/idascripts-2
    def tag(ea, *args, **kwds):
        '''tag(ea, key?, value?, repeatable=True/False) -> fetches/stores a tag from specified address'''
        # if not in a function, it could be a global, so make the tag repeatable
        #   otherwise, use a non-repeatable comment
        ea = int(ea)
        try:
            func = function.byAddress(ea)
        except Exception:
            func = None
        kwds.setdefault('repeatable', True if func is None else False)

        if len(args) < 2:
            return tag_read(ea, *args, **kwds)

        key,value = args
        result = tag_write(ea, key, value, **kwds)

        # add tag-name to function's cache
        if func is not None and value is not None and key is not '__tags__':
            top = func.startEA
            tags = function.tags(ea)
            tags.add(key)
            tag_write(top, '__tags__', tags)

        return result