0

I was studying how program and operating system works when an interesting(maybe stupid) scenario came up in my head. What happens if you execute a text file? What I did was, I create a text file with the word "hello" in it, and then save the file as an executable.

When I run it, Windows says it cannot open this type of file. What's going on?

Shouldn't the word "hello" be changed into binary and executed although with random instruction?

Thanks for clearing up my misunderstanding of how exe works.

user1535147
  • 1,325
  • 5
  • 14
  • 21

3 Answers3

2

An executable file needs to have a specific structure

what's in a .exe file?

You should go through the answer on the above question for a detailed explanation

Community
  • 1
  • 1
Akash
  • 1,716
  • 2
  • 23
  • 43
0

Just saving as an executable does convert to binary. You will need a compiler for that. If you are interested in programming, I suggest checking YouTube tutorials on java, android, iOS, C# or any number languages. Most good ones will start off with teaching you where to go to get free software to begin developing in whatever your desired language is.

0

The process of execution involves many steps. When you execute an executable file, the program loader reads the descriptors in the file for dynamic linking/shared libraries/DLLs to determine what all needs to be loaded. It needs to confer the descriptors for memory into actual memory (e.g. a program typically includes read only memory, read execute memory, and read write memory) that the loader has to set up. The loader has to resolve relocatable addresses. It has to create a stack.

After it has done all the setup, it runs your program.

If you just give it a text file, the loader finds none of the data strutters it needs to set up the program and just pukes.

On some systems (typically embedded) the executable is just an image of the memory. This is not the case of a typical interactive system that you are likely to use.

user3344003
  • 20,574
  • 3
  • 26
  • 62