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

本文介绍了.NET Reflector这一强大的工具,它不仅能够分析程序集、展示其内部细节,还能反编译代码并显示C#和Visual Basic.NET等语言的等效版本。通过实例展示了如何使用.NET Reflector分析程序集,并介绍了其插件功能。

摘要生成于 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、付费专栏及课程。

余额充值