拆卸大会的实际原因是什么? [英] What is the practical reason to disassemble an Assembly?
本文介绍了拆卸大会的实际原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们通常使用ILDASM来反汇编程序集,使用它可以查看IL的汇编代码。根据我的理解,我发现它存在风险(当然,可能不是因为MS.NET允许我们这样做)。但我未解决的问题是为什么我们应该拆解程序集更改IL代码并重新构建它?
任何实际情况都应该对我有所帮助。
提前感谢所有技术专家。
We generally use ILDASM to disassemble the assembly using which we can view Assembly code of IL. Per my understanding, I see a risk in it (ofcourse it may not be since MS.NET allows us to do so). But my uncleared question is why should we disassemble an assembly make changes in IL code and reconstruct it?
Any practical scenario should definetly help me.
Thanks in advance to all tech gurus.
推荐答案
好:添加代码生成代码记录等方法调用(面向方面编程),这样您就不必更改原始源代码并使其无法管理。
坏:通常用于逆向工程并更改您没有源代码的代码行为。
丑陋:删除许可/版权保护
The good : adding metric producing code like logging etc. to method calls (aspect-oriented programing) so you don't have to change your original source code and make it unmanageable.
The bad : generally for reverse engineering and changing the behavior of code that you don't have the source for.
The ugly : removing licensing/copyright protection
可能有其他一些原因,除了Mehdi的优秀答案中列出的那些。
我练习的一些案例:
- 在一些非常高级的编程中,您需要使用IL或者在更实际的情况下使用
System.Reflection.Emit
来动态发出代码,这是某些技术的关键,例如序列化,以及基于数据或接口自动生成UI。这样的工作非常困难,需要很好的IL知识。以下是我的工作:我在C#中创建短代码示例,反汇编它们,看看编译器如何生成IL代码,学习它并编写正确的Emit代码。- 在CodeProject上发表的一些作品中,人们开发了非常有趣的技术,在非托管代码中使用.NET代码,而不需要使用丑陋的COM组件。该方法基于向要导出的成员添加特殊属性以进行非托管,自动组装代码,拆卸代码,修改代码和再次组装。请参阅:
在MFC中加载C#DLL [ ^ ],
如何在Visual Basic 6.0中使用Visual Basic 2008中创建的dll [ ^ ],
调用用C#编写的托管DLL Unmanged Code VC ++ [ ^ ],
API在.Net:托管代码或非托管代码 [ ^ ]。
There can be some other reasons, except those listed in the excellent answer by Mehdi.
Some cases from my practice:
- In some really advanced programming, you need to use IL or, in more practical cases,
System.Reflection.Emit
, to emit code on the fly, which is the key to some technologies, such as serialization, and, say, automatic generation of UI based on data or interfaces. Such work is pretty difficult and needs good knowledge of IL. Here is what I do: I create short code samples in C#, disassemble them and see how the compiler generates the IL code, to learn it and write correct Emit code.- In some works published on CodeProject, people developed very interesting technique of using .NET code in unmanaged code, without resorting to ugly COM components. The approach is based on adding special attributes to members to be exported to unmanaged, automatic assembling of the code, disassembling it, modification of it and assembling again. Please see:
loading C# DLL in MFC[^],
How can I use a dll created in Visual Basic 2008 in Visual Basic 6.0[^],
Call Managed DLL written in C# from Unmanged Code VC++[^],
API's in .Net: Managed or UnManaged Code[^].
这篇关于拆卸大会的实际原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文