BinDiff Tool (Compact 7)
3/12/2014
The BinDiff command-line tool (bindiff.exe) shows the differences between two binary files.
Syntax
bindiff [/?] [/c] [/d[#]] [/s] [/v] LeftSpec RightSpec
Parameters
/?
Displays the BinDiff Help screen at the command prompt.
/c
Displays different byte counts and summary information.
/d[#]
Displays the byte differences between different files. You may optionally specify the number of non-different bytes to show on each side of the different regions in the files. The default is 8 bytes. Use 0 to show only the different bytes, or -1 to dump both files in their entirety.
/s
Processes subdirectories (LeftSpec and RightSpec must be directories).
/v
Excludes all time stamp and version information in executable files when it performs the comparison.
LeftSpec RightSpec
The left and right specs can represent files or directories. If two files are specified, the files will be compared with each other. If two directories are specified, all the files within both directories will be compared with each other.
Remarks
Application code is compiled into files that use binary format, and large applications and operating systems consist of several binary files. Over the programming life of an application, developers, testers, or writers might want to know which files, if any, have changed between the current and previous builds. While the size of the file can sometimes alert the interested party to a change, it is also possible for an executable file to change without the size of the file reflecting such changes. Being able to find files that have changed helps testers and writers direct their attention efficiently to the affected application areas. Developers can ensure that the correct versions of updated files are included in the installation directory for the product.
The BinDiff command-line tool can compare either 32-bit or 64-bit executable files. BinDiff can perform the following types of comparisons:
- Between two binary files, ignoring time stamp differences. This is the default comparison.
- Between two binary files, ignoring both time stamp and version information.
- Between two binary files, including differences in time stamp or version information. This can be used to verify a tree copy or a CD burn.
- Between all of the files in one directory and all of the files in another directory (LeftSpec and RightSpec must be directories).
Note
BinDiff uses a special comparison routine for all 32-bit and 64-bit Windows executable files that masks out various build time stamp fields in both files when it performs the comparison. This enables two executable files to be marked as Near Identical when the files are identical in every way except for the time that they were built.
Example
Example 1: Compare Two Versions of a File
You have two versions of the file Custom.dll, and you want to see whether there are any differences between the two files. Using BinDiff with no parameters other than LeftSpec and RightSpec performs a basic comparison. To check for different versions of Custom.dll, use the following syntax.
bindiff c:\temp\old\custom.dll c:\temp\current\custom.dll
Example 2: Compare Two Versions of a File, Ignoring Version and Time Stamp Differences
You have two versions of a file that you want to compare, and you want to make sure that versioning and time stamp information are not the only differences between the two files. To compare the two files while ignoring versioning and time stamp information, use the following syntax.
bindiff /v \\server\drop\old\custom.dll \\server\drop\current\custom.dll
Example 3: Compare Differing Byte Counts for Two Versions of a File
You have two versions of a file that you know differ, but you want to see how different they really are. To compare the two files and get a different byte count, use the following syntax.
bindiff /c \\server\drop\old\custom.dll \\server\drop\current\custom.dll
BinDiff displays the following output. In this case, 16 KB of code are different for the two files.
Different, Right is newer 16,294 bytes differ
File Count Summary
Identical: 0 files
Near Identical: 0 files
Different: 1 files
Left Only: 0 files
Right Only: 0 files
Errors: 0 files
Total: 1 files
Byte Count Summary
Matched: 16,294 bytes differ
Left Only: 0 bytes
Right Only: 0 bytes
Total: 16,294 bytes
Example 4: Compare Files in Two Directories
You want to compare all of the files in one build folder to those in another folder. To compare the files in the two directories, discounting any differences caused by versioning and time stamp information, use the following syntax.
bindiff /s /v \\server\drop\old \\server\drop\current
BinDiff displays the following output.
appsec.dll Right-only File
appsec.exe Right-only File
appsec.hlp Right-only File
dcpromo.csv Identical
dcpromo.dll Different, Right is newer
dcpromo.exe Different, Right is newer
In this case, three files have been added to the new build directory. One file (Dcpromo.csv) has not changed between builds, while two files (Dcpromo.dll and Dcpromo.exe) show differences in addition to versioning and time stamp changes.