4.5. Advanced Symbol Renaming Options
4.5.1. Symbol Renaming with Printable Characters
The symbol renaming algorithm uses unprintable Unicode characters by default. But sometimes, it may be beneficial to use printable ASCII characters instead. To do that, follow the instructions below.
Alternatively, you may prefer to use symbol encryption for the very same purpose.
Instructions on enabling printable characters for symbol renaming
Open obfuscatable project inside the IDE
Add new source file to the project and call it
ObfuscationSettings.cs(for C#) or
ObfuscationSettings.vb(for Visual Basic .NET). You may prefer to use another name instead of
ObfuscationSettings.cswith the following content (C#):
[assembly: Obfuscation(Feature = "rename symbol names with printable characters", Exclude = false)]
For Visual Basic .NET, fill
ObfuscationSettings.vbwith the following content:
<Assembly: Obfuscation(Feature:="rename symbol names with printable characters", Exclude:=False)>
Please note that printable characters in symbol names can be controlled at the assembly level only. For example, it is impossible to use printable characters for some specific class or method; it is possible to do this just for a whole assembly.
4.5.2. Type Renaming Patterns
Eazfuscator.NET removes the namespaces of renamed types by default. This can lead to some issues when badly written code tries to get a renamed type's namespace via reflection.
For example, let's see what kind of flawed code can suffer from the absence of namespaces.
Example 4.22. Example code that fails with
NullReferenceException when the given type has no namespace
bool IsSystemDataType(Type type)
if (type != null && type.Namespace.StartsWith("System.Data"))
As you can see in the sample above, the method can fail with
type.Namespace property returns
null, indicating that the given type has no namespace. This issue can be easily fixed if you have access to the source code, but sometimes the flawed code comes from elsewhere.
To workaround possible problems, a custom type renaming pattern can be defined for an assembly, for a type or a group of types. The examples below show the possible definitions.
Example 4.23. Add 'b' namespace to all renamed types in assembly
[assembly: Obfuscation(Feature = "type renaming pattern 'b'.*", Exclude = false)]
Example 4.24. Add 'b' namespace to a class
[Obfuscation(Feature = "type renaming pattern 'b'.*", Exclude = false)]
Example 4.25. Add 'b' namespace to a group of renamed classes. All classes with 'Impl' name ending are affected
[assembly: Obfuscation(Feature = "apply to type *Impl: type renaming pattern 'b'.*", Exclude = false)]
Of course, you are free to choose any namespace in a pattern.