问题
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