* 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory
* 0xABADCAFE : A startup to this value to initialize all free memory to catch errant pointers
* 0xBAADF00D : Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory
* 0xBADCAB1E : Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger
* 0xBEEFCACE : Used by Microsoft .NET as a magic number in resource files
* 0xCCCCCCCC : Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory
* 0xCDCDCDCD : Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory
* 0xDDDDDDDD : Used by Microsoft's C++ debugging heap to mark freed heap memory
* 0xDEADDEAD : A Microsoft Windows STOP Error code used when the user manually initiates the crash.
* 0xFDFDFDFD : Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory
* 0xFEEEFEEE : Used by Microsoft's HeapFree() to mark freed heap memory
显然,单字节操作码对此非常简单,但也可能存在奇怪的例外:例如,考虑到填充序列 0xCDCDCDCD (本页也提到过),我们可以看到它相当可靠,因为无论instruction pointer落在哪里(除了最后填充的字节之外,CPU可以继续执行有效的 two-byte x86指令 CD CD ,在这种情况下用于生成软件中断205(0xCD) .
Weirder仍然,而 CD CC CD CC 是100%可解释的 - 给出 INT 3 或 INT 204 - 序列 CC CD CC CD 不太可靠,只有75%如图所示,但通常99.99%重复作为int大小的内存填充 .
3 回答
此链接有更多信息:
http://en.wikipedia.org/wiki/Magic_number_(programming)
实际上,调试分配中添加了许多有用的信息 . 这个表更完整:
http://www.nobugs.org/developer/win32/debug_crt_heap.html#table
特别是关于
0xCC
和0xCD
,这些是20世纪80年代 Intel 8088/8086 处理器指令集的遗物 .0xCC
是software interrupt操作码INT0xCD
的特例 . 特殊的单字节版本0xCC
允许程序生成 interrupt 3 .尽管软件中断号原则上是任意的,但
INT 3
传统上用于 debugger break 或breakpoint函数,这一惯例至今仍然存在 . 无论何时启动调试器,它都会为INT 3
安装一个中断处理程序,以便在执行该操作码时,将触发调试器 . 通常,它会暂停当前正在运行的编程并显示交互式提示 .通常,x86
INT
操作码是两个字节:0xCD
后跟0-255之间的所需中断号 . 现在虽然您可以为INT 3
发出0xCD 0x03
,但英特尔决定添加一个特殊版本0xCC
而没有额外的字节 - 因为操作码必须只有一个字节才能作为未使用内存的可靠'fill byte' .这里的要点是,如果处理器错误地跳转到不包含任何预期指令的内存,则允许正常恢复 . 多字节指令不适用于此目的,因为错误的跳转可能落在任何可能的字节偏移处,在那里它必须继续正确形成的指令流 .
显然,单字节操作码对此非常简单,但也可能存在奇怪的例外:例如,考虑到填充序列
0xCDCDCDCD
(本页也提到过),我们可以看到它相当可靠,因为无论instruction pointer落在哪里(除了最后填充的字节之外,CPU可以继续执行有效的 two-byte x86指令CD CD
,在这种情况下用于生成软件中断205(0xCD) .Weirder仍然,而
CD CC CD CC
是100%可解释的 - 给出INT 3
或INT 204
- 序列CC CD CC CD
不太可靠,只有75%如图所示,但通常99.99%重复作为int大小的内存填充 .Macro Assembler Reference,1987