cmpf (C++ source included) is a cute little tool for finding the differences between a number files. It's a command line tool that takes three parameters, the names of two files to compare and the name of the so called mask file.
When you run the tool the first time it compares the two files and dumps the offsets of the bytes where the files differ to stdout. At the same time it creates the mask file which is used for consecutive comparisons. The mask file is just a file filled with 'C' and 'U' bytes that indicate whether the bytes at the same offset during the comparison were the same or not.
If you want to add another file to the comparison you re-run the tool with the parameters 1st file, 3rd file and mask file. Now the mask file exists and is considered in the comparison. Only bytes that were unchanged during the first comparison and have now changed are printed to stdout.
To make it simple: After n consecutive runs of the tool the bytes that were unchanged n-1 times but changed during the last comparison are printed to stdout.
What's the use of this tool? It makes it very easy to find RAM addresses during NES ROM hacking. Here's an example: I want to find the RAM byte where your health points are stored in Super Mario Bros II.
Continue reading "cmpf"