What is a code cave, and is there any legitimate use for one?

Eddie picture Eddie · Apr 24, 2009 · Viewed 14.6k times · Source

I encountered this word for the first time in the StackOverflow question "C# Theoretical: Write a JMP to a codecave in asm." I see that according to Wiktionary, a code cave is:

an unused block of memory that someone, typically a software cracker, can use to inject custom programming code to modify the behavior of a program.

Did I find the correct definition? If so, is there any legitimate use for a code cave?

Answer

chaos picture chaos · Apr 24, 2009

One might wish to intentionally create a code cave as a part of using self-modifying code.

Assuming, of course, that one is insane.