Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I'd like to write a compiler for Windows, since writing a compiler i.e making a programming language from scratch is tough, I'd like to write a simple EXE generator i.e a program that creates EXE's from scratch, no use of C# Code Providers or Windows API's, a program that generates a simple,executable file, maybe a program that print hello world, and that's it.
I am trying to create something similar to a compiler, but would not contain parsing,lexing,Code Converters, Just would create a simple executable that prints Hello World or something like that.
Posted

Okay, you can go ahead and do it. You will need to learn the following:
  1. The specifications for the Portable Executable file format:
    http://en.wikipedia.org/wiki/Portable_executable[^],
    http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx[^],
    http://msdn.microsoft.com/en-us/magazine/cc301808.aspx[^],
    http://www.ntcore.com/files/dotnetformat.htm[^].
  2. The specification on your CPU instruction set, to be able to write code:
    http://en.wikipedia.org/wiki/Instruction_set[^].
  3. The reference on Windows API, to be able to call anything to display "Hello World!", for example:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ms645452%28v=vs.85%29.aspx[^],
    http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073%28v=vs.85%29.aspx[^].


Let me tell you: I doubt this is a reasonable path to creation of a compiler, but for the purpose of the study this exercise could certainly be useful.

—SA
 
Share this answer
 
v2
Comments
ridoy 13-Sep-13 13:50pm    
bunch of useful links,5ed!
Sergey Alexandrovich Kryukov 13-Sep-13 14:05pm    
Without a whole bunch of links — nowhere... :-)
Thank you.
—SA
sid2x 14-Sep-13 0:48am    
Thanks for those links SA
What I wanted to actually learn is about Windows exes
Of course making a compiler is very different but at the end of the story, the compiler generates an EXE
5/5!!
Sergey Alexandrovich Kryukov 14-Sep-13 1:16am    
You are right. A answered because I used to generate some code immediately writing to executable files (in may case, by modifying, but the idea is the same). This is a kind of dirty business, but for certain purposes, like experimental ones, it could be useful.

You are very welcome.
Good luck, call again.
—SA
Ummm...yeah. I don't know if you know what you're getting into but the terms "simple" and "EXE Generator" do not belong in the same sentence. They are mutually exclusive terms.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900