Renaming hides what your methods are called. Control-flow obfuscation hides what they do. It is the layer that stops a decompiler from handing an attacker clean, readable logic even after every name is gone.
Why names are not enough
A decompiler like ILSpy reconstructs C# from IL by recognising patterns: this block is
an if, this is a while, this is a switch. Rename
everything and the result still reads as structured code —
if (a.b > c) { d.e(); } tells a reader the shape of your logic
even when the identifiers are meaningless. For algorithms, licence checks and business
rules, the shape is most of the secret.
What control-flow obfuscation changes
It rewrites each method into IL that computes the same result but no longer matches the tidy patterns a decompiler expects. The method still verifies and runs identically; it just no longer decompiles into clean source. Two techniques do most of the work:
- Flattening. The natural nesting of your code — loops inside conditionals inside loops — is broken into a flat set of blocks sitting under one big dispatch loop. A state variable decides which block runs next. The order you wrote is gone; what remains is "run block, update state, repeat", which does not map back to readable structure.
- Opaque predicates. Branches are added whose outcome is always known to the obfuscator but not obvious to an analyser — a condition that is always true for reasons a static tool cannot easily prove. The decompiler has to keep both paths, inflating the output with code that never actually runs, so the reader cannot tell the real path from the decoy.
What the decompiled output looks like
Instead of a readable method, a reader gets a large while-with-switch
driven by a state integer, padded with branches that lead nowhere. The logic is all
present — it has to be, or the program would not work — but recovering the original
structure means tracing the state machine by hand or running a dedicated deobfuscator
and hoping it has a preset for this transformation. That is exactly the cost increase
the technique exists to create.
Cost and when to use it
Flattening and opaque predicates add instructions, so a heavily obfuscated method is larger and a little slower than the original. For ordinary code this is irrelevant — see does obfuscation slow your app down? — but it is a real reason not to blanket-apply it to everything. The useful mindset is to reserve the heavier layers for the methods that actually hold value: licensing, a proprietary algorithm, the logic a competitor would most want to read.
It also compounds well with the other layers. Renaming removes the labels, string encryption removes the readable literals, and control-flow obfuscation removes the readable structure — so a static decompile returns almost nothing a human can skim. For the methods where even that is not enough, method virtualization goes a step further.
Compatibility
Because the transformation preserves behaviour, correct code is unaffected. The edge to be aware of is debugging your own release build: a stack trace or step-through over obfuscated control flow is hard to follow. Keep an unobfuscated build and its PDBs for your own diagnostics, and use the rename map to turn production traces back into your names.
Control-flow obfuscation is a Pro layer and is opt-in per run. The free tier covers renaming; turn this on when the logic, not just the names, is worth protecting.