1

This silly question happened to me when thinking about ways to write an executable binary
from scratch and somehow use it as a starting point for a new programming language project.
Meaning: you can't really make a working language,
if you can't produce and understand what makes a binary executable,
you can't make useful or working programming language.

So how can I make the most basic minimal and lightweight binary executable with as little complexity as possible in the executable itself and the tools that produce it?

How is it (executable binary) produced in the Linux and Windows platforms?

Maybe I need a hex editor not a text editor to achieve it?

Are there specific bits that make up the raw binary file that make it executable or does the operating system have to register it as executable?

Could I simply copy/paste binary code using editor and make it (raw binary file) executabe?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
user3789797
  • 450
  • 6
  • 15

1 Answers1

1

Yes, it's theoretically possible to create an executable file by hand in a hex editor. With some executable formats it's easier, with some - much harder. The very old COM format of MS-DOS is the simplest - it has no header whatsoever, the executable code starts at the beginning of the file. What does an executable look like?

The need for Hex Editor instead of Ascii/UTF Text Editor

The native text editor you're using is only showing you printable characters, or replacing unprintable characters with spaces, rectangles, or other gibberish. When you copy text from an opened binary file using native text editor, you're copying a broken representation of the file. You need to open binary files (that's what they're called) in something like a hex editor. (Then also paste in a hex editor.)

Notepad++ as Hex Editor

Notepad ++ can be used as Hex editor using a plugin by Jens Lorenz: https://www.youtube.com/watch?v=_f1PDl1TynE

Loading process of PE Windows Executable

Windows PE Executable walkthrought by Ange Albertini https://github.com/corkami/pics/blob/master/binary/pe101/pe101l.pdf enter image description here

Pe Format

Image source: https://tech-zealots.com/malware-analysis/pe-portable-executable-structure-malware-analysis-part-2/ enter image description here

user3789797
  • 450
  • 6
  • 15