如何在C#中创建一个简单的EXE生成器 [英] How to make a simple EXE generator in C#
问题描述
我想为Windows编写一个编译器,因为编写编译器即从头开始编写语言很难,我想编写一个简单的EXE生成器,即从头开始创建EXE的程序,不使用C#代码提供程序或Windows API,一个生成一个简单的可执行文件的程序,可能是一个打印hello world的程序,就是这样。
我正在尝试创建类似于编译器的东西,但是不包含解析,lexing,代码转换器,只需要创建一个打印Hello World或类似的简单可执行文件。
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.
推荐答案
好的,你可以继续这样做。您将需要学习以下内容:
Okay, you can go ahead and do it. You will need to learn the following:
- 可移植可执行文件格式的规范:
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 [ ^ ]。 - CPU 指令集上的规范 ,能够编写代码:
http://en.wikipedia.org/wiki/Instruction_set [ ^ ]。 - 在Windows API上引用,以便能够调用任何东西来显示Hello World!,例如:
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 一> [ ^ ]。
- 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[^]. - The specification on your CPU instruction set, to be able to write code:
http://en.wikipedia.org/wiki/Instruction_set[^]. - 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[^].
让我告诉你:我怀疑这是创建编译器的合理途径,但是为了研究的目的,这个练习肯定是有用的。
嗯...是啊。我不知道你是否知道你要进入的是什么,但术语简单和EXE发生器不属于同一个句子。它们是相互排斥的术语。
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.
我知道,这个话题非常陈旧......但是,看看我的项目......
https://github.com/bencz/CoffLib [ ^ ]
https://gist.github.com/bencz/3576dfc8a217a34c05a9 [ ^ ]
https://gist.github.com/bencz/4414035 [ ^ ]
I know, that topic is very very old... but, look my projects...
https://github.com/bencz/CoffLib[^]
https://gist.github.com/bencz/3576dfc8a217a34c05a9[^]
https://gist.github.com/bencz/4414035[^]
这篇关于如何在C#中创建一个简单的EXE生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!