如何使用C ++从较早版本创建新的exe文件? [英] How to create new exe file from older in c++?

查看:101
本文介绍了如何使用C ++从较早版本创建新的exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设某天你不是程序员朋友告诉你的:

为我制作应用程序,并将其命名为"old.exe"."old.exe"必须具备三个功能.

->打开记事本

->显示消息框

->创建名为"new.exe"的exe文件,该文件具有1. case或2. case或同时具有两者的功能.".

因此,您使用"C ++ builder 2010",打开"VCL Forms应用程序",并放置两个CheckBoxes"和一个按钮".您将按钮"Create new.exe"的标题"命名为"1",将"Openbox记事本"的命名为1.复选框",将显示消息"的命名为2.复选框".

但是您使用了什么代码?

记住,您亲爱的朋友不是程序员,他不知道如何制作打开记事本"或显示消息"甚至两者的exe("new.exe")文件,但他只会检查"希望复选框"(来自您的应用程序"old.exe"),他将获得具有这些功能的"new.exe".

那么,您在这些"old.exe"应用程序中放入了什么代码?

Let''s say that one day you''re no programmer friend told you:

"Make for me application, and give it name "old.exe". "old.exe" have to posess three functionality.

-> To open notepad

-> To show message box

-> To create exe file called "new.exe", which have functionality of 1. case, or 2. case, or have both.".

So you take "C++ builder 2010", open "VCL Forms application", and put "two CheckBoxes", and "one button". You named "caption" of button "Create new.exe", and 1. "checkbox" named "Open notepad", and 2. "checkbox" named "Show message".

But what code did you use?

Remeber that you dear friend is not programmer and he don''t know how to make exe ("new.exe") file which "open notepad" or "show message" or even both, but he will just "check" wished "checkbox" from your application "old.exe", and he will get "new.exe" which will have those functionality.

So what code did you put inside those "old.exe" application?

推荐答案

含糊而无奈地表达了原因",例如原因".我使用许多快捷方式"服务器无法作为打破某些非常基本的计算机范式的任何尝试的理由.带有配置和/或状态文件的解决方案是完全可行且常规的解决此类问题的方法.在考虑任何深奥的"方法之前,请尝试掌握使用主导范式进行编程的本质,并且至少不要浪费您的时间来努力滥用您正在使用的OS的工作范式.

作为关于在文件中克隆数据的方法的文件创建可行性的简短说明,让我解释一件简单的事情.在Windows系统中,您无法删除或修改当前加载到内存中的任何可执行文件.惊喜?尽管可以相对轻松地解决这一限制"(实际上这不是限制,而是一项重要的安全功能),但我什至不想讨论它.我更愿意解释这种方法是多么的错误和徒劳.

您是否曾经掌握过通用图灵机"的概念? 冯·诺依曼建筑"? 哈佛建筑"?您正在使用基于Intel或AMD CPU的计算机,该计算机具有由Harward设计的 指令集体系结构 架构.几乎所有现代的 操作系统 都遵循这种体系结构,这首先意味着具有存储程序的体系结构,独立的存储器,用于存储程序和数据;程序存储器在执行期间不会被修改.这些基本原理转化为与编程有关的所有基本概念,例如程序的编译/链接/加载,可执行文件以及其中的所有内容.

请参阅> http://en.wikipedia.org/wiki/Stored-program_computer [^ ].

一旦您使用基于编译的语言和编程系统(解释性语言是另一回事),并且将其编译成本地CPU指令集代码,所有主流编程都基于相同的原理. CPU体系结构的发展带来了对加载的程序代码和可执行文件进行绝对严格的硬件保护以免被修改的可能性.您应该接受所有基本原则,而不要与之抗争.至少,不要试图与诸如保存的复选框"之类的悲惨目标的基础背道而驰.

说到许多复选框":至少要熟悉 有限状态机 并考虑其在数据和操作中的表示.

免责声明.以上答案是针对该问题的第2节而写的.我想还是应该知道的.



—SA
The vaguely and helplessly expressed "reasons" like "cause I use many shortcuts" can no way server as a justification for any attempts to break some very fundamental computer paradigms. The solution with configuration and/or state file is perfectly feasible and regular way to solve any problems like that. Before considering any "esoteric" approaches, try to get the essence of programming using dominating paradigms, and at least don''t waste you time on endeavour aimed to abuse the working paradigms of the OS you''re using.

