Link to home
Start Free TrialLog in
Avatar of thenthorn1010
thenthorn1010Flag for United States of America

asked on

How to Tell If Two Executable (Binary) Windows Files are the same

I am attempting to compare two executables that are compiled from the same source code within Visual Studio 2008 and Visual Studio 2010. When I attempt to use WinMerge or PE Explorer, I can get the same source code showing several variations from one another even though they were compiled from the same source code. For instance if I were to compile executable_A at 1pm and then compile executable_B at 2pm, I would end up with several distinctions within the *.exe file itself when comparing them with WinMerge or PE Explorer. From using these programs, I have found that the date/time stamp of when the *.exe was created is different and embedded into the *.exe as well as there is something called a "magic number" that is different if you were to compile the same source code on two different computers. I was wondering if someone knew of a way to make the executables be the same throughout the entire executable file, by removing the date/time stamp or removing the "magic number" that is found when using these two applications to compare *.exe. (During the testing of these applications, I used some source code that was compiled in Visual Basic, C++, and C#. All languages ended up with the same results.)

Any help that could be provided on this issue would be greatly appreciated.
Avatar of Bill Nolan
Bill Nolan
Flag of United States of America image

There may be a prettier way to do this, but just a couple ideas:

1) Examine the compiler options and docs closely.  There may be switches, etc., to keep that data out, or to manually set it.
2) Depending on exactly what is being embedded, you may be able to fake it (by rigging the system clock, e.g.).  Cheesy.
3) If the differences are small and are written to a static header, you may be able to simply figure out where they are and ignore them (or copy from one to the other if you need to make them match).
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thenthorn1010

ASKER

TommySzalapski,

Thank you for the link to the article. It did help explain a lot to me about the PE file format. I was wondering if by chance you knew how to turn off the settings for having all of the information that was mentioned above from any *.EXE that is compiled and built within Windows. (I am being forced to use legacy code on Microsoft Visual C++ version 6 to begin this project, and the person purchasing the code would like to know that they are getting the same code that they have on their FTP site from the source code that they are purchasing.)

Thank you again for any help you can add and for all of the help that you provided.

One question...I was under the impression that the "Magic Number" was unique to each computer because it was representative of the processor that is being used...is that true? Or, why is the magic number the same on each computer, if I am incorrect?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the in-depth explanation...it helped me tremendously...