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?
Why does making a seemingly insignificant edit to an executable's machine code return errors?
operating systems
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.