使用.NET Reflector插件FileDisassembler还原源码

 
.NET Reflector,它是一个类浏览器和反编译器,能够分析程序集并向您展现它的全部秘密。.NET 框架向全世界引入了可用来分析任何基于 .NET 的代码(不管它是单个类仍是完整的程序集)的反射概念。反射还能够用来检索有关特定程序集中包含的各类类、方法和属性的信息。使用 .NET Reflector,您能够浏览程序集的类和方法,能够分析由这些类和方法生成的 Microsoft 中间语言 (MSIL),而且能够反编译这些类和方法并查看 C# 或 Visual Basic ?.NET 中的等价类和方法。

为了演示 .NET Reflector 的工做方式,我将加载和分析前面已经显示的 NUnitExample 程序集。下图显示了 .NET Reflector 中加载的该程序集。


在 .NET Reflector 内部,有各类可用来进一步分析该程序集的工具。要查看构成某个方法的 MSIL,请单击该方法并从菜单中选择 Disassembler。

除 了可以查看 MSIL 之外,您还能够经过选择 Tools 菜单下的 Decompiler 来查看该方法的 C# 形式。经过在 Languages 菜单下更改您的选择,您还能够查看该方法被反编译到 Visual Basic .NET 或 Delphi 之后的形式。如下为 .NET Reflector 生成的代码:
public void HashtableAddTest(){     
Hashtable hashtable1;
hashtable1 = new Hashtable();
hashtable1.Add("Key1", "value1");
hashtable1.Add("Key2", "value2");
Assert.AreEqual("value1", hashtable1["Key1"], "Wrong object returned!");
Assert.AreEqual("value2", hashtable1["Key2"], "Wrong object returned!");
}

前面的代码看起来很是像我为该方法实际编写的代码。如下为该程序集中的实际代码:
public void HashtableAddTest(){        Hashtable ht = new Hashtable();                    ht.Add("Key1", "value1");        ht.Add("Key2", "value2");        Assert.AreEqual("value1", ht["Key1"],  "Wrong object returned!");        Assert.AreEqual("value2", ht["Key2"],  "Wrong object returned!");}
尽管上述代码中存在一些小的差别,但它们在功能上是彻底相同的。 虽然该示例是一种显示实际代码与反编译代码之间对 比的好方法,但在我看来,它并不表明 .NET Reflector 所具备的最佳用途 — 分析 .NET 框架程序集和方法。.NET 框架提供了许多执行相似操做的不一样方法。例如,若是您须要从 XML 中读取一组数据,则存在多种使用 XmlDocument、XPathNavigator 或 XmlReader 完成该工做的不一样方法。经过使用 .NET Reflector,您能够查看 Microsoft 在编写数据集的 ReadXml 方法时使用了什么,或者查看他们在从配置文件读取数据时作了哪些工做。.NET Reflector 仍是一个了解如下最佳实施策略的优秀方法:建立诸如 HttpHandlers 或配置处理程序之类的对象,由于您能够了解到 Microsoft 工做组其实是如何在框架中生成这些对象的。 .NET Reflector 由 Lutz Roeder 编写 下载地址:http://www.aisto.com/roeder/dotnet 如今介绍一个它的插件。很是好用。还原源码。! www.denisbauer.com/Downloads/Reflector.FileDisassembler.zip 这是插件下载地址! 打开Reflector,在view菜单下的Add-Ins,将dll添加到里面便可! 而后加载一个dll。选中它。选择Tools-File Disassembler打开右侧File Disassembler窗口再选择Generate 这样就还原了源码。但可不是彻底还原! 下面还有其它的Plug-In.NET Reflector Add-InsThis website lists add-ins for .NET Reflector. After downloading one of the add-ins copy the files to the same directory as your 'Reflector.exe' file and load them via the 'Add-Ins' command under the 'View' menu. You can download Reflector here. --------------------------------------------------------------------------------Reflector.FileDisassembler This add-in can be used to dump the disassembler output to files for any Reflector supported language. Website Download --------------------------------------------------------------------------------Reflector.DelphiLanguage The Delphi view that is used inside .NET Reflector provided as a language add-in. Website Download --------------------------------------------------------------------------------Reflector.McppLanguage This add-in extends Reflector with a Managed C++ language rendering module. Website Download--------------------------------------------------------------------------------Reflector.ChromeLanguage This add-in extends Reflector with a Chrome language rendering module. Website Download --------------------------------------------------------------------------------Reflector.Diff This add-in shows differences between two versions of the same assembly. Website Download --------------------------------------------------------------------------------Reflector.VisualStudio This program is hosting .NET Reflector inside the Visual Studio 2003 IDE. Run Reflector.VisualStudio.exe to register the add-in with Visual Studio. Website Download --------------------------------------------------------------------------------Reflector.ClassView Shows class definitions as plain text with color coding. The menu item is registered under the "Tools" menu. Website Download --------------------------------------------------------------------------------Reflector.CodeModelView This add-in shows the underlying code model objects for a selected node in .NET Reflector. The menu item is registered under the "Tools" menu. Website Download --------------------------------------------------------------------------------Reflector.FileGenerator This add-in can be used to dump the disassembler output to files for any Reflector supported language. Download --------------------------------------------------------------------------------Reflector.Graph This add-in draws assembly dependency graphs and IL graphs. It also supports method ranking and type ranking. Website --------------------------------------------------------------------------------Reflector.OpenRunningAssembly Opens an assembly or dependency from a process running on the system. The menu item is registered under the "Tools" menu. Website Download --------------------------------------------------------------------------------Reflector.MbUnit This add-in allows loading and executing MbUnit unit test fixtures in Reflector. The source code is provided online. Website
相关文章
相关标签/搜索