自我修改代码的用途是什么? [英] What are the uses of self modifying code?

查看:213
本文介绍了自我修改代码的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自我修改代码有真正的用途吗?

我知道它们可以用于构建蠕虫/病毒,但是我想知道程序员是否有一定的理由必须使用自我修改的代码.

I know that they can be used to build worms/viruses, but I was wondering whether there is some good reason that a programmer may have to use self modifying code.

有什么想法吗?假想的情况也欢迎.

Any ideas? Hypothetical situations are welcome too.

推荐答案

原来,"自修改代码"列出了一个很好的列表:

Turns out that the Wikipedia entry on "self-modifying code" has a great list:

  1. 与状态相关的循环的半自动优化.
  2. 运行时代码生成,或 运行时或加载时间(很流行, 例如,在 实时图形),例如通用 排序实用程序,准备执行代码 a中描述的关键比较 具体的调用.
  3. 更改对象的内联状态,或模拟高级 封盖的构造.
  4. 修补子例程地址调用,通常在加载时完成 动态库,或者每个 修补子程序的调用 内部引用其参数 以便使用其实际地址. 是否将此视为 是否使用自修改代码" 术语.
  5. 进化计算系统,例如遗传程序.
  6. 隐藏代码以防止逆向工程,例如通过使用 反汇编器或调试器.
  7. 隐藏代码以躲避病毒/间谍软件扫描软件 之类的.
  8. 使用滚动模式填充100%的内存(在某些体系结构中) 重复的操作码,以擦除所有 程序和数据,或老化 硬件.
  9. 要在运行时解压缩并执行的代码压缩, 例如,当内存或磁盘空间为 有限.
  10. 一些非常有限的指令集只能使用 自修改代码以实现某些目标 功能.例如,一个 指令集计算机"的机器 仅使用 如果负则减去并分支 指令"不能做间接的 复制(类似于 C编程中的"* a = ** b" 语言),而无需使用自我修饰 代码.
  11. 有关容错
  12. 的说明
  1. Semi-automatic optimization of a state dependent loop.
  2. Runtime code generation, or specialization of an algorithm in runtime or loadtime (which is popular, for example, in the domain of real-time graphics) such as a general sort utility preparing code to perform the key comparison described in a specific invocation.
  3. Altering of inlined state of an object, or simulating the high-level construction of closures.
  4. Patching of subroutine address calling, as done usually at load time of dynamic libraries, or, on each invocation patching the subroutine's internal references to its parameters so as to use their actual addresses. Whether this is regarded as 'self-modifying code' or not is a case of terminology.
  5. Evolutionary computing systems such as genetic programming.
  6. Hiding of code to prevent reverse engineering, as through use of a disassembler or debugger.
  7. Hiding of code to evade detection by virus/spyware scanning software and the like.
  8. Filling 100% of memory (in some architectures) with a rolling pattern of repeating opcodes, to erase all programs and data, or to burn-in hardware.
  9. Compression of code to be decompressed and executed at runtime, e.g., when memory or disk space is limited.
  10. Some very limited instruction sets leave no option but to use self-modifying code to achieve certain functionality. For example, a "One Instruction Set Computer" machine that uses only the subtract-and-branch-if-negative "instruction" cannot do an indirect copy (something like the equivalent of "*a = **b" in the C programming language) without using self-modifying code.
  11. Altering instructions for fault-tolerance

关于使用自我修改代码阻止黑客的观点:

On the point about thwarting hackers using self-modifying code:

在几次固件更新过程中,DirectTV慢慢在其智能卡上组装了一个程序,以销毁被黑客入侵以非法接收未付费频道的卡.有关更多信息,请参见黑色星期日黑客上的Jeff的《编码恐怖》一文.

Over the course of several firmware updates, DirectTV slowly assembled a program on their smart card to destroy cards that have been hacked to illegally receive unpaid channels. See Jeff's Coding Horror article on the Black Sunday Hack for more information.

这篇关于自我修改代码的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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