Red Gate forums :: View topic - Preemptive mapn.xml
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 5
SmartAssembly 5 forum

Preemptive mapn.xml

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
Ben1628



Joined: 01 Jul 2010
Posts: 9

PostPosted: Sun Jul 04, 2010 5:37 am    Post subject: Preemptive mapn.xml Reply with quote

Is there something in smartassembly that is similiar to preemptive mapn.xml.

I think that will help one to identify the new name of the method that one is interested in, in case one needs to do further processing to that method after obfuscation, or making sure the the method is obfuscated to their satifisfaction using reflector.
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Mon Jul 05, 2010 2:00 pm    Post subject: Reply with quote

Unfortunately, we don't currently produce a human readable map file (it is in our requests tracker as SA-91).


If you do need to do post processing on the assembly where you need to know the obfuscated name you can use the "[ObfuscateTo( string )]" attribute, although I'll admit it is not the most friendly method.
Back to top
View user's profile Send private message
Ben1628



Joined: 01 Jul 2010
Posts: 9

PostPosted: Mon Jul 05, 2010 2:50 pm    Post subject: Reply with quote

Thanks.

I don't see any doc on "[ObfuscateTo( string )]".

Is this how we do it?

[ObfuscateTo(human)]
void anymethod()
{}

Do we need to enclose human with ""
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Mon Jul 05, 2010 4:11 pm    Post subject: Reply with quote

Yes it is
Code:

[ObfuscateTo("human")]
void anymethod()
{}


The string is a standard .NET System.String so it is enclosed in "", and you can do anything you can do with a string constant (e.g. "\u0001Hello" )


The other attribute which you would probably want to use alongside [ObfuscateTo(..)] is [ObfsucateNamespaceTo( string )] this, unsurprisingly, specifies the name to obfuscate the namespace of the type to.
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Mon Jul 05, 2010 4:12 pm    Post subject: Reply with quote

If you (or anyone else reading this forum) want it:
There is a full list of all the 15 attributes you can apply in the SmartAssembly.Attributes.cs or SmartAssembly.Attributes.vb which are in the "Attributes" folder where you installed SmartAssembly ("C:\Program Files\Red Gate\SmartAssembly 5\Attributes" by default).

  • DoNotObfuscateAttribute - Don't rename the element (class, method, field, etc)
  • DoNotObfuscateTypeAttribute - Don't rename the type or any element within it (method, field, nested class, etc)
  • ObfuscateToAttribute( string ) - Obfuscate the element to the name you specify
  • ObfuscateNamespaceToAttribute( string ) - Obfuscate the namespace of the type to the name you specify
  • DoNotPruneAttribute - Don't prune the element
  • DoNotPruneTypeAttribute - Don't prune the type or any element within it.
  • DoNotObfuscateControlFlowAttribute - Don't change the IL code within a method
  • ObfuscateControlFlowAttribute - In the project setting page you can specify two different levels of control flow obfuscation. Methods with this attribute will have control flow obfuscation applied at the level you specify for "flagged" methods, other methods will have the standard level applied, unless they have [DoNotObfuscateControlFlow] applied.
  • DoNotCaptureVariablesAttribute - Don't capture variable information for the Automatic Error reporting from this method
  • DoNotCaptureFieldsAttribute - Don't capture field information for the Automatic Error reporting from this type
  • DoNotSealTypeAttribute - Don't seal this class
  • ReportExceptionAttribute - Effectively adds a try/catch/ReportException block to the method. This means that you only get the part of the stack trace between the error and this method in the Error Report. Benefit is that the stack is not fully unwound so that you can continue with the control flow in the calling method.
  • DoNotEncodeStringsAttribute - Don't encode the strings in the element this is applied to.
  • EncodeStringsAttribute - Do encode the strings in the element this is applied to.
  • ExcludeFromMemberRefsProxyAttribute - Don't use Member Reference Proxy for this element.
Back to top
View user's profile Send private message
Ben1628



Joined: 01 Jul 2010
Posts: 9

PostPosted: Tue Jul 06, 2010 7:17 pm    Post subject: Reply with quote

[ObfuscateTo("human")]

Doesn't seem to do anything. I use Reflector to reverse engineer the exe, and there is no method with human.

btw,

apply ObfsucateNamespaceTo( string )]

namespace whatever

generate compile error
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Tue Jul 06, 2010 7:56 pm    Post subject: Reply with quote

Oh that is an interesting bug. If you are using [ObfuscateTo( string )] on a method then you have to use "Unicode encoding with advanced renaming" for it to work. I've logged the bug as (SA-325) as it should be available on all settings.

[ObfuscateNamespaceTo( string )] needs to be applied to a class, struct, enum or interface, otherwise you will get a compiler error.
Back to top
View user's profile Send private message
Ben1628



Joined: 01 Jul 2010
Posts: 9

PostPosted: Fri Jul 09, 2010 4:14 am    Post subject: Reply with quote

Well, I choose

I want to obfuscate using Unicode unprintable characters and advanced renaming alogorithm

and then on filed Name Mangling (I don't think that make any difference), I choose

I want to use advanced renaming, so that fields of a different type can have the same name

However, I still cannot locate my method.

may be you can just show me an example.
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Fri Jul 09, 2010 6:50 pm    Post subject: Reply with quote

I've sent you a PM.

No the field name managling shouldn't make any different in this case.
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group