All method names and fields in DLL are not obfuscated

javiersanagjaviersanag Posts: 5
edited October 19, 2012 11:32AM in SmartAssembly
Hi!

I'm trying to obfuscate a DLL that contains some WPF and some public methods. On these classes, all method names and signatures remain intact, even when they are internal or private. Also, all fields keep their original name. I have set all options to maximum obfuscation.

I have also tried this solution: http://stackoverflow.com/questions/6863 ... bfuscation with the "ExcludePublicMembers="0"" parameter.

Nothing has worked so far. Any way I can force field name mangling on private and internal methods and fields?

PS: I'm using ILSpy to disassemble the DLL.

Comments

  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    It looks like something changed in the latest version of SmartAssembly that makes that workaround

    <Obfuscation ExcludePublicMembers="0" Obfuscate="1">

    invalid, I'm afraid. I've opened a bug for this with reference SA-1389 .


    In the meantime, you could downgrade to version 6.6 which I've found still works: http://downloads.red-gate.com/checkforu ... 6.4.95.exe

    Sorry for this inconvenience!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • Thanks for the reply. Unfortunately, I get the same behavior with version 6.6, even after specifying "ExcludePublicMembers = 0".

    All my DLLs are merged into the main assembly, so I don't understand why they are not obfuscated in the expected way. It is especially worrying that the internal and private members keep their original names. Even the main .exe file has most private and internal members unchanged after obfuscation (this I don't understand why).

    I hope something like this can be solved in the next version of SmartAssembly.
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Yes, that is strange. SmartAssembly does purposely skip obfuscation of certain types though -- are those objects that aren't getting obfuscated any of the following?

    · Any type with the Serializable attribute specified will not be obfuscated
    · Any type with a base class of System.MulticastDelegate will not be obfuscated
    · Any type with the System.ServiceModel.OperationContractAttribute specified will not be obfuscated
    · Any type with the System.ServiceModel.ServiceContractAttribute specified will not be obfuscated
    · Any method with the System.Reflection.DefaultMemberAttribute specified will not be obfuscated
    · Any type with an attribute starting with System.Xml.Serialization. set will not be obfuscated

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • Yes, that is strange. SmartAssembly does purposely skip obfuscation of certain types though -- are those objects that aren't getting obfuscated any of the following?

    · Any type with the Serializable attribute specified will not be obfuscated
    · Any type with a base class of System.MulticastDelegate will not be obfuscated
    · Any type with the System.ServiceModel.OperationContractAttribute specified will not be obfuscated
    · Any type with the System.ServiceModel.ServiceContractAttribute specified will not be obfuscated
    · Any method with the System.Reflection.DefaultMemberAttribute specified will not be obfuscated
    · Any type with an attribute starting with System.Xml.Serialization. set will not be obfuscated

    We're not dealing with any of those types. I have activated the logging functionality, and I get many of these messages:

    class [PresentationFramework]System.Windows.Controls.Grid GridClose excluded from obfuscation: Has a special base type ([PresentationFramework]System.Windows.Window)

    Is WPF not supported?
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Oh, I see--SmartAssembly does support WPF, but it will automatically skip obfuscation of some objects in a WPF assembly, I'm afraid. :( It does this to make sure that the obfuscated version of your application will still work with your xaml file. Are all the objects getting skipped related to WPF?

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • Most of the classes that are not obfuscated derive from Window or from UserControl, so they are indeed related to WPF. In these classes none of the method names or field names are modified after obfuscation, and for instance, a simple private boolean keeps the name. Is this the expected behavior?

    It seems that SmartAssembly has important limitations with WPF (maybe Microsoft's fault). Behavior like the one described above means that we need to move most of the logic to other non-WPF classes, but in many cases this is either not possible or it complicates code in an unnecessary way...
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi Javier,

    I've come across a comment that the developers have made in regards to exclusions. Apparently, exclusions can vary depending on a whole host of factors such as the type of assemblies being processed, which combination of other features may be enabled, the CLR version being targetted and more. I apologize for any inconvenience this may cause!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi Javier!

    So, it turns out that the actual problem here is that I was having a moment of stupidity..:oops:

    In version 6.7, the attribute is now KeepPublicMembersAccessible rather than ExcludePublicMembers

    My deepest apologies for the confusion!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


Sign In or Register to comment.