I've modified program database in IDA Pro and then created a .dif file with File -> Produce File -> Create DIF File...
After that I've reverted all my changes to database. Is there a way to apply changes from .dif file back?
Thanks
Reverse Engineering Stack Exchange is a question and answer site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation. It only takes a minute to sign up.
Sign up to join this communityAs far as I understand the .dif file is built as follows - after some initial meaningless lines it contains something like this:
offset_in_file: initial_byte current_byte
So applying the differences to the idb should be easy with simple python function as follows:
#not tested, not checked, not ran even once
#beware of errors, use on your own risk
import idaapi
import idc
def apply_dif_file(dif_file_name):
f = open(dif_file_name, "r")
for l in f:
if l.find(":") == -1:
continue
splitted = l.split()
off_in_file = splitted[0]
initial_byte = splitted[1]
new_byte = splitted[2]
#Converting offset to integer
#After that converting it to the ea
offset = int(off_in_file.replace(":", ""), 16)
ea = idaapi.get_fileregion_ea(offset)
#converting new byte
new_byte_num = int(new_byte, 16)
idc.PatchByte(ea, new_byte_num)
f.close()
Good luck, note the latest edits.