Tool for 3-Way Binary (Hex) File Comparison?
Asked Answered
H

5

5

I have a set of binary configuration files with three versions each -- an original, and two differently-modified versions of each file. I need to be able to see the differences between the two versions as well as the original, all at the same time.

What I need is a three-way diff tool for binary files. Through a rather exhausting Google search, I eventually happened upon a screenshot of an application that does exactly what I need -- unfortunately, the forum post containing the image does not mention what application it is they're using:

http://www.xboxhacker.org/index.php?topic=15032.0

Can someone point me in the direction of a (Windows) application that provides a binary-safe (hex) comparison of three binary files??

Honestly answered 30/12, 2010 at 2:55 Comment(1)
BTW, I'm really looking for a GUI tool. I'd be happy if someone could just tell me the name of that tool in the last screenshot in that forum post I referenced.Honestly
H
2

The screenshot is from Araxis Merge. Their pro edition ($270) supports 3-way compares.

Haiti answered 4/1, 2011 at 20:18 Comment(7)
This doesn't support 3-way merge of binary files. From the link: "In addition to two-way file comparison, the Professional Edition of Merge enables you to compare (and, for text files, merge) three files".Tegantegmen
I didn't see the OP's comment in your post. Well, it's the one pictured, and it does do 3-way binary compares. I would expect binary merge support is pretty rare, since it would be very easy to introduce corruption. That's certainly the reason we've never considered for in Beyond Compare.Lenticular
@Craig: " we've never considered for in Beyond Compare". Do you work on Beyond Compare? Great tool! Very well done!Tegantegmen
While any product developer is at liberty to design their product as they see fit, I personally find it ridiculous to refuse to produce useful tools (like 3-way binary merge) based on the possibility that someone might use it foolishly. There are plenty of things I could do to screw up my system or my employer's software, but I prefer not to, so I'm careful with the many useful and powerful tools I already have at my disposal. BC is not doing anyone any favors in this instance.Honestly
Craig: I've downloaded the evaluation of Araxis Merge and it appears you are correct -- Araxis Merge Pro DOES support 3-way merge of binary files! Pretty amazing. It's also very expensive (as you said) and apparently not terribly stable, since it just crashed on me after opening a second binary file. ;) But I'm going to invest in a commercial comparison product, I'd rather have the one that has all the features I'm going to need.Honestly
@Nathan, yes, I'm project manager and lead developer. Thanks for the kudos; I'm glad you like it.Lenticular
@Brian: We're not refusing to do something, we're giving it lower priority. The code and data structures for hex and text comparisons are very different, and implementing hex merging is a lot of work. It has to be scheduled, written, and tested just like any other feature. It's not like we have it working and just left it disabled out of spite. It's also not that of a common request, and we have to work on what our customers want. There are plenty of things BC supports that Araxis doesn't, like comparing Excel files or live registries, and ignoring renamed identifiers.Lenticular
T
10

Vim has a built-in diff tool that can compare an arbitrary number of files. It also runs on Windows. You can find it at http://vim.org.

The standard installation of vim for windows includes xxd, which allows you to see binary files as text:

So for example if you try:

xxd xxd.exe

you'll get:

0000000: 4d5a 9000 0300 0000 0400 0000 ffff 0000  MZ..............
0000010: b800 0000 0000 0000 4000 0000 0000 0000  ........@.......
0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000030: 0000 0000 0000 0000 0000 0000 d800 0000  ................
0000040: 0e1f ba0e 00b4 09cd 21b8 014c cd21 5468  ........!..L.!Th
0000050: 6973 2070 726f 6772 616d 2063 616e 6e6f  is program canno
0000060: 7420 6265 2072 756e 2069 6e20 444f 5320  t be run in DOS 
0000070: 6d6f 6465 2e0d 0d0a 2400 0000 0000 0000  mode....$.......
0000080: 6ba7 bec3 2fc6 d090 2fc6 d090 2fc6 d090  k.../.../.../...

etc...

So you can use xxd to dump your binary files into text files:

xxd orig > orig.txt
xxd mod1 > mod1.txt 
xxd mod2 > mod2.txt

And then run vim in diff mode:

vim -d orig mod1 mod2

And this will give you something like this:

example of 3-way vimdiff

(This screenshot was taken from here and is no more than an illustration of what a 3-way diff will look like in VIM)

All of these tools are available in windows, so they should solve your problem.

Edit:

After you merge the results of xxd, you can convert the hex dump into a binary file using xxd -r:

xxd -r merged_xxd_file merged_binary_file

