Objective
In the implementation of the project will sometimes encounter the need to understand the program code developed by a third party or because it has lost the original code for a long time, because it is written by someone else, so we do not have the original code can be read directly, in this case we need to decompile these programs and DLL files.
First about what the DLL is, the DLL full name is the dynamic linking library, when you use. NET to develop an application, when you are using a Web site project or a category library, when the project is built, the Bin folder underneath the project produces the All of the class files in the project are compiled into DLL files, and if you are developing a library of shared tool categories, you will be able to provide this DLL file to multiple applications and Web site references.
But DLL files are compiled files, in general, it is impossible to know the internal composition of the program code, so you have to use the Anti-compilation tool to assist to spy on the original code inside the DLL, in this note, DLL files can be anti-compiled, so do not think that the program is written as a DLL File after the other people can not know the content, but if you really want to hide the contents of the DLL, you can confuse the DLL in the way the DLL files in the program code to make a mess, increase the difficulty of reading after the anti-compilation.
Create a category Library
Before deserializing the DLL, let's set up a class library for later decompile use, and open VS to create a category library project, as follows
A salaryhelper Class file is then created to calculate the amount of the payroll funds, as follows
The content of the Salaryhelper Class is simply a way to write a method and return the salary amount, as follows
View Sourceprint?01.
namespace
Tools
02.
{
03.
public
class
SalaryHelper
04.
{
05.
public
decimal
GetMySalary()
06.
{
07.
return
22000;
08.
}
09.
}
10.
}
Finally, create a consoleapplication to add the Tools category library to the reference, and call the Getmysalary () method to get the salary, as follows
View Sourceprint?01.
namespace
ConsoleApp
02.
{
03.
class
Program
04.
{
05.
static
void
Main(
string
[] args)
06.
{
07.
Tools.SalaryHelper helper =
new
Tools.SalaryHelper();
08.
Console.WriteLine(
09.
string
.Format(
"My Salary is {0}"
, helper.GetMySalary().ToString()));
10.
Console.Read();
11.
}
12.
}
13.
}
Execution results are as follows
Using the IL anti-translation tool
When you install Visual Studio, Windows SDK Tools is typically installed together with an IL anti-translation tool in Windows SDK tools that can decompile DLL files into intermediate languages, as follows
Using the Il anti-translation tool to decompile the DLL into an intermediate language can correspond to the original code, but this intermediate language is very uncomfortable, so we will use other tools to do the anti-compilation action.
The redgate. NET Reflector and Telerik. NET Decompiler are often heard in the tools used to decompile this two tool, and the. NET Reflector tool is a cost-free tool, but the functionality is pretty powerful, This tool is recommended for frequent in-depth use, while. NET Decompiler is a free anti-compilation tool that does not have the. NET Reflector power, but is free to do it first, and the following is a demonstration of this tool.
Decompile program code using the Telerik. NET Decompiler Tool
First go to download URL click free Download download the installation file
After the download is complete, you can install the next step .... Point-to-finish
After the installation is complete, go to "Start"→"All Programs"→"telerik" find Telerik justdecompile program execution, as follows
After opening the Justdecompile program, click on the "open..."→"file (s) ..." to find our tools DLL File Open
After opening, expand the tree directory below and find the Salaryhelper Class we wrote in the Tools namespace
After selecting to Salaryhelper, the right splitter window will display the category's anti-compiled program code, as follows
Anti-compilation program code
The original program code
After the DLL archive is compiled through the. NET Decompiler tool, is it found that the similarity between the two is very high and very cordial:P, and this tool can also convert the anti-compiled program code to other languages of the code, in the top of the tool column can see a C # drop-down menu, click to select C #, VB, IL language
If you are writing the VB language, you can change C # to Visual Basic, the modified code will become the Visual Basic Language Program code, is not very convenient.
With this tool there is also a very important function is to see the. NET Framework implementation of the category library! If the Load framework is selected at open, you can select the installed. NET Framework to read, as follows
This allows you to see the bottom-up implementation of the. NET Framework class Library, which is a simple way to use it for the reference of people in need.