ExecuteAssembly

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, melvyn.harbour, dom.smith

ExecuteAssembly

Postby SlushPuppy » Fri Nov 11, 2011 7:10 pm

I am trying to byte load an assembly that has been processed with SmartAssembly and execute it, but I am having a lot of problems.

If I use EntryPoint.Invoke, it load two obfuscated modules and then exits with an exit code 0. I use .net reflector and I can see the entry point is #gB, so I have tried to manually invoke that with similar results.

I have just about given up thinking it is not possible but what bugs me is using AppDomain.ExecuteAssembly() finds the entry point just fine and executes it flawlessly.

The problem, is I can't find a way to get ExecuteAssembly to accept a byte loaded assembly so I can embed this assembly with a licensing wrapper.

If I was to guess, it looks like it is picking the wrong entry point when trying to run, but both AppDomain.ExecuteAssembly and Assembly.EntryPoint are suppose to invoke the entry point, yet one has successfully done so, and the other, not so much.

If anyone has some insight on how I can make this work, I would be eternally grateful.
SlushPuppy
 
Posts: 4
Joined: Fri Nov 11, 2011 7:01 pm

Postby james.davies » Mon Nov 14, 2011 4:28 pm

Execute Assembly probably finds the entry point using
public virtual MethodInfo EntryPoint { get; }

(http://msdn.microsoft.com/en-us/library ... point.aspx)

Your best option is to use that rather than trying to manually lookup the entry point in the obfuscated assembly.
Thanks,
James Davies
Technical Support Engineer
Red Gate Software
james.davies
 
Posts: 46
Joined: Tue Apr 19, 2011 2:39 pm

Re:

Postby SlushPuppy » Mon Nov 14, 2011 9:36 pm

james.davies wrote:Execute Assembly probably finds the entry point using
public virtual MethodInfo EntryPoint { get; }

(http://msdn.microsoft.com/en-us/library ... point.aspx)

Your best option is to use that rather than trying to manually lookup the entry point in the obfuscated assembly.


I was using the below code, which I believe is doing what you suggest.

Assembly a (byte loaded exe that is run through SmartAssembly)

a.EntryPoint.Invoke(null, null);
SlushPuppy
 
Posts: 4
Joined: Fri Nov 11, 2011 7:01 pm

Postby james.davies » Wed Nov 16, 2011 8:31 pm

OK. Using reflection on obfuscated code often causes issues.

Could you add the licensing wrapper to your code and then process with SA? (SA generally works best when it is done last)
Thanks,
James Davies
Technical Support Engineer
Red Gate Software
james.davies
 
Posts: 46
Joined: Tue Apr 19, 2011 2:39 pm

Re:

Postby SlushPuppy » Wed Nov 16, 2011 9:45 pm

james.davies wrote:OK. Using reflection on obfuscated code often causes issues.

Could you add the licensing wrapper to your code and then process with SA? (SA generally works best when it is done last)


Unfortunately no, the output we are given has already been run through SmartAssembly. It seems like Main() is always "#gB" but when I specifically invoke that function using Assembly.Invoke or other methods, it will launch two obfuscated module names (different every execution) but won't actually show the application.
SlushPuppy
 
Posts: 4
Joined: Fri Nov 11, 2011 7:01 pm

Postby james.davies » Wed Nov 23, 2011 4:22 pm

I am not sure why you don't have access to the code until after it has been processed by Smartassembly ? Do you have a Smartassembly license ?

The supported way to use Smartassembly is to apply it last , and not to use reflection on obfuscated code.
Thanks,
James Davies
Technical Support Engineer
Red Gate Software
james.davies
 
Posts: 46
Joined: Tue Apr 19, 2011 2:39 pm

Postby SlushPuppy » Sun Nov 27, 2011 9:05 pm

The problem is it is outputted from a private Rapid Development tool that outputs a .net assembly, and they already pass it through SA6. We tried making our wrapper using .NET (C#) but can't execute the assembly when using byte loaded assembly.

I assume this is the same problem we are having when using commercial licensing tools like ExecKey, Intellilock, and so on. They will wrap the exe, and the licensing wrapper works, but won't spawn off the exe properly.
SlushPuppy
 
Posts: 4
Joined: Fri Nov 11, 2011 7:01 pm

Postby Chris.Allen » Thu Jan 05, 2012 2:49 pm

We need to reproduce this exact problem in-house to know if what you are doing is even supported. Would you be willing to help us create an exact reproduction of your issue? If so, we can set up space for uploads etc.
Chris.Allen
 
Posts: 594
Joined: Thu Mar 12, 2009 4:17 pm


Return to SmartAssembly 6

Who is online

Users browsing this forum: No registered users and 0 guests