如何通过c#从一个应用程序启动一个新进程(不是process.start) [英] how to start a new process from one application by c#(not process.start)

查看:596
本文介绍了如何通过c#从一个应用程序启动一个新进程(不是process.start)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的应用程序appB加载并启动第三方应用程序(c#)appA。我不想使用process.start(),因为我应该像这样启动appA:启动我的appB --- - >读取appA文件为字节arrBytes

---->更改arrByte的一些字节(现在会有一个新的应用程序new_appB)--->然后运行它(new_appB)通过.net反射技术如下:

汇编myAssembly = Assembly.Load(arrByte); 
_MethodInfo info = myAssembly.EntryPoint;
new 主题(()= > info.Invoke( null null ))。Start();



但是问题是new_appB将是appA的子线程,如果我退出appA,new_appB也将结束。



实际上appB是一个特殊文件,已加密且无法直接运行。所以我需要动态解密它。我不想将new_appB保存到HDD。谢谢!



无论如何从内存中启动new_appB作为新进程?我还希望在new_appB运行时appA自动退出



不将new_appB保存到本地hdd或使用process.start()

希望你能发牢骚我,非常感谢你!

解决方案

没有。没有其他办法,除了通过P / Invoke调用Windows API的 CreateProcess ,这会给你相同的结果。



我确定你想要的东西根本就没有意义。您只需要了解过程的本质。您是否知道每个进程都在隔离的地址空间中执行;并且硬件支持隔离地址空间?这对于理解这个问题非常重要。



-SA


除了正如谢尔盖在他的解决方案中指出的那样,你不能做你所描述的事实:



让应用程序直接修改另一个应用程序的字节是不好的策略;而且,我认为它可能触发可疑事件检测恶意软件/病毒防护软件。



但是,启动另一个应用程序,你从你的应用程序传入参数将改变其他应用程序的状态/行为是一个合理的策略。



C#论坛上的这个新主题可能会给你一些想法:[ ^ ] ...查看该主题第一篇文章中链接的CP文章。

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 :

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!

解决方案

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


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.


这篇关于如何通过c#从一个应用程序启动一个新进程(不是process.start)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