简体   繁体   English

在C#沙箱中运行非托管EXE

[英]Running unmanaged EXE in C# sandbox

I have a third-party unmanaged program as a part of my application. 我有一个第三方非托管程序作为我的应用程序的一部分。 I have a managed C# application as well which is an "entry point" for the system. 我有一个托管的C#应用​​程序,它是系统的“入口点”。 It ensures that the unmanaged program can only be run properly if certain conditions are met. 它确保只有满足某些条件才能正常运行非托管程序。

I'd like to have the C# application run the unmanaged program in a sandbox so that a particular file isn't directly read from or written to the hard drive; 我想让C#应用程序在沙盒中运行非托管程序,以便不直接从硬盘驱动器读取或写入特定文件; instead the C# app needs to process it and then feed the file to the 3rd-party application or save it to the disk. 相反,C#应用程序需要处理它,然后将文件提供给第三方应用程序或将其保存到磁盘。

I've looked into using the AppDomain class of C# but I believe only managed code can be run by it. 我已经研究过使用C#的AppDomain类,但我相信只有托管代码可以由它运行。 Is there an alternative system for what I'm trying to accomplish? 对于我想要完成的事情,是否有替代系统?

Pretty sure you can't really run an unmanaged program in a C# sandbox, save for writing an unmanaged emulator in C# and running the unmanaged executable in that. 非常确定你无法真正在C#沙箱中运行非托管程序,除了在C#中编写非托管仿真器并在其中运行非托管可执行文件。 And it'd be slow to run and hard to write so you probably don't want to go that route. 而且运行起来很慢而且很难写,所以你可能不想走那条路。

The only way I could see this working would be if the unmanaged program called a C# wrapper for the file system. 我能看到这个工作的唯一方法是,如果非托管程序称为文件系统的C#包装器。 Do you have the source code for the unmanaged program? 你有非托管程序的源代码吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM