ILDASM和ILASM,如何使用? [英] ILDASM and ILASM, how use them?

查看:479
本文介绍了ILDASM和ILASM,如何使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用Visual Studio命令提示符(反汇编)dll时遇到了麻烦,就像我看到的那样,看起来并不那么简单

I'm having a hard time trying to (Dis)assemble a dll using the Visual Studio command prompt, don't look that simple as I see in the microsoft page.

我通过以下方式使用ildasm:

I'm using the ildasm for these way:

ildasm myLibrary.dll output:MyLibrary.il

我得到:无法打开'MyLibrary.il'进行输出.

我也尝试了完整路径:

ildasm directory\myLibrary.dll output:directory\MyLibrary.il

我得到:指定了多个输入文件

使用ildasm GUI实际上可以,但是当我使用ilasm时:

Using the ildasm GUI actually works, but when I use the ilasm:

ilasm myLibrary.il /dll

我得到:当我使用完整路径时,我无法打开'myLibrary.il'.

这是怎么了?

推荐答案

简单,让我们看一下这行代码:

simple, let's take this line of code:

using System;      
public class sample  
{
    static void Main(string[] args)
    {
        Console.WriteLine("Inside main ...");
    }
}

让我们将App.cs编译为App.exe.现在,运行该可执行文件时,它会在Inside main…中打印.

Let us compile App.cs to App.exe. This executable now prints Inside main … when we run it.

现在,让我们尝试更改此可执行文件的输出,而无需触摸其源文件.

您运行ildasm App.exe /out:App.il 生成与可执行文件相对应的IL代码.您现在可以在记事本中编辑此il代码,并将ldstr从"Inside main…"更改为"Inside main change…",如下所示:

You run ildasm App.exe /out:App.il to generate the IL code corresponding to the executable. You can now edit this il code in notepad and change the ldstr from "Inside main …" to "Inside main changed …" as shown below:

IL_0000:  nop
IL_0001:  ldstr      "Inside main ..."
IL_0006:  call       void [mscorlib]System.Console::WriteLine(string)
IL_000b:  nop
IL_000c:  ret

收件人

IL_0000:  nop
IL_0001:  ldstr      "Inside main changed ..."
IL_0006:  call       void  [mscorlib]System.Console::WriteLine(string)
IL_000b:  nop
IL_000c:  ret

现在,让我们通过运行ilasm App.il.从此il文件重建可执行文件.这将生成一个新的App.exe.如果运行App.exe,您将获得以下输出"Inside main changes…"

Now let us rebuild the executable from this il file by running ilasm App.il. This generates a new App.exe. If you run App.exe you will get the following output "Inside main changed …"

There are useful posts in social.msdn and in c-sharpcorner as well guiding through the use of ILDASM and ILASM.

这篇关于ILDASM和ILASM,如何使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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