Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed May 23, 2014
1 parent b518498 commit 5139a47
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 42 deletions.
1 change: 1 addition & 0 deletions Confuser.Core/Confuser.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<Compile Include="Project\InvalidPatternException.cs" />
<Compile Include="Project\PatternParser.cs" />
<Compile Include="Project\Patterns\AndOperator.cs" />
<Compile Include="Project\Patterns\FullNameFunction.cs" />
<Compile Include="Project\Patterns\NotOperator.cs" />
<Compile Include="Project\Patterns\MemberTypeFunction.cs" />
<Compile Include="Project\Patterns\DeclTypeFunction.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Confuser.Core/Marker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected Rules ParseRules(ConfuserProject proj, ProjectModule module, ConfuserC
{
var ret = new Rules();
var parser = new PatternParser();
foreach (var rule in module.Rules.Concat(proj.Rules))
foreach (var rule in proj.Rules.Concat(module.Rules))
{
try
{
Expand Down
1 change: 1 addition & 0 deletions Confuser.Core/Project/PatternParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static PatternParser()
fns.Add(DeclTypeFunction.FnName, () => new DeclTypeFunction());
fns.Add(NamespaceFunction.FnName, () => new NamespaceFunction());
fns.Add(NameFunction.FnName, () => new NameFunction());
fns.Add(FullNameFunction.FnName, () => new FullNameFunction());
fns.Add(MatchFunction.FnName, () => new MatchFunction());
fns.Add(MatchNameFunction.FnName, () => new MatchNameFunction());
fns.Add(MatchTypeNameFunction.FnName, () => new MatchTypeNameFunction());
Expand Down
28 changes: 28 additions & 0 deletions Confuser.Core/Project/Patterns/FullNameFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dnlib.DotNet;

namespace Confuser.Core.Project.Patterns
{
/// <summary>
/// A function that compare the full name of definition.
/// </summary>
public class FullNameFunction : PatternFunction
{
internal const string FnName = "full-name";
/// <inheritdoc/>
public override string Name { get { return FnName; } }

/// <inheritdoc/>
public override int ArgumentCount { get { return 1; } }

/// <inheritdoc/>
public override object Evaluate(IDnlibDef definition)
{
object name = Arguments[0].Evaluate(definition);
return definition.FullName == name.ToString();
}
}
}
31 changes: 14 additions & 17 deletions ProjectFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Indicates whether this rule inherits the settings from the previous rules.
Default to `true`.

`pattern`:
The RegEx pattern used to match the target components of this rule.
The pattern expression used to match the target components of this rule.

`preset`:
The protection preset of the rule.
Expand Down Expand Up @@ -117,28 +117,25 @@ Optional.

Applying rules
--------------
The rules are applied from local to global, from begin to end.
ConfuserEx will keep a list of protections for every components, and applies matching rules in order.
The rules are applied from global rules (in `project` element) to local rules (in `module` element), from begin to end.
ConfuserEx will keep a list of protections for every items, and applies the rules in order.

For each rules, ConfuserEx will do:

1. If the component does not match with the rule's pattern, skip the rule.
2. If the rule does not inherit previous settings (i.e. no `inherit`), clear the current protection list.
3. Fill the protection list with the protections contained in the specified `preset` value of the rule.
1. If the item does not match with the rule's pattern, skip the rule.
2. If the rule does not inherit previous settings (i.e. no `inherit`), clear the marking on the item.
3. Mark the items with the protections contained in the specified `preset` value of the rule.
4. For each protection settings in the rule:
5. If `action` is remove, remove the protection from the list.
6. If `action` is add, add the protection settings to the list.
5. If `action` is remove, remove the protection from the marking.
6. If `action` is add, add the protection settings to marking.

The value of the component that used to match with rules' patterns is basically the full name provided by dnlib.
Here's some examples:
The pattern is a simple function-based expression that evaluated for every items. If it is evaluated to `true`, the item is matched with the pattern.

Type: `Namespace.Type/NestedType`
Method: `System.Void Namespace.Type::Method<!!0,!!1>(System.String,System.Int32)`
Field: `System.String Namespace.Type::Field`
Property: `System.String Namespace.Type::Property`
Indexer: `System.String Namespace.Type::Items(System.Int32)`
Event: `System.EventHandler Namespace.Type::Event`
Here are some example expressions:
`true`: Matches all items.
`name('X')`: Matches all items that has name 'X'.
`member-type('type') and full-name('NS.Type')`: Matches types that have full name 'NS.Type'.

Examples
----------------
ConfuserEx projects that are working for ILSpy and PaintDotNet can be found under `additional` directory as examples.
ConfuserEx projects that work for ILSpy and PaintDotNet can be found under `additional` directory as examples.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ It is the successor of [Confuser](http://confuser.codeplex.com) project.
Features
--------
* Supports .NET Framework 2.0/3.0/3.5/4.0/4.5
* Symbol renaming
* Symbol renaming (Support WPF/BAML)
* Protection against debuggers/profilers
* Protection against memory dumping
* Protection against tampering (method encryption)
* Control flow obfuscation
* Constant/resources encryption
* Reference hiding proxies
* Disable decompilers
* Embedding dependency
* Compressing output
* Extensible plugin API
* Many more are coming!

Expand Down
18 changes: 9 additions & 9 deletions additional/ilspy.crproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<project baseDir="." outputDir="Confused" xmlns="http://confuser.codeplex.com">
<rule preset="none" pattern=".*">
<protection id="rename">
<argument name="mode" value="unicode" />
</protection>
<protection id="anti ildasm" />
<rule preset="none" pattern="true">
<protection id="anti debug" />
<protection id="rename">
<argument name="mode" value="unicode" />
</protection>
<protection id="ref proxy" />
<protection id="anti dump" />
<protection id="anti ildasm" />
<protection id="anti tamper" />
<protection id="constants" />
<protection id="ctrl flow" />
<protection id="invalid metadata" />
<protection id="ref proxy" />
<protection id="rename" />
<protection id="resources" />
</rule>
<module path="ICSharpCode.AvalonEdit.dll" />
<module path="ICSharpCode.Decompiler.dll" />
Expand Down
29 changes: 15 additions & 14 deletions additional/pdn.crproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<project baseDir="." outputDir="Confused" xmlns="http://confuser.codeplex.com">
<rule preset="none" pattern=".*">
<protection id="rename">
<argument name="mode" value="unicode" />
</protection>
<protection id="anti ildasm" />
<rule preset="none" pattern="true">
<protection id="anti debug" />
<protection id="rename">
<argument name="mode" value="unicode" />
</protection>
<protection id="ref proxy" />
<protection id="anti dump" />
<protection id="anti ildasm" />
<protection id="anti tamper" />
<protection id="constants" />
<protection id="ctrl flow" />
<protection id="invalid metadata" />
<protection id="ref proxy" />
<protection id="rename" />
<protection id="resources" />
</rule>
<rule preset="none" pattern="PaintDotNet.Menus\..*Menu(|Item|Base)$">
<rule preset="none" pattern="namespace('PaintDotNet.Menus') and match-name('Menu(|Item|Base)$')">
<protection id="rename" action="remove" />
</rule>
<rule preset="none" pattern="PaintDotNet.Menus\..*Menu::menu.*$">
<rule preset="none" pattern="namespace('PaintDotNet.Menus') and match-type-name('Menu$') and match-name('^menu')">
<protection id="rename" action="remove" />
</rule>
<rule preset="none" pattern="PaintDotNet.Tools\..*Tool(|Base)$">
<rule preset="none" pattern="namespace('PaintDotNet.Tools') and match-name('Tool(|Base)$')">
<protection id="rename" action="remove" />
</rule>
<rule preset="none" pattern="PaintDotNet.IndirectUI\..*PropertyControl.*\(\)$">
<rule preset="none" pattern="namespace('PaintDotNet.IndirectUI') and match-type-name('PropertyControl') and (member-type('method') or member-type('property'))">
<protection id="rename" action="remove" />
</rule>
<module path="PaintDotNet.exe" />
<module path="PaintDotNet.Base.dll" />
<module path="PaintDotNet.Core.dll" />
<module path="PaintDotNet.Data.dll" />
<module path="PaintDotNet.Effects.dll" />
<module path="PaintDotNet.exe" />
<module path="PaintDotNet.Resources.dll" />
<module path="PaintDotNet.SystemLayer.dll" />
</project>

0 comments on commit 5139a47

Please sign in to comment.