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

本文介绍了.NET Reflector 这一工具,它是类浏览器和反编译器,可分析基于.NET 的代码。借助反射概念,能检索程序集里类、方法和属性的信息。还能浏览程序集的类和方法,分析 MSIL,反编译查看 C#、Visual Basic.NET 或 Delphi 形式的代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

.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.
Reflector是由微软员工Lutz Roeder编写的免费程序。Reflector的出现使.NET程序员眼前豁然开朗,因为这个免费工具可以将.NET程序集中的中间语言反编译成C#或者Visual Basic代码。除了能将IL转换为C#或Visual Basic以外,Reflector还能够提供程序集中类及其成员的概要信息、提供查看程序集中IL的能力以及提供对第三方插件的支持。 程序集,作为.NET时代的动态链接库,蕴藏了太多的软件秘密。为此,Visual Studio内置的ILDASM成为最初挖掘程序集的上佳工具。但自从Reflector出现后,ILDASM相形见绌。因为,Reflector能提供更多的程序集信息,而且是免费的工具。   如今,在Visual studio中编译源代码(无论是VB还是C#)时,编译器都会将高级源代码翻译成MSIL,即“微软中间语言”,而不是特定的机器指令。具有更多安全性、版本控制、共享能力与其它相关元数据的中间语言(IL),是包在一个或多个DLL或可执行文件中的。   基于ILDASM检查程序集中的IL有时很有用,但它要求我们熟悉MSIL。通常,比起IL,大多数开发人员对像C#或Visual Basic这样的高级程序设计语言更为熟悉。   Reflector的出现使.NET程序员眼前豁然开朗,因为这个免费工具可以将.NET程序集中的中间语言反编译成C#或者Visual Basic代码。除了能将IL转换为C#或Visual Basic以外,Reflector还能够提供程序集中类及其成员的概要信息、提供查看程序集中IL的能力以及提供对第三方插件的支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值