SmartAssembly 6

Obfuscating code with name mangling

About name mangling

Name mangling changes the name of your classes and methods to unreadable characters, making your code harder to understand. SmartAssembly automatically detects non-obfuscatable code or metadata.

Using name mangling

Name mangling makes your code harder to understand by changing the names of types, methods and fields. 

To use name mangling, in the Project Settings window, go to Obfuscation or click the icon in the toolbar.

Select the assemblies that you want to obfuscate.

If you experience problems with name mangling, see Troubleshooting name mangling.

SmartAssembly doesn't obfuscate public members of DLL files, because the DLL would be unusable.

 

Types/methods name mangling options

ASCII characters

Renames types and methods using ASCII characters. For example, the type FullScreenSplash is obfuscated to #dc.

Unicode unprintable characters

Renames types and methods using Unicode unprintable characters. For example, the type FullScreenSplash is obfuscated to U+1D11E (which is unprintable).

Unicode unprintable characters and advanced renaming algorithm

Renames types and methods using Unicode unprintable characters and renames multiple items with the same name. For example, the types FullScreenSplash and FontStyle are both obfuscated to U+017D.

When you obfuscate an assembly using ASCII characters name mangling, SmartAssembly doesn't reuse the obfuscated type and method names between different assemblies. This allows you to decode a stack trace, even if the stack-trace covers several obfuscated assemblies.

Fields name mangling options

One-to-one renaming scheme

Changes all fields in all classes so that they have different names. A field's name is unique within an assembly.

Obfuscated in the same style as the selected Types/methods name mangling.

Standard renaming

Alters the field name so that is unique within a class, however the same name is often used within other classes in the assembly. For example, #a: string, #b: boolean, #c: string, #d: boolean.

Obfuscated in the same style as the selected Types/methods name mangling.

Advanced renaming

Alters the field name, however it not unique within a class and is reused. Fields of a different type will have the same name. For example, #a: string, #a: boolean, #b: string, #b: boolean.

Obfuscated in the same style as the selected Types/methods name mangling.

When name mangling is enabled, the colored bars under the toolbar icon and to the left of the feature options are green. If it is disabled, the bars are orange.

If you have methods in different classes that have the same method name, you may have to use Advanced renaming to obfuscate those method names.

 

Method parent obfuscation (Professional and Developer editions only)

Method parent obfuscation moves methods to other types in the assembly, making it hard to discover which classes they are part of.

Please note that method parent obfuscation may not work with some types of assembly.

Name mangling example:

The following example shows code before and after name mangling:

Before:

public ClientLicence GetLicence(ItemType type);
public bool IsFileInProject(string fileName);
public void ResolveAssemblyReferences();
public void Save();
private void SetMemento(Properties memento);
public void Start(bool withDebugging);
private void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink);

After:

It isn't possible to display unprintable characters. For the purpose of this example, unprintable characters are represented by an asterisk (*).

public ‑.‑ *(‑.‑);
public bool *(string);
public void *();
public void *();
private void *(‑.‑);
public void *(bool);
private void *(‑.‑,‑.‑);

 

 

 


Didn't find what you were looking for?