Cheap and Secure Web Hosting Provider : See Now

[Solved]: Why does making a seemingly insignificant edit to an executable's machine code return errors?

, , No Comments
Problem Detail: 

First of all, I would like to apologize if this question is in the wrong section. For all I know, it could be placed in Super User, Reverse Engineering, or Stack Overflow.

Now lets get back the experiment I tried:

What I did was took an executable file and changed its file type to a text document type. Then I opened this file in a text editor and changed a single character. This character was just part of some descriptive copyright information. After this I changed the file type back to an executable file type and tried running it. Why does the Windows operating system return the error, "The version of this file is not compatible with the version of Windows you're running...", when attempting to run the executable?

What is happening underneath the hood when an executable runs?

Asked By : Armend Veseli

Answered By : Yuval Filmus

When you open an executable in a text editor then the editor reads the contents in some lossy way - even if you haven't changed anything then the file would be different. Binary files contain non-printable characters (those with ASCII codes from 0 to 31), and these could be deleted by the text editor (other than CR/LF), especially the 0 character. Also, Windows text editors would convert CR (the UNIX new line convention; 0D) to CR/LF (the Windows convention; 0D 0A).

If you're curious what went wrong in your case, try to compare the files byte by byte and see where the differ. You could use a "hex editor", which is what you should have used to modify your file in the first place. These editors don't mishandle your files.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/21625

3.2K people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback