How does c# decompiler work

爷,独闯天下 提交于 2019-12-06 05:07:58

问题


i am interested in decompilers like ILSpy or .Net Reflector and etc.

Can anybody tell me how this decompiler convert exe or dll files written in c# to its original source code?


回答1:


There are two key points, here.

Firstly, IL, while a lower level language that C# or VB.NET, is a much higher level than assembler or machine code. Many high level constructs are still in place and can be used relatively easily to determine the flow and operation of the code.

The other key point, is that a decompiler does not generate the original source code. It generates high-level language constructs from the lower-level IL, which, typically are very similar to the original source code, but not identical.




回答2:


The ILSpy team has several blog posts on how ILSpy works:

  • Initial post giving a rough overview of the architecture
  • Details on how the implicit evaluation stack of IL is converted into variables
  • Walkthrough of decompiler pipeline, part 1
  • Walkthrough of decompiler pipeline, part 2



回答3:


Because the C# complier generates a meta data information and the generated code is intermediate language that is translated to binary code at runtime so each dll or exe generated from the complier can be refactored by .net reflector and the ILSpy can



来源:https://stackoverflow.com/questions/6918270/how-does-c-sharp-decompiler-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!