a29k-coff.py 文件源码

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

项目:a29k-ida 作者: arnew 项目源码 文件源码
def accept_file(li, n):
    """
    Check if the file is of supported format

    @param li: a file-like object which can be used to access the input data
    @param n : format number. The function will be called with incrementing 
               number until it returns zero
    @return: 0 - no more supported formats
             string "name" - format name to display in the chooser dialog
             dictionary { 'format': "name", 'options': integer }
               options: should be 1, possibly ORed with ACCEPT_FIRST (0x8000)
               to indicate preferred format
    """

    # we support only one format per file
    if n > 0:
        return 0

    li.seek(0)
    magic = li.read(2)
    if struct.unpack('>h',magic)[0] in magics:
        idaapi.set_processor_type("A29K", SETPROC_ALL)
        return { 'format': fmt_a29k_coff_big, 'options': 1 }
    if struct.unpack('<h',magic)[0] in magics:
        idaapi.set_processor_type("A29K", SETPROC_ALL)
        return { 'format': fmt_a29k_coff_little, 'options': 1 }

    # unrecognized format
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号