【发布时间】:2018-09-21 20:29:52
【问题描述】:
我正在制作一个使用 procdump 转储进程然后使用 Strings v2.53 将转储转换为实际字符串的工具,在转换转储后,我试图将控制台应用程序中显示的所有字符串写入 .文本文件。
我不知道我做错了什么,我尝试了每个论坛帖子,我看到了如何做到这一点,但我就是做不到。
这是我的代码
string path2 = @"C:\Void\Dump\Dump.txt";
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd.exe";
info.RedirectStandardInput = true;
info.UseShellExecute = false;
p.StartInfo = info;
p.Start();
StreamWriter sw = p.StandardInput;
using (sw)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine(@"cd C:\Void\Dump");
sw.WriteLine(@"strings -s");
System.IO.StreamWriter stream = new System.IO.StreamWriter(path2);
sw.AutoFlush = true;
Console.SetOut(stream);
}
}
【问题讨论】:
-
我只需要知道如何将Console App正在写入的文本转换为txt。
-
你的最终目标是什么?你想用txt文件做什么?如果您想再次在程序中读回该 txt,您也可以直接将 strings.exe 作为进程启动,而无需通过 cmd.exe 绕道。如果这样做,您可以只重定向此进程的 StandardOutput,并在您的 C# 程序中完全以编程方式读取 strings.exe 的输出,而无需临时 txt 文件...
-
我制作了一个工具,它将自动创建 javaw 进程的转储,使用 strings.exe 将转储转换为可读字符串,然后使用 consoleapp 字符串在新的 txt 中搜索与作弊相关的字符串。因为我为之工作的人不希望那里的网络上有骗子,所以他们希望我制作一个工具来防止这种情况。我已经有了制作转储和转换它的过程。我只需要知道如何将所有显示的 ConsoleApp 文本转换为我可以搜索的 txt。
-
所以本质上你确实希望在你的程序中搜索 strings.exe 的输出,还是我误解了你?
-
是的,你完全正确。
标签: c# console console-application dump streamwriter