You can see more details and options in xxd's manpage

Tegantegmen answered 30/12, 2010 at 9:42 Comment(4)
Thanks, but I'm looking for a GUI tool, such as the one in the screenshot at the end of that forum post I referenced. I should also add that I need to be able to merge, too.Honestly
vim has a gui. Just use gvim everywhere I wrote vim. vim's diff mode enables merging very efficiently.Tegantegmen
I can't merge binary files by dumping them into a text file and merging those. ;) I need to be able to merge actual binary files. But thanks, I didn't know vim had a Windows GUI.Honestly
@Brian: Yes you can, using xxd -r. I updated the answer with details.Tegantegmen
H
2

The screenshot is from Araxis Merge. Their pro edition ($270) supports 3-way compares.

Haiti answered 4/1, 2011 at 20:18 Comment(7)
This doesn't support 3-way merge of binary files. From the link: "In addition to two-way file comparison, the Professional Edition of Merge enables you to compare (and, for text files, merge) three files".Tegantegmen
I didn't see the OP's comment in your post. Well, it's the one pictured, and it does do 3-way binary compares. I would expect binary merge support is pretty rare, since it would be very easy to introduce corruption. That's certainly the reason we've never considered for in Beyond Compare.Lenticular
@Craig: " we've never considered for in Beyond Compare". Do you work on Beyond Compare? Great tool! Very well done!Tegantegmen
While any product developer is at liberty to design their product as they see fit, I personally find it ridiculous to refuse to produce useful tools (like 3-way binary merge) based on the possibility that someone might use it foolishly. There are plenty of things I could do to screw up my system or my employer's software, but I prefer not to, so I'm careful with the many useful and powerful tools I already have at my disposal. BC is not doing anyone any favors in this instance.Honestly
Craig: I've downloaded the evaluation of Araxis Merge and it appears you are correct -- Araxis Merge Pro DOES support 3-way merge of binary files! Pretty amazing. It's also very expensive (as you said) and apparently not terribly stable, since it just crashed on me after opening a second binary file. ;) But I'm going to invest in a commercial comparison product, I'd rather have the one that has all the features I'm going to need.Honestly
@Nathan, yes, I'm project manager and lead developer. Thanks for the kudos; I'm glad you like it.Lenticular
@Brian: We're not refusing to do something, we're giving it lower priority. The code and data structures for hex and text comparisons are very different, and implementing hex merging is a lot of work. It has to be scheduled, written, and tested just like any other feature. It's not like we have it working and just left it disabled out of spite. It's also not that of a common request, and we have to work on what our customers want. There are plenty of things BC supports that Araxis doesn't, like comparing Excel files or live registries, and ignoring renamed identifiers.Lenticular
R
2

You could have a look to ECMerge (a tool I work on), it has a 2 and 3-way diff of binary files (HEX + ASCII). There is no merge feature. You can move from changed area to change area easily and compact long zones (long insertions, changes or unchanged).

Retain answered 10/12, 2011 at 15:8 Comment(0)
T
0

The latest version of Beyond Compare seems to support 3-way diff and merge. Moreover, its feature list says it supports comparison of binary files.

Note that this is not free software :-)

Tegantegmen answered 30/12, 2010 at 16:22 Comment(3)
I checked into this previously. BC has Text 3-way Compare and it has Binary Compare -- these are separate modes, they do not work together. I can't imagine why they'd make such a ridiculous distinction, but that's just how it is. :(Honestly
@Brian: You can use xxd to convert the binaries into text, then use BC for 3-way compare, then xxd -r to convert the merged text back into binary.Tegantegmen
@Brian: The algorithms, data structures, and editor interfaces are completely different between a text comparison and a binary one. It's not an arbitrary limitation, it's a matter of priorities and months of development for something that isn't a common request.Lenticular
T
0

I was recently introduced to p4merge, which appears to also support binary files.

It takes 3 files as input: The original and two derivatives. It shows them side-by-side, with a fourth window that shows the merged file, with editing capabilities and conflict resolution.

I just used this to merge two branches of a large codebase, and it was extremely convenient.

p4merge example

Now, I haven't used it to merge binary files, but it does support diffing pictures, so I'd be surprised if binaries weren't supported.

Tegantegmen answered 15/7, 2014 at 20:29 Comment(1)
It cannot diff binaries. No surprise here, many VCSes support at least diffing of images out of the box because images is a common contents type when doing website or publication or UI.Ap

© 2022 - 2024 — McMap. All rights reserved.