我们是否在反汇编器或逆向工程 CIL 中查看原始代码?
以ILSPy为例。当我查看程序集时,我看到的是原始 C# 吗?或者,此代码是使用某种类型的逆向工程过程从 CIL 重建的吗?
我的理解是发布程序集不包含任何原始代码,仅包含 CIL。那么,如果我在发布模式下构建程序集会有什么不同吗?
Take ILSPy. When I view my assembly am I looking at my original C#? Or, is this code reconstructed from CIL using some type of reverse engineering process?
My understanding is that release assemblies do not include any original code, just CIL. So, does it make a difference if I build my assembly in release mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
发布程序集和调试程序集都不包含原始源代码。
ILSpy 与朋友们分析编译后的CIL以提取合理的C#等效项。
Neither release nor debug assemblies contain original source code.
ILSpy & friends analyze the compiled CIL to extract a reasonable C# equivalent.
发布与调试仍然有很大的区别。编译器会进行优化。请参阅 Scott Hanselman 关于发布与调试的帖子。
就 ILSpy 的功能而言,它会显示 CIL,然后将其逆向工程为合理的 C#/VB 表示形式。我承认 ILSpy 在这方面做得非常好!我用它反转了其他人的程序集,并且可以完全理解他们的代码。我唯一一次遇到问题是在 WPF 和 GUI 方面,但我确信也有办法解决这个问题。
为了防止逆向组装和保护您的知识产权,请使用 Dotfuscator 或其他混淆工具。
Release vs Debug still makes a huge difference. The compiler does optimize. See Scott Hanselman's post about Release vs Debug.
In terms of what ILSpy does, yes it displays CIL and then reverse engineers it to a reasonable C#/VB representation. I'll admit ILSpy does a very good job with it! I've reversed others' assemblies with it and can make perfect sense of their code. The only time I've had it break down was with WPF and GUI stuff, but I'm sure there are ways to work that as well.
In terms of preventing reversal of your assembly and protecting your intellectual property, use Dotfuscator or other obfuscation tool.
您正在看到从 IL 重构的代码。此重建过程可以在任何 .NET 程序集上执行,无论它是在调试模式还是发布模式下构建的。
您无法阻止以这种方式从程序集中重建源代码,但如果您想让代码不太有用/难以理解,您可以使用各种 .NET 混淆工具。
You are seeing code reconstructed from the IL. This reconstruction process can be performed on any .NET assembly regardless of whether it is built in debug or release mode.
You can't prevent your source code from being reconstructed from your assembly in this way, but if you want to make the code less useful/understandable you can use various .NET obfuscation tools.
实际上,您可以使用 ILMerge 或 .net FuZe 将您的 exe 和 dll 包装到 exe 或 dll 容器中,使其更难以反汇编。
Actually, you could use ILMerge or .net FuZe to wrap your exe and dlls into an exe or dll container, making it more difficult to disassemble.