As a short note about feasibility of file creation of approach of the approach of cloning data in the file, let me explain one simple thing. In Windows systems, you cannot remove or modify any executable files currently loaded in memory. Surprise? Even though one can relatively easily work around this "limitation" (which is in fact not limitation but an important safety feature), I don''t even want to discuss it. I prefer to explain how wrong and fruitless this approach is.

Have you ever head of the concepts of "universal Turing machine"? "Von Neumann architecture"? "Harvard architecture"? You are using a computer based on Intel or AMD CPU with instruction-set architecture designed with Harward architecture in mind. Nearly all modern operating systems follow this architecture which first of all means the architecture with stored program, and separate memory for storing a program and data; program memory is not modified during execution. These basic principles are translated onto all the basic conceptions related to programming, such as compiling/linking/loading of programs, executable files and everything on top of it.

Please see http://en.wikipedia.org/wiki/Stored-program_computer[^].

As soon as you work with languages and programming systems based on compilation (interpretive languages is a different story), and the compilation into the native CPU instruction-set codes, all the mainstream programming is based on the same principles. Development of CPU architectures led to possibilities for absolutely strict hardware protection of loaded program code and executable files from modification. You should embrace all the basic principles instead of fighting against them. At least, don''t try to find against the fundamentals for such miserable goals like preserved "check boxes".

Speaking of the "many check boxes": at least get familiar with the concept of finite state machine and think about its representation in data and operation.

Disclaimer. The above answer is written in response to v.2 of the question. I think it''s good to know anyway.



—SA


回答问题的v.3:

无论如何,这也没有任何意义.首先,除非将子进程专门设计用于某种狡猾的协作,否则绝对没有必要从另一个应用程序中启动一个应用程序.特别是像记事本这样的基础.谁需要启动它? Windows应用程序中添加的大多数原始文本编辑器组件都会做得更好,但是在这种情况下,您将对其具有完全控制权.对于记事本,用户可以比自己更好地启动它-您是否考虑过?

仅仅通过设计和编程满足任何要求的常规单个应用程序并以任何可考虑的灵活性水平,都无法实现任何目标.如果您考虑一下,您的朋友就不会在意创建新的可执行文件的过程.他只需要显示一些功能即可.您可以通过数百万种方法来实现此目标,所有这些都避免了无用的替换编译器/链接器的想法.

最终用户不需要它.但是您应该了解什么是更好的应用程序,可执行文件和进程,以及编译器和链接器的功能.需要教育.

如果您不知道如何在不生成可执行文件的情况下实现所需的灵活性,那么您就不是真正的编程专家,而是幻想着您不太了解的事情.再次,首先学习传统方式的一些基础知识.无论如何,如果您尝试以正确的方式编写一些应用程序并遇到一些问题,我们将很乐意为您提供帮助.

—SA
Answering the v.3 of the question:

It also makes no sense, whatsoever. To start with, there is absolutely no sense in starting one application from another one unless the child process is specifically design for some sly kind of collaboration, which is also unlikely. Especially such a rudiment like the notepad. Who needs to start it, ever? Most primitive text editor component added to your Windows application will do much better, but in this case you will have a full control over it. As to notepad, you user can start it even better than you can — did you think about it?

There is nothing you cannot achieve just by designing and programming of a regular single application meeting any requirements with any thinkable level of flexibility. If you think about it, your friend does not care about the process of creation of new executable file. He only needs some functionality to appear. You can achieve this goal in million ways, all avoiding fruitless idea of substituting of the compiler/linker.

A final user does not need it. But you should understand what better what the application, executable file and process are, and what the compiler and linker do. Education is needed.

If you have no clue how to achieve required flexibility without generating an executable file, you are not really going in for programming but rather fantasizing about matters you don''t really understand. Again, learn some basics of traditional way first. Anyway, if you try to write some application in a right way and face some problems, we will gladly help you.

—SA


那么您在这些"old.exe"应用程序中放入了什么代码?
很多,但不会在此处插入.您需要的是一个代码生成器,它将执行一些简单的检查决策并为您生成程序.一个星期天下午的工作太多了.
So what code did you put inside those "old.exe" application?
Lots, but it will not get inserted here. What you are asking for is a code generator that will take a few simple check decisions and generate a program for you. It''s too much work for a Sunday afternoon.


这篇关于如何使用C ++从较早版本创建新的exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