Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does inserting characters into an executable binary file cause it to "break"?
    primarykey
    data
    text
    <p>Why does inserting characters into an executable binary file cause it to "break" ?</p> <p><strong>And, is there any way to add characters without breaking the compiled program?</strong></p> <h3>Background</h3> <p>I've known for a long time that it is possible to use a hex editor to change code in a compiled executable file and still have it run as normal...</p> <h3>Example</h3> <p>As an example in the application below, <code>Facebook</code> could be changed to <code>Lacebook</code>, and the program will still execute just fine:</p> <p><a href="https://i.stack.imgur.com/5VicK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5VicK.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/7D2Z5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7D2Z5.png" alt="enter image description here"></a></p> <h3>But it Breaks with new Characters</h3> <p>I'm also aware that if new characters are added, it will break the program and it won't run, or it will crash immediately. For example, adding <code>My</code> in front of <code>Facebook</code> would achieve this:</p> <p><a href="https://i.stack.imgur.com/DcgRa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DcgRa.png" alt="enter image description here"></a></p> <h3>What I know</h3> <ul> <li>I've done some work with <code>C</code> and understand that <a href="https://stackoverflow.com/questions/3831312/compiler-and-linker-difference#3831354">code is written in human readable, compiled, and linked into an executable file.</a></li> <li>I've done introductory studies of assembly language and understand the concepts about data, commands, and pointers being moved around</li> <li>I've written small programs for Windows, Mac and Linux</li> </ul> <h3>What I don't know</h3> <ul> <li>I don't quite understand the relationship between the operating system and the executable file. I'd guess that when you type in the name of the program and press return you are basically instructing the operating system to "execute" that file, which basically means loading the file into memory, setting the processor's pointer to it, and telling it 'Go!'</li> <li>I understand why having extra characters in a text string of the binary file would cause problems</li> </ul> <h3>What I'd like to know</h3> <ol> <li>Why do the extra characters cause the program to break?</li> <li>What thing determines that the program is broken? The OS? Does the OS also keep this program sandboxed so that it doesn't crash the whole system nowadays?</li> <li>Is there any way to add in extra characters to a text string of a compiled program via a hex editor and not have the application break?</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload