拆卸大会的实际原因是什么? [英] What is the practical reason to disassemble an Assembly?

查看:94
本文介绍了拆卸大会的实际原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们通常使用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的优秀答案中列出的那些。



我练习的一些案例:



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