简体   繁体   中英

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. 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. 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. 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. So in general, yes, you can serve your file from any source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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