Check Attributes
When processing an input assembly, Dotfuscator recognizes a number of attributes that dictate how it should inject Checks into the assembly. By using these attributes on your source code, you can configure Dotfuscator's Checks inline with your application code. This page details these attributes.
Note that you can also configure Checks using the Dotfuscator user interface. For information on when you might want to configure via the user interface and when you might want to use attributes, see the When to Use Attributes section of the Attributes Overview page.
Important: Injection in general is controlled by the Enable injection global option. If this option is disabled, no code will be injected despite any attributes.
Referencing the Attributes
Dotfuscator ships with a reference assembly that defines the Check Attributes.
The assembly is named PreEmptive.Attributes.dll
and is located in the same directory where Dotfuscator is installed.
The easiest way to find the path to this assembly is to:
Open a Dotfuscator command prompt.
Run the command
where PreEmptive.Attributes.dll
and copy the result.
You can then add a reference to this assembly to your project. Note that the assembly has no dependencies besides the framework itself, so it can be copied to a different location if desired.
Attribute Listing
This section lists the attributes that Dotfuscator recognizes to configure its Check injection.
Properties that are only recognized by Dotfuscator Professional are omitted.
TamperCheckAttribute
Instructs Dotfuscator to inject a Tamper Check with the annotated method as its sole location.
In prior versions of Dotfuscator, this attribute was known as InsertTamperCheckAttribute
.
That attribute is now deprecated; we recommend using TamperCheckAttribute
.
Namespace: PreEmptive.Attributes
Applies to: Method
Multiple allowed on one code element: No
Requirements:
For Dotfuscator to recognize uses of this attribute and inject a Tamper Check, all of the following must be true:
The Enable injection global option must be enabled; and,
The Honor injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
For the injected Tamper Check to send telemetry, all of the following must be true:
When Dotfuscator builds the config, the Send tamper check messages global option must be enabled; and,
At runtime, when the Check runs, instrumentation must be set up (via a call to some other method annotated with
SetupAttribute
).
For Dotfuscator to remove uses of this attribute from the protected assembly, the Strip injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
Properties:
Action: The Check Action the Check will take if it detects a tampered application.
- Defaults to None.
ApplicationNotificationSinkElement: Specifies the kind of code element that the Check will use to inform the application of the Check's result. This code element is known as an Application Notification Sink.
Defaults to None, which means the application is not notified of the Check's result.
If Method, MethodArgument, or Delegate, the Check calls a method, delegate method argument, or delegate field with the signature
void(bool)
.If Field or Property, the Check sets a
bool
field or property.DefaultAction is deprecated. Please set Action to Exit for the same behavior.
ApplicationNotificationSinkName: Specifies the name of the Application notification sink.
- Required unless ApplicationNotificationSinkElement is None or DefaultAction.
ApplicationNotificationSinkOwner: Specifies the name of the type that declares the Application notification sink.
- Defaults to the type that defines the annotated method.
DebuggingCheckAttribute
Instructs Dotfuscator to inject a Debugging Check with the annotated method as its sole location.
Namespace: PreEmptive.Attributes
Applies to: Method
Multiple allowed on one code element: No
Requirements:
For Dotfuscator to recognize uses of this attribute and inject a Debugging Check, all of the following must be true:
The Enable injection global option must be enabled; and,
The Honor injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
For the injected Debugging Check to send telemetry, all of the following must be true:
When Dotfuscator builds the config, the Send debug check messages global option must be enabled; and,
At runtime, when the Check runs, instrumentation must be set up (via a call to some other method annotated with
SetupAttribute
).
For Dotfuscator to remove uses of this attribute from the protected assembly, the Strip injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
Properties:
Action: The Check Action the Check will take if it detects a debugger attached to the application.
- Defaults to None.
ApplicationNotificationSinkElement: Specifies the kind of code element that the Check will use to inform the application of the Check's result. This code element is known as an Application Notification Sink.
Defaults to None, which means the application is not notified of the Check's result.
If Method, MethodArgument, or Delegate, the Check calls a method, delegate method argument, or delegate field with the signature
void(bool)
.If Field or Property, the Check sets a
bool
field or property.DefaultAction is not supported. Dotfuscator will error if this setting is used.
ApplicationNotificationSinkName: Specifies the name of the Application Notification Sink.
- Required unless ApplicationNotificationSinkElement is None or DefaultAction.
ApplicationNotificationSinkOwner: Specifies the name of the type that declares the Application Notification Sink.
- Defaults to the type that defines the annotated method.
ShelfLifeCheckAttribute
Instructs Dotfuscator to inject a Shelf Life Check with the annotated method as its sole location.
A Shelf Life Activation Key is required to use this attribute.
In prior versions of Dotfuscator, this attribute was known as InsertShelfLifeAttribute
.
That attribute is now deprecated; we recommend using ShelfLifeCheckAttribute
.
Namespace: PreEmptive.Attributes
Applies to: Method
Multiple allowed on one code element: No
Requirements:
For Dotfuscator to recognize uses of this attribute and inject a Shelf Life Check, all of the following must be true:
The Enable injection global option must be enabled; and,
The Honor injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default; and,
The attribute's ActivationKeyFile property must refer to a valid Shelf Life Activation Key; and,
The attribute's ExpirationDate property must be set.
For the injected Shelf Life Check to send telemetry, all of the following must be true:
When Dotfuscator builds the config, the Send shelf life notification messages global option must be enabled; and,
At runtime, when the Check runs, instrumentation must be set up (via a call to some other method annotated with
SetupAttribute
).
For Dotfuscator to remove uses of this attribute from the protected assembly, the Strip injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
Properties:
ActivationKeyFile: The path to a valid Shelf Life Activation Key file at build time.
Always required.
The file is not needed after Dotfuscator processes the assembly.
ExpirationDate: The expiration date of the application, expressed either as an absolute date (
YYYY-MM-DD
) or as the number of days beyond the date of Dotfuscator's processing.- Always required.
ExpirationNotificationSinkElement: Controls Shelf Life exit behavior.
Defaults to None, which means the application continues after the Shelf Life Check, even if it has expired.
If DefaultAction, the application will exit if the Shelf Life Check detects the application has expired.
All other settings are only supported in Dotfuscator Professional.
RootCheckAttribute
Instructs Dotfuscator to inject a Root Check with the annotated method as its sole location.
Namespace: PreEmptive.Attributes
Applies to: Method
Multiple allowed on one code element: No
Requirements:
For Dotfuscator to recognize uses of this attribute and inject a Root Check, all of the following must be true:
The Enable injection global option must be enabled; and,
The Honor injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
For Dotfuscator to remove uses of this attribute from the protected assembly, the Strip injection attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
Properties:
Action: The Check Action the Check will take if it detects the application is running on a rooted Android device.
- Defaults to None.
ApplicationNotificationSinkElement: Specifies the kind of code element that the Check will use to inform the application of the Check's result. This code element is known as an Application Notification Sink.
Defaults to None, which means the application is not notified of the Check's result.
If Method, MethodArgument, or Delegate, the Check calls a method, delegate method argument, or delegate field with the signature
void(bool)
.If Field or Property, the Check sets a
bool
field or property.DefaultAction is not supported. Dotfuscator will error if this setting is used.
ApplicationNotificationSinkName: Specifies the name of the Application Notification Sink.
- Required unless ApplicationNotificationSinkElement is None or DefaultAction.
ApplicationNotificationSinkOwner: Specifies the name of the type that declares the Application Notification Sink.
- Defaults to the type that defines the annotated method.