def save_symbols():
"""
Gather symbols and write to .map using expected naming convention.
"""
input_file_path = idaapi.get_input_file_path()
if not os.path.exists(input_file_path):
print "ClemSym: warning: {} does not exist.".format(input_file_path)
output_path = input_file_path + '.map'
new_data = get_symbol_map()
if os.path.exists(output_path):
with open(output_path, 'rb') as orig_fd:
orig_data = orig_fd.read()
if orig_data == new_data:
print "ClemSym: symbol map on disk is already up to date"
return
# Always backup as we *really* don't want to kill someone's
# hand-made symbol map!
bak_ctr = 0
while os.path.exists(output_path + '.bak' + str(bak_ctr)):
bak_ctr += 1
os.rename(output_path, output_path + '.bak' + str(bak_ctr))
print "ClemSym: writing symbols to", output_path
with open(output_path, 'wb') as output_fd:
output_fd.write(new_data)
评论列表
文章目录