function_BASE_3024.py 文件源码

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

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

    # Check to see if function tag is being applied to an import
    try:
        rt,ea = __addressOfRtOrSt(func)
    except LookupError:
        # If we're not even in a function, then use a database tag.
        logging.warn('{:s}.tag_write : Attempted to set tag for a non-function. Falling back to a database tag. : {:x}'.format(__name__, func))
        return database.tag_write(func, key, value)

    # If so, then write the tag to the import
    if rt:
        logging.warn('{:s}.tag_write : Attempted to set tag for a runtime-linked symbol. Falling back to a database tag. : {:x}'.format(__name__, ea))
        return database.tag_write(ea, key, value)

    # Otherwise, it's a function.
    fn = by_address(ea)

    # if the user wants to change the '__name__' tag then update the function's name.
    if key == '__name__':
        return set_name(fn, value)

    state = internal.comment.decode(comment(fn, repeatable=1))
    res,state[key] = state.get(key,None),value
    comment(fn, internal.comment.encode(state), repeatable=1)

    if res is None:
        internal.comment.globals.inc(fn.startEA, key)

    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号