0

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

1

As 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.