executable - 自修改代码有什么用?

标签 executable self-modifying

自修改代码有任何实际用途吗?

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

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

最佳答案

事实证明,维基百科条目“self-modifying code”有一个很棒的列表:

  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

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

在几次固件更新过程中,DirectTV 慢慢地在其智能卡上组装了一个程序,用于销毁被黑客非法接收无付费 channel 的卡。请参阅 Jeff 的编码恐怖文章 Black Sunday Hack了解更多信息。

关于executable - 自修改代码有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/516688/

相关文章:

assembly - 在 x86 汇编器中找到用于教育目的的最小自修改代码示例?

c++ - 自修改代码 [C++]

linux - Gdb 在自修改代码中切换断点

android - Android 上的 native 自修改代码

Java Netbeans GUI 生成器制作可执行 jar

python - 运行 sudo 命令以在脚本中执行可执行文件

ruby - 如何将 Ruby 脚本作为可执行文件执行?

c - Linux在运行时写入进程自己的可执行文件

c# 多个计时器编辑同一个列表

c++ - 如何对 .exe 附带的外部文件进行编码