Definition
What is invalid code?
Invalid code is an obfuscation technique that exploits the gap between what a runtime accepts and what a decompiler expects. It inserts sequences the .NET runtime executes without issue but that decompilers cannot interpret.
Decompilers rebuild readable source from compiled code by assuming the code follows the patterns a normal compiler produces. Invalid code breaks that assumption.
The application behaves exactly as intended, because the runtime handles the sequences correctly. The decompiler, expecting compiler-shaped code, fails: it crashes, skips methods, or produces output that does not compile.
