如何在我的文件中写入运行.exe? [英] How do write running .exe in my file ?

查看:48
本文介绍了如何在我的文件中写入运行.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Exe文件。因为我没有Exe源。我说英语非常糟糕所以我希望你通过绘画说出来;



http://i.imgur.com/Hg4P4Sm.png



I have Exe File. Because I don't Have A Exe Source. I'm Very Bad Speak English so I want you to say by drawing;

http://i.imgur.com/Hg4P4Sm.png

byte[] MyFileAsd = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9 };

  private void button1_Click(object sender, EventArgs e)
  {
      string File = Application.StartupPath + @"\originalExe.exe";

      Process.Start(File);

      //I want to print MyFile.asd to OriginalExe's memory, so MyFile.asd will act like it's on OriginalExe.exe. Thus, OriginalExe.exe will act like it's reading MyFile.asd without any errors, but it'll actually be reading my byte[] MyFileAsd = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9 };

  }



我不是来自美国。因为我需要帮助你不明白我说的是什么吗?


I'm not from the US. because I'm need Help. Do you not understand what I say to ?

推荐答案

我想我会跟随。我会尝试用简单的英语帮助。



现在你有:

  • 一个数据文件(asd)
  • 一个应用程序(originalExe)
I think I follow. I will try to help in simple English.

Now you have:
  • a data file (asd)
  • an application (originalExe)
using System.IO;

byte[] MyFileAsd = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9 };

  private void button1_Click(object sender, EventArgs e)
  {
      // Write data to temporary file.
      string temp = Path.GetTempFileName();
      File.WriteAllBytes(temp, FyFileAsd);
      string exe = Application.StartupPath + @"\originalExe.exe";

      Process.Start(exe, temp);
  }


您没有解释OriginalExe.exe应用程序的功能,输入的预期内容,输出的输出方式。 />
应用程序通常在命令行中输入,输出可以在文件或标准输出流中。更少见的是,需要对标准输入流进行交互式输入。在所有这些情况下,您可以模拟所需的输入和捕获输出。



对于命令行输入,您可以使用方法的第二个参数 Process.Start ,如解决方案2所示。



如果需要使用标准输入或标准输出流,可以使用重定向那些流。以防万一,也使用标准错误流的重定向。这里解释了重定向:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput(v = vs.110).aspx [ ^ ],

http://msdn.microsoft .com / zh-cn / library / system.diagnostics.process.standardoutput(v = vs.110).aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/ system.diagnostics.process.standarderror(v = vs.110).aspx [ ^ ],

http:// msdn。 microsoft.com/en-us/library/system.diagnostics.processstartinfo%28v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system .diagnostics.processstartinfo.redirectstandardinput(v = vs.110).aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput(V = vs.110)的.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandarderror(v = vs.110).aspx [ ^ ],

另见: http://msdn.microsoft .com / zh-CN / library / 0w4h05yb(v = vs.110).aspx [ ^ ]。



我还要补充一点,依赖一些没有源代码的可执行文件可能会危及您的业务。如果可能,重要的是自己编写所需的功能,或使用知名的维护库,而不是 System.Diagnostics.Process.Start



-SA
You did not explain the functionality of the OriginalExe.exe application, what is expected on input, how the output is delivered.
It's very usual for applications to have input in a command line, and output could be in a file, or standard output stream. More rarely, interactive input to the standard input stream is required. In all such cases, you can simulate required input and capture output.

For command line input, you can use the second parameter of the method Process.Start, as shown in Solution 2.

If you need to work with standard input or standard output stream, you can use redirection of those stream. Just in case, also use redirection of standard error stream. Redirection is explained here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardinput(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandarderror(v=vs.110).aspx[^],
see also: http://msdn.microsoft.com/en-us/library/0w4h05yb(v=vs.110).aspx[^].

I would also add that relying on some executable without source code could endanger your business. If possible, it would be important to write required functionality by yourself, or use reputed maintained library, instead of System.Diagnostics.Process.Start.

—SA


这篇关于如何在我的文件中写入运行.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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