Smokescreen directives file

Smokescreen home
Revision history
User guide
Installation guide
Obfuscation notes
Directives file
Incremental obfuscation
Buildtool integration
Watermarking
License and download
Purchase
Faqs/Known issues
Email
Obfuscation settings can be specified through the GUI, or through directives. These directives can be present in a directives file, as options in the command line, or in an array of Strings when using the api methods. When using a directives file with the GUI, the 'Use Directives File' checkbox in the 'File' menu must be checked and the 'Directives File' field should specify the filename of the directives file. The menu and field settings in the GUI will be ignored and all obfuscation parameters will be taken from the directives file. Each directive in the file should be entered on a separate line.
When using a directives file from the command line, the '-directives' option should be used to specify the filename of the directives file. If the directives are specified individually as part of the command line then each directive must start with a '-' character. If the directives are specified in a String array then each string must specify a complete directive.
All directive information, except for identifier names is case insensitive. When using a directives file, all obfuscation parameters including directory paths are expected to be specified in the directives file. The different types of directives that may be used in the directives file are described below.


General directives

These directives are used to specify directory information such as source, destination and superclass paths. They are also used to control the access level for obfuscation of classes, fields and methods, the removal of fields and methods, and the control of bytecode obfuscation. Essentially the general directives are used to replace the checkboxes and fields used in the GUI. Prior to rev 3.6 each line that specifies a general directive must start with a '*' character and a space, this is not required for rev 3.6 and later.

Specifying source, destination and superclass paths
The directive types that are used to specify directory information are 'source_directory', 'destination_directory' which may be used only once in the directives file, and 'superclass_path' which may be used more than once in the directives file. Some examples are
source_directory c:\my source directory
destination_directory c:\my destination directory
superclass_path c:\jdk1.3.0_02\jre\lib\rt.jar
The directive type for specifying that superclasses may be found in the search path for loading classes is 'use_class_loader_for_superclasses'. This means that the locations for superclasses can be specified through the classpath. If this directive is used, then the paths specified using the 'superclass_path' directive will be ignored. An example is
use_class_loader_for_superclasses

Incremental obfuscation
The directive type for specifying that an input change record file must be used is 'use_change_record'. The renaming of classes, methods and fields will be done such that it is consistent with the change record. Any symbolic names that are not specified in the change record file will be renamed by Smokescreen as per usual. Only the mapping of old to new names in the change record file are used. The obfuscation settings in the change record file are ignored, and these must still be specified in the directives file. An example is
use_change_record c:\changelog.txt

Logging name changes
The directive type used to indicate if name changes are to be logged in the log file is 'log_changes' (no parameters). An example is
log_changes

Ignoring the native modifier
The directive type used to indicate if the 'native' keyword modifier for methods is to be ignored is 'ignore_native' (no parameters). Normally methods declared with the native modifier are excluded from renaming. Using this directive will allow these methods to be renamed if possible. An example is
ignore_native
Preserving a class completely
The directive type used to indicate that a class should not be changed at all is 'preserve_class'. The class that is specified will be copied unchanged from the source to destination. An example is
preserve_class MyPackage.MyClass
Overwriting class files
The directive type used to indicate if classfiles may be overwritten is 'overwrite_classfiles' (no parameters). An example is
overwrite_classfiles
Writing watermarks
The directive types that are used for writing a watermark to the obfuscated files are 'watermark_string' and 'watermark_password'. The 'watermark_string' directive is followed by the actual watermark text. The 'watermark_password' directive is followed by a password which is used to encrypt the watermark. Some examples are
watermark_string This is the watermark text
watermark_password myPassword
Reading watermarks
The directive types that are used for reading the watermarks from obfuscated files are 'read_watermark' and 'watermark_password'. The 'watermark_password' directive should be followed by the same password that was used when write the watermarks. Some examples are
watermark_password myPassword
read_watermarks
Renaming based on access level, and removing unused
The directive types that specify the obfuscation level for symbolic names and the bytecode are 'classes', 'methods', 'fields', 'bytecode'. Each directive type which specifies obfuscation based on access level, for classes, methods or fields may only be specified once in a directives file. However more than one bytecode directive may be present in the directives file.

The allowable settings for 'classes' are 'no_obfuscation', all_non-public', 'all_classes', 'remove_unused', 'rename_packages'. An example of a 'classes' directive is
classes all_classes
This indicates that all class names should be considered for obfuscation.

