In Windows, I wish to compare old binary files with newly built ones in order to determine which files has been updated. However, when I build the files I give them new meta data details (like version etc.). By right clicking the file and going to the tab 'Details' you can see file version and other information. This causes the comparisons differentiate. Is it possible to work around this in order to check which files are equal or not?

  • Binary file is an ordered stream of bytes without any structure. If you distinguish some structural constructions (such as a metadata) in it you assume there is any structure whereas standard utilities which compares binary files do not know about it. So you may create your own comparing tool which will take into consideration this strusture too and compare datapart only, or, if metadata block is static (both in position and in size), you may compare files using standard utilities and ignore the difference in metadata addresses. – Akina Aug 13 '18 at 11:54
  • The only difference is really in the File version attribute. So instead of "3.0.3" it could be "". As to the standard utilities, is there any specific one you thought of and/or would recommend? – Alexander Aug 13 '18 at 12:04
  • The only difference is really in the File version attribute. There is no any attribute in binary files. There is no structure in binary files at all. As I understand you use the term 'binary' instead of 'compiled executable' or something similar. – Akina Aug 13 '18 at 12:37
  • I am talking about .exe- and .dll-files. – Alexander Aug 13 '18 at 12:53
  • Google for "compare binary files". This gives you plenty of tools that let you do so. Just view the differences and ignore metadata changes (since you 'build the files' I assume you know where the metadata is located). – Jan Doggen Aug 14 '18 at 12:50

Give Angus Johnson's Resource Hacker a try. This free tool will allow you to view (and even edit) the resource tables in a given executable as long as the PE or library was compiled with the Version Info resource. Please keep in mind that you won't be able to view or edit the resource files within an obfuscated binary.

| improve this answer | |
  • 1
    This application probably is suitable for what I asked when I scrolled through it. Although as Alex pointed out this is really is the wrong way to go about as a workflow. I will close this question and refrase it to something better as this attacks the core problem from the wrong way. – Alexander Aug 16 '18 at 12:16

I reread your comments and it looks to me like you want to compare version info from executable files and libraries instead of checking integrity of files.

Well, first off all you need to understand that there no such terms as "metadata header". Executable files and libraries on windows has concept of so called "resources" that linked to final file on compilation/linking. It isn't requirement, so programmer may use resources or simply skip it. In a file's resources one can pack practically anything, icons, sounds, picture, malicious encrypted payload and so on. In the same resource file programmer may specify additional textual info such as file version. You need to understand, that file version isn't advancing automatically in some languages, it is a programmers manual job to change file's version.
Ok, let back to subject, I guess you want to compare file versions between executable/libraries files, so you can use command line tool to extract file version from resources with help of official utility from Microsoft sigcheck.exe that is part of very useful utilities from Sysinternals Suite. If you would run sigcheck.exe on executable files that has resources, then this program will extract "meta-data" you mentioned:

Prod version:
File version:

You can parse further fields you need to compare with you preferred tool.

If you can use Windows API, you can extract "meta-data" from resources programmatically by employing FileVersionInfo WinAPI.

Previous guess:

Since you mentioned compare old binary files with newly built ones, then the best option for you would be to use version control systems such as git or fossil that both can track changes in binary files besides of convenient tracking of source files.

You can also compare binary files in multiple ways:

The standard Unix's diff utility that can compare binary files, it simply would tell if it differ or not.
(If you're on windows 10, you can use WSL to run natively unix's utility)

There is also visual binary diff that runs on both, - windows and Unix.

Native window's utility fc also can do binary comparison as fc /b file1 file2

You can use explorer extension that can calculate hash of binary files, for example HashCheck, DirHash or even use Microsoft's fciv

If you using Microsoft visual studio, you can also use WinDiff

For a huge files (in Terabytes size) comparison you can use old good HxD

| improve this answer | |
  • A well put together post, however, unfortunately I've tried some of these suggestions and all of them have been comparing header as well which causes it to complain on differences. – Alexander Aug 14 '18 at 8:43
  • I guess we talking about apples and oranges :) I updated my answer, is that what you want? – Alex Aug 14 '18 at 12:39
  • Clarifying: If I build a dll with fileversion and build that as file.dll. Then change the fileversion to and build it and place it in another folder. I want to know if the data is equal (which they are in this case). I found that I can change File version by altering its buffer with program StampVer in order to get the same file versions on both files and then proceed to check if they are equal. However, StampVer is unable to handle small versions like "2.4" as it want only expect inputs of four like: "". This would overwrite the buffer. – Alexander Aug 14 '18 at 14:05
  • "I want to know if the data is equal" - What data are you talking about ??? What "buffer" is? If you building yourself dll file, it all in your source code or you trying to hack some1's dll with tools like StampVer? Please clarify what are doing exactly. You using common word like "build" that generally known as - build file from source code, but I guess you have your own special meaning regarding this. – Alex Aug 14 '18 at 14:21
  • I want to know if there are any changes in my source code or if they remain unmodified after iterations of versions. The data (is "the program" i've written). The buffer that I refer to is just simply the "amount of data which is allocated for the resources". If the string had 3 chars previously, obviously, everything would break if it is adjusted to being 8 chars. Anyways, StampVer is a detour but my point is that if the fileversion are equal. Then the files would be equal and therefore be eligable for comparing with byte or hash comparisons. – Alexander Aug 14 '18 at 14:43

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.