简体   繁体   English

从数据库/网络服务器流二进制文件? C#

[英]Stream Binary File from Database / webserver? C#

I've started to work on my runPE just to get a little more familiar with C# and how a runPE work. 我开始研究runPE只是为了更加熟悉C#和runPE的工作原理。 Just for learning purposes. 仅用于学习目的。 And this is how I do it. 这就是我的方法。

private static void Inject(string injectTo, string binToInject)
{
    int num = 0;
    RunPe.Run(Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), /*injectTo*/"ilasm.exe"),"", File.ReadAllBytes(binToInject), 4, ref num);
}

How ever, right now the bin(.exe) file I 'inject' located on my machine, what I would like to do is to stream this bin from DataBase or a server so it would not need to be on my machine. 但是,现在,我“注入”到我的计算机上的bin(.exe)文件,我想做的是从数据库或服务器流式传输此bin,因此它不需要在我的计算机上。 Is that possible? 那可能吗?

Presumably this is the only interaction you have with the file?: 大概这是您与文件的唯一交互?:

File.ReadAllBytes(binToInject)

All that does is return a byte[] array representing the contents of the file. 所要做的只是返回一个代表文件内容的byte[]数组。 So anything which returns the same thing would work as a drop-in functional replacement. 因此,返回相同内容的任何东西都可以用作嵌入式功能替换。

Any data access technology (plain ADO.NET, Entity Framework, etc.) would generally treat a BLOB column (which would contain a file) as a byte[] , or at least something easily converted to that. 任何数据访问技术(普通的ADO.NET,实体框架等)通常都将BLOB列(其中将包含一个文件)视为byte[] ,或者至少将其容易地转换为该byte[] So in general, yes, you can serve your file from any source. 因此,通常,可以,您可以从任何来源提供文件。

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

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