Reflector如何反编译代码? [英] How does Reflector decompile code?

查看:214
本文介绍了Reflector如何反编译代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Red Gate Ant Profiler或Reflector等工具如何将IL转换为C#或VB.NET代码?

How do tools like the Red Gate Ant Profiler or the Reflector convert IL into C# or VB.NET code?

我最近注意到Red Gate Ant Profiler不会生成与最初编写的源代码相同的代码.

I recently noticed that the Red Gate Ant Profiler does not generate the same source code that was written originally.

它在我使用foreach的地方生成了while循环.

It generated a while loop where I had used a foreach.

这让我思考.我在Reflector中打开了Reflector.exe本身,但是它们的代码大部分(不是全部)都被混淆了.

That made me think. I opened Reflector.exe itself in Reflector but their code is mostly (not all of it) obfuscated.

推荐答案

在常规工作中,通过查看IL并构建在语义上等效于IL的源代码,可以反编译器.由于IL丢弃了一些高级信息(尽管不如机器代码那么多),并且通常有几段代码可编译为同一个IL,所以这并不总是产生原始的源代码.例如,foreach循环等效于某种while循环(首先设置一个枚举器,然后循环直到该枚举器用尽,然后在每个步骤前进该枚举器).

Decompilers in general work by looking at the IL and constructing source code which is semantically equivalent to the IL. This can't always yield the orignal source code, because IL drops some high-level information (though not as much as machine code) and because there's usually several pieces of code that compile to the same IL. For example, a foreach loop is equivalent to a certain kind of while loop (one that sets up an enumerator first, then loops until the enumerator is exhausted, and advanced the enumerator at each step).

这篇关于Reflector如何反编译代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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