有没有办法从.DLL获取源代码? [英] Is there any way to get the source code from .DLL ?

查看:463
本文介绍了有没有办法从.DLL获取源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



DLL是在.NET代码的帮助下构建的。

根据信息,我有我们可以使用

IL DIssemble

IL SPY

.NET反射器



到看到DLL中存在的对象,classess,属性。



但是有没有办法从DLL获取源代码?

这个问题对我来说很奇怪:(作为.NET开发人员。



但JAVA人员自豪地说他们的可执行文件EAR可以反编译成源代码从它构建...



所以,.NET好友,请帮助我评论更多关于从中获取源代码的方法dll ...

是否存在任何方式?

如果是,那是什么?

如果不是,为什么它不可用? ??



提前感谢您的帮助!!!!

Hi Friends,

DLL is build with the help of .NET code.
As per the information, I am having we can use
IL DIssemble
IL SPY
.NET reflector

to see the objects, classess, properties present inside the DLL.

But is there any way to get the source code from DLL ?
This question is looking very strange to me :( as a .NET developer.

But JAVA folks are proudly saying that their executable EAR can decompile to the source code from it is build...

so, .NET friends, Please help me by commenting more about the way to get the source code from dll...
Whether any way is present ?
If yes, What is that ?
If no, Why it is not available ???

thanks in advance for your help !!!!

推荐答案

虽然我完全赞同@Rohan Leuva,您可以尝试Telerik的优秀产品,名为Just Decompile。它非常易于使用。

您可以从这里下载 http://www.telerik.com/download/justdecompile [ ^ ]



我的建议是第一次使用文档/教程。



希望,它有帮助:)



注意:你不能得到100%相同的代码decopmiled但它应该生成相同的工作代码。
While I completely agree with @Rohan Leuva, you can try an excellent product from Telerik named "Just Decompile". It's very easy to use.
You can download it from here http://www.telerik.com/download/justdecompile[^]

My suggestion is to follow the documentation/tutorial for the first time use.

Hope, it helps :)

Note: You cann't get the 100% same code decopmiled but it should generate equivalent working code.


你列出的工具是查看.NET DLL内容的很好的工具。 ILSpy和.NET Reflector允许您将DLL中的代码导出到C#或VB.NET中,但是有一些限制。



我个人使用ILSpy,这是就像打开DLL一样简单,找到有问题的类,然后转到File-> Save Code。



我从Red Gate开始没有使用.NET Reflector使它成为封闭源并为此收费。当我使用它时,它有一个非常好的功能,可以将整个程序集的内容导出到C#或VB.NET项目,而不是像ILSpy那样的单个代码文件。



还有其他工具可以实现这一目标。我知道Telerik有一个,但我相信它是一个商业产品。 JetBrains也有一个名为dotPeek的免费使用。



为了理解你的第二个问题,为什么,你需要了解.NET的工作原理。您的.NET应用程序未编译并链接到可执行文件,就像C / C ++应用程序一样。您的应用程序被编译为中间语言(IL)或Microsoft中间语言(MSIL),类似于Java的字节码。看一下这篇文章,深入了解IL:

了解通用中间语言(CIL) [ ^ ]



在Windows中,当您运行.NET应用程序时,本地计算机将获取IL并执行Just In时间编译(JIT)以生成可在本地计算机上运行的本机代码。看看这篇MSDN文章,了解有关JIT的更多信息:

将MSIL编译为本机代码 [ ^ ]



简单回答原因只是你的代码还没有完全编译,直到你运行您的应用程序,以便逆向工程是相当直接的。这有限制(linq查询,lamda表达式,混淆器),工具可能很难创建确切的代码,但它可以提供一些功能。



我希望这有帮助。
The tools you listed are great tools for viewing the contents of .NET DLLs. ILSpy and .NET Reflector allow you export the code from the DLL into C# or VB.NET, but there are limitations to this.

I personally use ILSpy, which is as easy as opening the DLL, finding the class in question, then go to File->Save Code.

I haven't used .NET Reflector since Red Gate made it closed source and charged for it. When I did use it, it had a very nice feature that would export the entire assembly's contents into C# or VB.NET project as opposed to individual code files like ILSpy does.

There are also other tools out there that will achieve this. I know Telerik has one, but I believe it is a commercial product. JetBrains also has one called dotPeek that is free to use.

In order to understand your second question, the why, you need to understand how .NET works. Your .NET application is not compiled and linked into executable file like a C/C++ application is. Your application is compiled into an intermediate language (IL) or Microsoft Intermediate Language (MSIL) which is similar to Java's bytecode. Take a look at this article to understand IL a bit more in depth:
Understanding Common Intermediate Language (CIL)[^]

In Windows, when you run a .NET application, the local computer takes the IL and performs a Just In Time compile (JIT) to produce native code that can run on the local computer. Take a look at this MSDN article to understand more about JIT:
Compiling MSIL to Native Code[^]

The short answer to the why is simply your code hasn't been fully compiled until you run your application so the reverse engineering is fairly straight forward. There are limitations to this (linq queries, lamda expressions, obfuscator) where the tool may have an extremely hard time creating the exact code, but it will be able to give something functional.

I hope this helps.


这篇关于有没有办法从.DLL获取源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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