Fix for a inheritance problem and some other changes

26 views
Skip to first unread message

webbie

unread,
Jun 19, 2007, 5:06:37 AM6/19/07
to obfuscar

We are using Obfuscator with our quite large project and it work's
very well. (After testing several commercial products with all having
their own special downsides. ;( )

We ran into a major issue with Obfuscator, found a fix and want to
contribute the changes to the project:
When a virtual method of a class is skipped from being renamed, the
overriding or overridden methods in the related classes must also be
excluded from name changes.
When this is not done you typically get a "method has no
implementation" error when running your program.

Here is an example to reproduce the problem. When the method in
Interace1 is filtered from renaming, the obfuscated version of the
program throws an error:

using System;
using System.Collections.Generic;
using System.Text;

namespace test
{
public interface Interface1
{
void Method1();
}

public class Class1 : Interface1
{
public void Method1() { Console.WriteLine("Method1"); }
public void Method2() { Console.WriteLine("Method2"); }
}

class Program
{
static void Main(string[] args)
{
Class1 bla = new Class1();
bla.Method1();
}
}
}

Besides this fix we did some minor changes to help us in our project.
Maybe these are also of interest:
All Skip???? elements in the configuration file now accept simple
wildcards (*,?) or full regular expressions for filtering types and
member names. Regular expressions are identified by a starting ^
character which counts to the regular expression. I don't think, that
there are type or member names including the characters ^,* or ? so
this should give no compatibility issues. The rx attribute gets
somewhat obsolete by this feature of course.

In the mapping file the scope (Assembly) of a type is also put in
brackets instead of the comma separation. This should increase human
readability.

I uploaded the patch for these changes to this group. It was created
from Obfuscar version 1.1.0 (SVN Revision 29). It includes the fix for
the inheritance problem (only Obfuscator.cs) and the other two changes.

Ryan Williams

unread,
Jun 19, 2007, 3:36:06 PM6/19/07
to obfu...@googlegroups.com
Good changes!

I particularly like the changes with the brackets...much better, imo.
The wildcard stuff is good too, I like it (I cut out the extra
substring allocation, though). I ran into some trouble while testing
your fix for the virtual method skipping...it worked when skipping
Interface1.Method1, but not Class1.Method1 (I fixed it by making the
virtual naming / renaming into a real two-pass operation...all virtual
method names now get assigned before renaming occurs, so if a group is
given a name but later needs to get skipped, it can be unnamed).

Committed them in r30.

webbie

unread,
Jun 20, 2007, 8:47:13 AM6/20/07
to obfuscar
Thank you for the quick response and integrating the changes.
It seems that I did not test the changes in the virtual method code
enough. It worked for our project, so I thought it was OK.
The avoided string allocation in the wildcard code is a good
optimization. This method is called quite often.

As the patch is committed to SVN now, I tried to remove it from the
files section. But I did not find a button to do this. Maybe this is
only allowed to the group owner. Otherwise it will have to stay there
forever ;)

Ryan Williams

unread,
Jun 20, 2007, 9:17:18 AM6/20/07
to obfu...@googlegroups.com
It's good to get feedback like that, patches / fixes are good for everyone :)

Also, I dropped the file from the group for you ;)

Reply all
Reply to author
Forward
0 new messages