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

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

ExecuteAssembly

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
SlushPuppy



Joined: 11 Nov 2011
Posts: 4

PostPosted: Fri Nov 11, 2011 7:10 pm    Post subject: ExecuteAssembly Reply with quote

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.
Back to top
View user's profile Send private message
james.davies



Joined: 19 Apr 2011
Posts: 46

PostPosted: Mon Nov 14, 2011 4:28 pm    Post subject: Reply with quote

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

(http://msdn.microsoft.com/en-us/library/system.reflection.assembly.entrypoint.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
Back to top
View user's profile Send private message
SlushPuppy



Joined: 11 Nov 2011
Posts: 4

PostPosted: Mon Nov 14, 2011 9:36 pm    Post subject: Re: Reply with quote

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

(http://msdn.microsoft.com/en-us/library/system.reflection.assembly.entrypoint.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);
Back to top
View user's profile Send private message
james.davies



Joined: 19 Apr 2011
Posts: 46

PostPosted: Wed Nov 16, 2011 8:31 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
SlushPuppy



Joined: 11 Nov 2011
Posts: 4

PostPosted: Wed Nov 16, 2011 9:45 pm    Post subject: Re: Reply with quote

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.
Back to top
View user's profile Send private message
james.davies



Joined: 19 Apr 2011
Posts: 46

PostPosted: Wed Nov 23, 2011 4:22 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
SlushPuppy



Joined: 11 Nov 2011
Posts: 4

PostPosted: Sun Nov 27, 2011 9:05 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 591

PostPosted: Thu Jan 05, 2012 2:49 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic 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