database.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:idascripts 作者: ctfhacker 项目源码 文件源码
def tag_write(ea, key, value):
    '''Set the tag ``key`` to ``value`` at the address ``ea``.'''
    if value is None:
        raise ValueError("{:s}.tag_write({:x}, {!r}, ...) : Tried to set tag {!r} to an invalid value. : {!r}".format(__name__, ea, key, key, value))

    # if the user wants to change the '__name__' tag, then
    # change the name fo' real.
    if key == '__name__':
        return set_name(ea, value, listed=True)
    if key == '__extra_prefix__':
        return extra.set_prefix(ea, value)
    if key == '__extra_suffix__':
        return extra.set_suffix(ea, value)
    if key == '__color__':
        return set_color(ea, value)

    # if not within a function, then use a repeatable comment
    # otherwise, use a non-repeatable one
    try: func = function.by_address(ea)
    except: func = None
    repeatable = False if func else True

    # grab the current value
    ea = interface.address.inside(ea)
    state = internal.comment.decode(comment(ea, repeatable=not repeatable))
    state and comment(ea, '', repeatable=not repeatable) # clear the old one
    state.update(internal.comment.decode(comment(ea, repeatable=repeatable)))

    # update the tag's reference
    if key not in state:
        if func:
            internal.comment.contents.inc(ea, key)
        else:
            internal.comment.globals.inc(ea, key)

    # now we can actually update the tag
    res,state[key] = state.get(key,None),value
    comment(ea, internal.comment.encode(state), repeatable=repeatable)
    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号