有没有真正的应用程序可以自我修改代码?

发布于 2024-12-07 21:55:49 字数 63 浏览 3 评论 0原文

网络上很少有示例演示如何编写自修改代码。但它们只是例子。我想知道是否有任何真正的应用程序可以自我修改代码。谢谢!

There are few examples on the web demonstrating how to write a self-modifying code. But they're just examples. I would like to know if there is any real application being self modifying code. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

泅人 2024-12-14 21:55:49

首先想到的是病毒、木马之类的。

自修改代码使防病毒应用程序更难将您的应用程序识别为恶意应用程序。

使用自修改代码的另一个领域是 遗传编程

还有一个 维基百科文章涵盖了您的问题。

The first thing that comes to mind are viruses, trojaners and the likes.

Self-modifying code makes it harder for anti-virus applications to identify your application as malicious.

Another area were self-modifying code is used is genetic programming

There's also a Wikipedia article covering your question.

苍白女子 2024-12-14 21:55:49

我可以参考其他架构吗?因为,当您使用较弱的系统(例如嵌入式应用程序)时,经常使用 SMC,因为只有有限数量的 RAM 可用于程序运行。

此外,维基百科有一个相当不错的 列表

Am I allowed to reference other architectures? Because, when you're working with weaker systems, like embedded applications, SMC is often used, since there is only a limited amount of RAM available for the programs to run in.

Also, wikipedia has quite a nice list.

那小子欠揍 2024-12-14 21:55:49

“自修改代码”也可能指 Java 中的字节码修改。许多框架(如 Guice、JPA、EJB 和 Web 容器)以及几乎所有 AOP(面向方面​​编程)框架都使用它。
基本上,它们在 JVM 加载和执行字节码之前对其进行修改。所有这些框架都试图向类添加行为,而不需要手动编写横切关注点。事务控制、依赖注入、作用域或上下文注入是常见的嫌疑对象。

'Self modifying code' may also refer to bytecode modifications in Java. This is used by many frameworks like Guice, JPA, EJB- and Webcontainers and almost all AOP (Aspect Oriented Programming) frameworks.
Basically they modify the bytecode before it is loaded and executed by the JVM. All those frameworks try to add behaviour to the class without the need to code cross-cutting concerns by hand. Transaction control, dependency injection, scope or context injection are the usual suspects.

调妓 2024-12-14 21:55:49

我知道一个程序包含自修改代码(作为保护方案),它的作用是在输入正确的密码时解密自身,并且解密的代码在将打开的文件保存到磁盘方面发挥着重要作用,该程序称为“WinHEX”.. 您可以在虚拟保护调用的正上方找到 SMC 代码,如果输入正确的密码,程序将调用写入进程内存 api 来解密该部分,并最终将文件保存到磁盘。

I know a program that contains a self modifying code (works as a protection scheme), it's role is to decrypt itself if the right password was entered and the decrypted code plays a big role into saving the opened file to disk, this program is called 'WinHEX'.. you can find the SMC code right above the call to virtual protect, and if the right password is entered, the program calls the write process memory api to decrypt the section, and to eventually save the file to disk.

人│生佛魔见 2024-12-14 21:55:49

动态语言运行时 (DLR) 使用自修改代码来优化给定调用站点的常见类型。

假设您正在 .NET 之上编写动态类型语言,并且您的语言的源代码如下:

x + y

现在,在静态类型语言中,x的类型y 可以在编译时确定 - 假设 xyint,那么 x + y< /code> 将使用 IL“add”指令。

但在动态类型语言中,这个分辨率每次都可能不同。下次,xy 可以是字符串,在这种情况下,此调用站点的值解析将使用 String.Concat。但决定使用哪种 IL 的成本可能会非常高。事实上,如果在调用站点的第一次命中中,xy 是一对 int,则很可能连续命中该调用站点也将带有一对 int 。

因此,DLR 进行如下迭代: 调用站点的编译代码如下所示:

return site.Update(site, x, y);

第一次传入一组给定类型(例如,一对 int)时,Update 方法将变为语言实现来确定哪个方法/指令应该与一对 int 和一个 + 一起使用。然后这些规则被重新编译到调用站点中;生成的编译代码看起来像这样:

if (x is int x1 && y is int y1) { return x1 + y1; }
return site.Update(site, x, y);

int 的连续调用使编译的代码保持不变。

如果遇到新的类型对,代码会自行重写为如下内容:

if (x is int x1 && y is int y1) { return x1 + y1; }
if (x is string x2 && y is string y2) { return String.Concat(x2, y2); }
return site.Update(site, x, y);

有关其工作原理的详细信息,请参阅 Jim Hugunin 在 PDC 2008 上关于动态语言的演讲DLR 设计文档,位于 DLR 项目

The Dynamic Language Runtime (DLR) uses self-modifying code to optimize for the common types of a given call site.

Let's say you're writing a dynamically typed language on top of .NET, and you have source code in your language as follows:

x + y

Now, in a statically typed language, the types of x and y can be determined at compile time -- say x and y are ints, then x + y will use the IL "add" instruction.

But in a dynamically typed language, this resolution could be different every time. Next time, x and y could be strings, in which case the value resolution for this call site would use String.Concat. But resolving which IL to use is liable to be very costly. In fact, if in the first hit of the call site x and y are a pair of ints, it's highly likely that successive hits on this call site will also be with a pair of ints.

So the DLR iterates as follows: The compiled code of the callsite looks like this:

return site.Update(site, x, y);

The first time a given set of types is passed in -- say, a pair of ints, the Update method turns to the language implementation to resolve which method/instruction should be used with a pair of ints and a +. Those rules are then recompiled into the callsite; the resulting compiled code looks something like this:

if (x is int x1 && y is int y1) { return x1 + y1; }
return site.Update(site, x, y);

Successive calls with pairs of ints leave the compiled code unchanged.

If a new type pair is encountered, the code self-rewrites into something like this:

if (x is int x1 && y is int y1) { return x1 + y1; }
if (x is string x2 && y is string y2) { return String.Concat(x2, y2); }
return site.Update(site, x, y);

For more information on how this works, see Jim Hugunin's talk at PDC 2008 on dynamic languages and the DLR design documentation at the DLR project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文