Zach
Zach

Reputation: 59

Why are “binary files” not in raw binary?

I have a C program saved in an executable (.exe- I have heard this also referred to as a “binary” file). When I open that in a text editor, it is not in binary, but in some other wacky assembly of characters. Why is this? what stage of execution does the file actually display? Why does this intermediary text exist between the C code and actual raw binary?

Upvotes: 2

Views: 1646

Answers (2)

dbush
dbush

Reputation: 223689

The "wacky assembly of characters" that you see is binary. Generally speaking, a binary file is any file that is not plain text but instead contains data meant for a program to read instead of a person.

The .exe file you have contains the machine code required to run the program, along with some data describing the layout of the file.

What you see when you open the .exe in a text editor is the editor trying to make sense of what it's reading. Some of the bytes in the file might be ASCII codes for readable characters, so you'll see those characters in that case. For bytes whose ASCII code is not a printable character, the editor attempts to display in some way that makes sense.

Upvotes: 4

Abhishek Bhagate
Abhishek Bhagate

Reputation: 5766

.exe is a file extension that stands for executable. An executable file is not source code, it is a file that has been compiled to be ran directly by an operating system. Those random characters that you see are because the file consists of a series of bytes that are not designed to be viewed as text.

A binary file is a computer file that is not a text file. The term "binary file" is often used as a term meaning "non-text file". Many binary file formats contain parts that can be interpreted as text; for example, some computer document files containing formatted text, such as older Microsoft Word document files, contain the text of the document but also contain formatting information in binary form.


These files are not meant to be read or viewed on text editor like notepad. Most text editing programs do not parse binary encoding formats, and are expected to parse ASCII character code formatting.

You need an disassembler, a hexadecimal viewer or a specific tool such as readpe to read the content exe files. They But code obfuscation may hinder disassembly. Code might be delibrately obfuscated to make it harder to retrieve the source code.

Upvotes: 1

Related Questions