Click here to Skip to main content
15,888,269 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I want to load and launch third party application(c#)appA, from my Application appB. I don't want to use process.start(),because i should launch the appA like this: start my appB---->read the appA file as bytes arrBytes
---->change some bytes of arrByte (now there will be a new application new_appB)--->then run it(new_appB) by .net reflection technology like below :
C#
Assembly myAssembly = Assembly.Load(arrByte);
            _MethodInfo info= myAssembly.EntryPoint;
            new Thread(() => info.Invoke(null, null)).Start();

But the problem is new_appB will be a child thread of appA, and if i exit appA,the new_appB will end too.

actually the appB is a special file which have been encrypted and could not run directly. so I need to decrypt it dynamic. I don't want to save the new_appB to HDD. Thank!

Is there anyway to start new_appB as a new process from memory? I also want appA auto exit while new_appB is running.

Without saving new_appB to local hdd or using process.start()
hope you can hlep me ,thank you very much!
Posted
Updated 22-Oct-14 17:50pm
v5
Comments
Sergey Alexandrovich Kryukov 22-Oct-14 9:57am    
Why? why?!
—SA
Sinisa Hajnal 22-Oct-14 10:05am    
As you said your self, you need to start new process. You cannot without using Process.Start :) And as Sergey says: Why!?
iscreen 22-Oct-14 22:04pm    
actually the appB is a special file which have been encrypted and could not run directly. so I need to decrypt it dynamic. I don't want to save the new_appB to HDD. Thank!

No. There is no other way, except calling CreateProcess of the Windows API through P/Invoke, which would give you the same results.

I'm sure that what you want simply makes no sense. You just need to understand the nature of the process. Did you know that each process is executed in the isolated address space; and the isolation address spaces is supported by hardware? This is the point important for understanding of the issue.

—SA
 
Share this answer
 
In addition to, as Sergey points out in his solution, the fact you can't do what you describe:

Having an Application directly modify the bytes of another Application is bad strategy; and, I think it could trigger suspicious-event detection malware/virus protection software.

However, launching another Application where you pass in parameters from your Application that will change the state/behavior of the other Application is a reasonable strategy.

This new thread on the C# Forum here may give you some ideas: [^] ... check out the CP article linked to in the first post on that thread.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Oct-14 16:16pm    
Sure, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900