日期:2014-05-17  浏览次数:20780 次

现在有一个 C#写的exe,没有源码,请问怎样在他运行的时候,捕获到程序 Console.writeline的内容呢?
不知道有没有什么工具,可以实现,先谢谢

------解决方案--------------------
用Process类。。
------解决方案--------------------
输出重定向

            Process p = new Process();
            // Redirect the output stream of the child process.
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = @"CslParentCls.exe";
            p.Start();
            // Do not wait for the child process to exit before
            // reading to the end of its redirected stream.
            // p.WaitForExit();
            // Read the output stream first and then wait.
            string output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();

------解决方案--------------------
用Depends.exe或DUMPBIN.EXE查看.dll输入输出信息
VS里面自带的你搜索安装VS目录(Depends.exe)

然后利用反编译命令格式:
dumpbin /DISASM  你的文件.exe
------解决方案--------------------
这个问题有点意思,我还没点击进来的时候就想到了Process类,但楼主却欲言又止,说:“我不能运行他,或者说不能这么简单的运行起来”,楼主要不干脆把需求说出来,看看有没有别的办法,不然除了Process类,你就只有用的反射去动态的new类里面的对象,然后再分析,然后再用new出来的对象,去执行。如果是控制台程序,那么就new它的入口类,然后用对象去Invoke了。