当前位置:编程学习 > C#/ASP.NET >>

使用.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-Ins
This 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


--------------------------------------------------------------------------------
Disclaimer: The content of this website is provided "AS IS" with no warranties, and confers no rights.

上一个:关于ref,out,params参数的理解(粘贴的源代码,说明在注释里面)
下一个:浅谈图形验证码的识别!

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,