使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具

使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具

使用ildasm获取源代码

.NET code (C#, VB, F#, etc) compiles (for the most part) into Intermediate Language (IL) and then makes it way to native code usually by Just-in-time (JIT) compilation on the target machine. When you get a DLL/Assembly, it's pre-chewed but not full juiced, to mix my metaphors.

.NET代码(大部分是C#,VB,F#等)会编译为中间语言(IL),然后通常通过在目标计算机上进行即时(JIT)编译将其转换为本地代码。 当您获得DLL /程序集时,将其进行预咀嚼但未完全溶解,以混合我的隐喻。

Often you'll come along a DLL that you want to learn more about. Sometimes you'll want to just see the structure of classes, methods, etc, and other times you want to see the IL - or a close representation of the original C#/VB/F#, etc. You're not looking at the source, you're seeing a backwards projection of the IL as whatever language you want. You're basically taking this pre-chewed food and taking it out of your mouth and getting a decent idea of what it was originally.

通常,您会遇到想要了解更多信息的DLL。 有时,您只想看一下类,方法等的结构,而有时又想看一下IL-或原始C#/ VB / F#的近似表示,等等。您不是在看源代码。 ,无论您想要哪种语言,您都会看到IL的向后投影。 您基本上是将这种预先咀嚼的食物从嘴里拿出来,对它的本来面目有所了解。

I've used ILDasm for years, but it's old and lame and people tease you for using it because they are cruel. ;)

我已经使用ILDasm多年了,但是它又老又la脚,人们嘲笑您使用它,因为它们很残酷。 ;)

Seriously, though, I use ILDasm - the IL Disassembler - simply because it's already installed. Those tweets got me thinking though that I need to update my options, so I'm trying out ILSpy and dnSpy.

严重的是,我使用ILDasm-IL Disassembler-仅仅是因为它已经安装了。 这些推文让我开始思考,尽管我需要更新我的选项,所以我正在尝试ILSpydnSpy

ILSpy (ILSpy)

ILSpy has been around for a while and has multiple front-ends, including ones for Linux/Mac/Windows based on Avalonia in the form of AvaloniaSpy. You can also integrate ILSpy into Visual Studio 2017 or 2019 with this extension. There is also a console decompiler and, interestingly, cross-platform PowerShell cmdlets.

ILSpy已经存在了一段时间,并且具有多个前端,包括用于基于AvaloniaLinux / Mac / Windows的AvaloniaSpy形式的前端。 您还可以使用此扩展将ILSpy集成到Visual Studio 2017或2019中。 还有一个控制台反编译器,以及有趣的是跨平台的PowerShell cmdlet

使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具

I've always liked the "Open List" feature of ILSpy where you can open a preconfigured list of assemblies you want to browse, like ASP.NET MVC, .NET 4, etc. A fun open source contribution for you might be to update the included lists with newer defaults. There's so many folks doing great work in open source out there, why not jump in and help them out?

我一直很喜欢ILSpy的“打开列表”功能,您可以在其中打开要浏览的程序集的预配置列表,例如ASP.NET MVC,.NET 4等。对您来说,一个有趣的开源贡献可能是更新包含的列表具有较新的默认设置。 有这么多人在开源方面做得很好,为什么不跳进来帮助他们呢?

dnSpy (dnSpy)

dnSpy has a lovely UI AND a great Console app using the same engine. It's amazingly polished and VERY complete. I was surprised that it also has a full hex editor as well as property pages for common EXE file headers. From their GitHub, dnSpy features

dnSpy具有漂亮的用户界面和使用相同引擎的出色控制台应用程序。 它非常抛光,非常完整。 我很惊讶它还具有完整的十六进制编辑器以及常见EXE文件标头的属性页。 从GitHub的dnSpy功能

  • Debug .NET Framework, .NET Core and Unity game assemblies, no source code required

    调试.NET Framework,.NET Core和Unity游戏程序集,无需源代码
  • Edit assemblies in C# or Visual Basic or IL, and edit all metadata

    编辑C#或Visual Basic或IL中的程序集,并编辑所有元数据
  • Light and dark themes

    浅色和深色主题
  • Extensible, write your own extension

    可扩展,编写自己的扩展
  • High DPI support (per-monitor DPI aware)

    高DPI支持(每个监视器都知道DPI)

dnSpy takes it to the next level with an integrated Debugger, meaning you can attach to a running process and debug it without source code - but it feels like source code because it's decompiling for you. Note where it says C#, I can choose C#, VB, or IL as a "view" on my decompiled code.

dnSpy通过集成的调试器将其提升到一个新的水平,这意味着您可以附加到正在运行的进程中,而无需源代码即可对其进行调试-但这就像源代码,因为它正在为您反编译。 注意在显示C#的地方,我可以选择C#,VB或IL作为反编译代码上的“视图”。

使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具

Here is dnSpy actually debugging ILSpy and stopped at a decompiled breakpoint.

这是dnSpy实际上正在调试ILSpy并在反编译的断点处停止的情况。

使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具

There's a lot of great low-level stuff in this space. Another cool tool is Reflexil, a .NET Assembly Editor as well as de4dot by the same mysterious author as dnSpy. JetBrains has the excellent dotPeek and Telerik has JustDecompile. Commercial Tools include Reflector.

在这个空间中有很多很棒的底层东西。 另一个很酷的工具是.NET程序集编辑器Reflexil,以及与dnSpy一样神秘的作者的de4dot。 JetBrains具有出色的dotPeek,而Telerik具有JustDecompile 。 商业工具包括Reflector

What's your favorite?

你最喜欢什么?



Sponsor: Manage GitHub Pull Requests right from the IDE with the latest JetBrains Rider. An integrated performance profiler on Windows comes to the rescue as well.

赞助商:使用最新的JetBrains Rider从IDE直接管理GitHub Pull Requests。 Windows上的集成性能分析器也可以解决。

关于斯科特 (About Scott)

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

斯科特·汉塞尔曼(Scott Hanselman)是前教授,前金融首席架构师,现在是演讲者,顾问,父亲,糖尿病患者和Microsoft员工。 他是一位失败的单口相声漫画家,一个玉米种植者和一本书的作者。

使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具
使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具
使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具
About   关于 Newsletter 时事通讯
Hosting By 主持人
使用ildasm获取源代码_有什么比ILDasm好? ILSpy和dnSpy是反编译.NET代码的工具

翻译自: https://www.hanselman.com/blog/whats-better-than-ildasm-ilspy-and-dnspy-are-tools-to-decompile-net-code

使用ildasm获取源代码