The allowable settings for 'methods' are 'no_obfuscation', 'all_private', 'all_non-protected/non-public', 'all_non-public', 'all_methods', 'remove_unused'. An example of a 'methods' directive is
methods all_private
This indicates that only private methods should be considered for obfuscation.

The allowable settings for 'fields' are 'no_obfuscation', 'all_private', 'all_non-protected/non-public', 'all_non-public', 'all_fields', 'remove_unused'. An example of a 'fields' directive is
fields all_non-public
This indicates that only non-public fields should be considered for obfuscation.

Unused classes methods or fields can be specified for removal by using the 'remove_unused' directive in each case. An example of a 'fields' directive to remove unused fields is
fields remove_unused
This indicates that unused fields should be considered for removal.

Bytecode obfuscation
The allowable settings for 'bytecode' are 'shuffle_stack_operations', 'add_fake_exceptions', 'change_switch_statements', 'encrypt_strings'. An example of a 'bytecode' directive is
bytecode add_fake_exceptions
This indicates that fake exceptions should be added to the bytecode of the class methods.

Name exclusion directives

These directives are used to exclude a specific class, method or field name from obfuscation. The name which is to be excluded is case sensitive. The directive types that may be used are 'class', 'method', 'field' and 'all_names_in_class'. The 'all_names_in_class' directive is used for excluding the class name, all method names and all field names in a particular class. When using the 'method' or 'field' directive, if the method or field name is not fully qualified with a class name, then all methods or fields with that name will be excluded from the renaming process. If the classname is included then only that specific method or field will be excluded from name obfuscation. Both the 'forward slash' and 'dot' can be used as a package separator when specifying class names. Prior to rev 3.6 each line that specifies an exclusion directive must start with a '-' character and a space, this is not required for rev 3.6 and later.
The '*' or '#' character ('#' is preferred) can be used as a wildcard character in place of an actual class, method or field name to match any class, method or field. Below rev 3.6 only the '*' may be used as a wildcard character.
When using the 'class' or 'all_names_in_class' directive, the package name must be included. If a wildcard character is used for the class name, and a package name is specified, it will match all classes in that package. To specify the default package start the class name with a dot or slash (eg "/myclass" specifies a class in the default package).
When using the 'method' or 'field' directives, a class name must be specified if the wildcard character is being used to match all the method or field names.
Some examples of these directives are:
all_names_in_class MyPackage/MyClassName
all_names_in_class /#
all_names_in_class MyPackage/#
class MyPackage/MyClassName
class /#
class MyPackage/#
method MyMethodName
method MyClassName.#
field MyFieldName
field MyClassName.#
method SpecificClass.SpecificMethod
field SpecificClass.SpecificField
class MyPackage.MyClassName
method MyPackage.SpecificClass.SpecificMethod
field MyPackage.SpecificClass.SpecificField
Comments

A comment line can only appear in the directives file, and is one that starts with the '/' character. All such lines will be ignored when the directives file is processed. An example comment is
/ This is a comment line.
Specifying multiple parameters with directives

In the case of directives that take additional parameters, more than one parameter may be specified using a comma as a delimiter. Some examples are
methods all_methods, remove_unused

bytecode add_fake_exceptions, change_switch_statements, encrypt_strings

method thisMethod, thatMethod
Directives listing
All available directive types and settings are listed below
source_directory c:\my source directory
destination_directory c:\my destination directory
superclass_path c:\my superclasses
use_class_loader_for_superclasses
overwrite_classfiles
preserve_class MyPackage.MyClass
log_changes
ignore_native
use_change_record c:\changelog.txt
watermark_string The text that is to be inserted as a watermark
watermark_password thePassword
read_watermark

classes no_obfuscation
classes all_non-public
classes all_classes
classes remove_unused
classes rename_packages

methods no_obfuscation
methods all_private
methods all_non-protected/non-public
methods all_non-public
methods all_methods
methods remove_unused

fields no_obfuscation
fields all_private
fields all_non-protected/non-public
fields all_non-public
fields all_fields
fields remove_unused

bytecode shuffle_stack_operations
bytecode add_fake_exceptions
bytecode change_switch_statements
bytecode encrypt_strings

preserve_class MyPackage.MyClass
all_names_in_class MyClass
all_names_in_class SomePackage/SomeClass
all_names_in_class SomePackage/#
class MyClass
class SomePackage/SomeClass
class SomePackage/#
method MyMethod
method SomeClass.SomeMethod
method SomePackage/SomeClass.SomeMethod
method SomePackage/SomeClass.#
field MyField
field SomeClass.SomeField
field SomePackage/SomeClass.SomeField
field SomePackage/SomeClass.#