How to Remove "Headers" and "Footers" from Executable Files

Posted on 2011-10-23
Last Modified: 2012-05-12
I am attempting to remove the header and the footer from an executable file so that I can compare one executable file to another, and I was wondering if there was a way in order to remove the information that Windows adds to compiled programs within Visual Studio or C++ (or any other Microsoft Programming language). I am have been told to use PEExplorer, but I was also wondering if there was any other w ay to remove the "time stamp" from inside of the executable along with any other information stored in the header that is set each time the application is compiled and does not have anything to do with the actual executable binary code that is compiled when the user builds a new project within Microsoft compilers.

If anyone could provide any suggestions to how to remove the header information and just have the "guts" of the executable that is being used would  be greatly appreciated.
Question by:thenthorn1010
    LVL 77

    Assisted Solution

    by:David Johnson, CD, MVP
    if you change anything within an executable you have to rebuild the checksum or the .exe will fail (invalid checksum), you also may damage the structure so that you have to adjust the entry points and other internal tables. Easier to decompile/disassemble and then recompile/remake the file.

    The .exe follows a very strict sequence
    LVL 32

    Assisted Solution

    you better compare the .obj (release configuration) files before linking. those are more likely to be comparable than an executable.

    LVL 37

    Accepted Solution

    It is my understanding that the checksum is only computed over the image, not the header. (.exe files are in the category of "image files" in the documentation, by the way). So if you change only the header, there shouldn't be any checksum errors.

    There are no options to not include this header info in any compiler. This information is required for any file that is in the PE format (which all your DOS/Windows exe files will be).

    The only option is to hack the required changes after you compile the exe files. Since you already have the format of the PE files and know where the pieces you want to manipulate are, you just need to write a program that changes those fields to what you want.

    For a complete write-up of the format see

    This is not the best way to do it though. The best way would be to have your program that compares the files just ignore the headers. If you don't currently have a program for comparing the exe files, you should write one. It will be pretty simple to just tell it to skip all the header bytes and only look at the image bytes.

    Another snag you may run up against is that the order in which the linker links the different pieces together can change the actual image. I can see no way around this issue unless you have the individual .obj files to compare against (which I doubt).


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now