技术文档 2008-07-16 10:12:05 阅读212 评论0 字号:大中小
天比较热,开门见山:
方法一:

使用cmd调用ildasm.exe#region 使用cmd调用ildasm.exe


/**//// <summary>
/// 使用cmd调用ildasm.exe 参数:argm= ildasm F:\\overred.exe /out=F:\\overred.il
/// </summary>
public static bool cmdCreateIL(string argm)

{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;


try

{
p.Start();
p.StandardInput.WriteLine(argm);
p.StandardInput.WriteLine("exit");
p.StandardOutput.ReadToEnd();
p.Close();
return true;
}
catch

{
return false;
}
finally

{
p.Dispose();
}
}
#endregion
方法二:
//argm= ildasm F:\\overred.exe /out=F:\\overred.il
Microsoft.VisualBasic.Interaction.Shell(@argm, Microsoft.VisualBasic.AppWinStyle.NormalFocus, true, 0);
一进程,一shell,夫妻双双把家还。另有更多,在此不举,本tip只为那些想写il的工具的们献上一小碟老醋花生,以助酒兴!
以下是我小妾,虽不漂亮,来见各位婆娘

功能增加中。。。相信不久,她将以裸体呈现(提供源码下载)
在上篇文章:来,一起扁ILDASM -->.net中略谈如何调ildasm.exe 中只是简单谈到如何调ildasm.exe,让只吃过猪肉的朋友们再看看猪跑,那就是如何取得ildasm.exe输出的内容(而不是生成某个il文件),ildasm的输出内容命令:/TEXT
ildasm.exe -text overred.exe
如上,就会把overred.exe的il码打印在dos窗口,我们可以使用如下程序在C#里“抢亲”:
string cmd(string argm)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "ildasm.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.Arguments = " -text " + argm;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
return p.StandardOutput.ReadToEnd();
}
string ilContent=cmd(@"overred.exe");
ilContent就是你要抢的肥婆拉。
评论