Example #1
0
def customnames():
    '''Iterate through all of the custom names defined in the database and update the cache with their reference counts.'''
    # FIXME: first delete all the custom names '__name__' tag
    left, right = db.range()
    for ea in db.address.iterate(left, right):
        ctx = internal.comment.globals if not func.within(ea) or func.address(ea) == ea else internal.comment.contents
        if db.type.has_customname(ea):
            ctx.inc(ea, '__name__')
        continue
    return
Example #2
0
def customnames():
    '''Iterate through all of the custom names defined in the database and update the cache with their reference counts.'''
    # FIXME: first delete all the custom names '__name__' tag
    left, right = db.range()
    for ea in db.address.iterate(left, right):
        ctx = internal.comment.globals if not func.within(ea) or func.address(
            ea) == ea else internal.comment.contents
        if db.type.has_customname(ea):
            ctx.inc(ea, '__name__')
        continue
    return
Example #3
0
def customnames():
    '''Add all custom names defined in the database to the tagcache as "__name__"'''
    # FIXME: first delete all the custom names '__name__' tag
    left, right = db.range()
    for ea in db.iterate(left, right - 1):
        fn = idaapi.get_func(ea)
        ctx = internal.comment.globals if not fn or fn.startEA == ea else internal.comment.contents
        if db.type.has_customname(ea):
            ctx.inc(ea, '__name__')
        continue
    return
Example #4
0
def extracomments():
    '''Iterate through all of the extra comments defined in the database and update the cache with their reference counts.'''
    left, right = db.range()
    for ea in db.address.iterate(left, right):
        ctx = internal.comment.contents if func.within(ea) else internal.comment.globals

        count = db.extra.__count__(ea, idaapi.E_PREV)
        if count: [ ctx.inc(ea, '__extra_prefix__') for i in six.moves.range(count) ]

        count = db.extra.__count__(ea, idaapi.E_NEXT)
        if count: [ ctx.inc(ea, '__extra_suffix__') for i in six.moves.range(count) ]
    return
Example #5
0
def globals():
    '''Yields all the global tags.'''
    ea, sentinel = db.range()
    while ea < sentinel:
        f = idaapi.get_func(ea)
        if f:
            t = fn.tag(ea)
            if t: yield ea, t
            ea = f.endEA
            continue
        t = db.tag(ea)
        if t: yield ea, t
        ea = db.a.next(ea)
    return
Example #6
0
def do_data():
    addr, tags = {}, {}
    left, right = db.range()
    print 'fetching global tags'
    for ea in db.iterate(left, right - 1):
        f = idaapi.get_func(ea)
        if f is not None: continue
        res = db.tag(ea)
        #res.pop('name', None)
        for k, v in res.iteritems():
            addr[ea] = addr.get(ea, 0) + 1
            tags[k] = tags.get(k, 0) + 1
        continue
    return addr, tags
Example #7
0
def extracomments():
    '''Add all extra cmts in the database to the tagcache as "__name__"'''
    # FIXME: first delete all the custom names '__name__' tag
    left, right = db.range()
    for ea in db.iterate(left, right - 1):
        fn = idaapi.get_func(ea)
        ctx = internal.comment.contents if fn else internal.comment.globals

        count = db.extra.count(ea, idaapi.E_PREV)
        if count: [ctx.inc(ea, '__extra_prefix__') for i in xrange(count)]

        count = db.extra.count(ea, idaapi.E_NEXT)
        if count: [ctx.inc(ea, '__extra_suffix__') for i in xrange(count)]
    return
Example #8
0
def extracomments():
    '''Iterate through all of the extra comments defined in the database and update the cache with their reference counts.'''
    left, right = db.range()
    for ea in db.address.iterate(left, right):
        ctx = internal.comment.contents if func.within(
            ea) else internal.comment.globals

        count = db.extra.__count__(ea, idaapi.E_PREV)
        if count:
            [ctx.inc(ea, '__extra_prefix__') for i in six.moves.range(count)]

        count = db.extra.__count__(ea, idaapi.E_NEXT)
        if count:
            [ctx.inc(ea, '__extra_suffix__') for i in six.moves.range(count)]
    return
Example #9
0
def fetch_globals_data():
    """Fetch the reference count for the global tags (non-function) in the database.

    Returns the tuple `(address, tags)` where the `address` and `tags`
    fields are both dictionaries containing the reference count for
    the addresses and tag names.
    """
    addr, tags = {}, {}
    left, right = db.range()
    print >> output, 'globals: fetching tags from data'
    for ea in db.address.iterate(left, right):
        if func.within(ea): continue
        ui.navigation.auto(ea)

        res = db.tag(ea)
        #res.pop('name', None)
        for k, v in six.iteritems(res):
            addr[ea] = addr.get(ea, 0) + 1
            tags[k] = tags.get(k, 0) + 1
        continue
    return addr, tags
Example #10
0
def fetch_globals_data():
    """Fetch the reference count for the global tags (non-function) in the database.

    Returns the tuple `(address, tags)` where the `address` and `tags`
    fields are both dictionaries containing the reference count for
    the addresses and tag names.
    """
    addr, tags = {}, {}
    left, right = db.range()
    six.print_(u'globals: fetching tags from data', file=output)
    for ea in db.address.iterate(left, right):
        if func.within(ea): continue
        ui.navigation.auto(ea)

        res = db.tag(ea)
        #res.pop('name', None)
        for k, v in six.iteritems(res):
            addr[ea] = addr.get(ea, 0) + 1
            tags[k] = tags.get(k, 0) + 1
        continue
    return addr, tags