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
评论列表
文章目录