如何正确反编译dll和exe文件并将反编译的代码转换为正确的源代码 [英] How to decompile dll and exe files properly and convert the decompiled code to the correct source code

查看:367
本文介绍了如何正确反编译dll和exe文件并将反编译的代码转换为正确的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大师,

我是新手程序员,缺乏经验,对C#和Asp.net有一定的了解。

我目前被指派对使用Webservice(C#4.0,.Net Framework 4.0)的C#窗口应用程序的某些页面进行更改。我没有项目的源代码,只有exe和dll文件(bin文件夹中的几个dll文件和3个exe文件,几个.resx文件,.asmx文件和垃圾箱外面的web配置)。 />


在搜索谷歌后,我明白我需要使用反射器工具来反编译代码和reflexil插件来更改代码。我已经反编译了应用程序的所有exe和dll文件,最后我得到了很多错误的源代码。但是,我没有看到任何设计页面,也不知道解决方案结构是否正确,因为我之前根本没有看过源代码。我真的需要你的帮助。我想得到正确的源代码和解决方案结构。



如果有人能告诉我,我将深表感谢

1)反编译的正确方法是什么? (我是否需要反编译exe文件和dll或其中之一?)

2)更改代码的更好方法是什么? (通过reflexil或Visual Studio的反射器)

3)我是否有一些链接可以解释如何将反编译代码(自动生成的代码)转换为正确的源代码?

4)我怎样才能获得设计页面(我看到的只有.cs页面)?

5)如何检查当前的解决方案结构是否正确?



如果需要提供更多信息,请告诉我。

提前感谢您的好意见。



注意:以前的程序员离开公司并且没有源代码。

Hi Guru,
I am newbie programmer with the little experience and having some knowledge of C# and Asp.net.
I am currently assigned to make the changes for some pages of the C# window application that is using Webservice (C# 4.0, .Net Framework 4.0). I don't have the source code for the project but exe and dll files only (a few dll files in bin folder and 3 exe files, a few .resx files, .asmx files and web config outsides of the bin).

After searching through the google, I understand that I need to used the reflector tools to decompile the code and reflexil plugin to change the code. I have decompiled all of the exe and dll files of the application and lastly I got the source code with a lot of errors. However, I don't see any design page and don't have any idea whether the solution structure is correct or not since I have not seen the source code before at all.I really need the help from you.I would like to get the correct source code and solution structure.

It would be deeply appreciated if someone can tell me
1) What is the proper way to decompile ? (Do I need to decompile both exe files and dll or either one?)
2) Which is the better way to change the code? (via reflector with reflexil or Visual Studio)
3) May I have some links that explain well how to convert the decompiled code (auto-generated code) to the correct source code?
4) How shall I do in order to get design page (all I see is .cs page)?
5) How to check the current solution structure is correct or not?

Please let me know if any further information is required to provide.
Thank you so much in advance for your kind advice.

Note:The previous programmer left the company and don't have the source code.

推荐答案

我一直有反编译和反射器的问题,请尝试 DotPeek [ ^ ]。



1.你真的需要反编译你需要修改的那个。如果您更改DLL中的API,可能需要您更改EXE。



2.有一些工具可以让您直接在MSIL上工作并在里面修改该工具,但我更愿意回到代码并重新编译整个事情。 最好的是那种能够以最少的努力在你的情况下工作的。



3.我不确定你的意思是什么正确来源码。如果您的意思是代码没有错误,请尝试上面链接的工具。它将转换为C#,人们已经有了很好的结果。没有工具是100%有效的,因为编译器可能包含无法在源代码中复制的优化。



4.很多反编译器(Reflector就是这个问题)不会制作单独的Designer.cs文件。我不确定DotPeek是否会创建设计器文件但是没有好办法解决这个问题。存在设计器文件的原因很简单,因为它可以更容易地将设计器代码与用户代码分开,在通过编译器运行之后无法确定它是设计器生成的还是用户生成的。



5.解决方案结构是编译的结构,技术上文件夹和解决方案的内部结构只是为了便于组织代码,同样,这种结构不会在编译文件中复制。反编译器无法知道它是如何布局的(它可以根据名称空间进行猜测),但是没有办法复制原始结构。只要所有文件都在那里并编译回正确的命名空间和类型,它就像你希望的那样好。
I've always had problems with decompiling and Reflector, try DotPeek[^].

1. You only really need to decompile the one you need to modify. If you change an API in the DLL it may require you to change the EXE.

2. There are tools out there that let you work directly on MSIL and modify inside the tool, but I would prefer to go back to code and recompile the entire thing. The "best" one is the one that works in your situation with the least amount of effort.

3. I'm not sure what you mean "correct" source code. If you mean the code without errors, try the tool I linked above. It will convert to C# and people have had good results with it. No tool is 100% effective though since the compiler may include optimizations that are not possible to replicate in source.

4. A lot of decompilers (Reflector is one with this problem) doesn't make separate Designer.cs files. I'm not sure if DotPeek will create designer files but there isn't a good way around this. Designer files exist for the pure reason to make it easier to separate designer code from user code, after it runs through the compiler its impossible to determine if it was designer generated or user generated.

5. The solution structure is the one that compiles, technically folders and internal structure of the solution are only there to make it easy to organize code, and again, this structure is not replicated in the compiled file. The decompiler has no way of knowing how this was laid out (it can guess based on namespaces), but there is no way to duplicate the original structure. As long as all the files are there and compiles back into the right namespaces and types, its as good as you can hope for.


我过去做过这样的事情......。br />
源代码丢失了 - 只留下了二进制文件。



我开始创建一个新项目(Windows应用程序,在你的情况下为.NET 4)。

然后试图用反复无常的代码填充反编译代码。希望你会发现也许没有必要反编译dll,因为你不必在那里改变任何东西。



所以至少你以一些可管理的东西结束为了将来......
I have done such things in the past….
Source Code was lost - only the binaries left.

I started with creating a new Project (Windows application, .NET 4 in your case).
Then tried to fill up with the decompiled code -piece by piece. Hopefully you will find out that maybe there is no need to decompile the dlls because you don't have to change anything there.

So at least you end with something managable for the future...


这篇关于如何正确反编译dll和exe文件并将反编译的代码转换为正确的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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