. Net, Dll literacy, how to debug the compiled dll in ?,. Netvs
What is Dll?
DLL is a library that contains code and data that can be used by multiple programs at the same time. For example, in Windows, Comdlg32 DLL executes common functions related to the dialog box. Therefore, each program can use the functions included in the Dll to implement the "open" dialog box. This helps promote code reuse and effective memory usage.
By using DLL, the program can be modularized and composed of relatively independent components.
Generally speaking, a project consists of multiple modules. Each module can be loaded into the main program at runtime (if the corresponding module is installed ). Because modules are independent from each other, the program loading speed is faster, and the module is loaded only when the corresponding functions are requested, you only need to replace the current DLL.
How to Create a Dll?
In. net Development as an example. In the current compilation environment, you only need to right-click the project you want to create as a dll and re-generate it, and then find the debug folder under the corresponding folder of the project, there will be a file with the same name as the current project suffix dll.
How to Use Dll?
First, reference the dll in the project, and then using the dll to call the class and method. Because it is a dll, F12 is generally like this:
We can see that this class is neither an abstract class nor any interface or class, but the method body is not implemented, and the top part is the xx assembly.
You can view the structure in the Object Browser of vs, but you cannot see the code in the method or debug it.
How to view the dll code?
You want to understand the code implementation in these dll files, but you cannot see them. However, what you think of has come to our predecessors. In another way, you cannot see the code in the compiled dll because vs compiler does not include this function.
So, let's find a tool to help us look at the code in this dll.
This implementation process is called decompilation.
Naturally, we need to decompile the software.
Currently, the well-known decompilation software includes Il spy and. NET Reflector.
I prefer il spy because I have a Chinese version on the Internet.
Chart:
If you want to view a specific dll, click the file tab, click open, and find the dll path (. NET Reflector ).
The tool is very convenient and has many functions. For more information, see Baidu.
How to debug the dll code in vs development projects?
What should I do if I want to debug the source code in the project? I will tell you that only one tool can meet your requirements.
That is the vs plug-in of. NET Reflector.
. NET Reflector is a decompilation software, but if you want to debug dll code in real time, you need to use its vs plug-in.
. NET Reflector and. NET Reflector vs plug-in are two concepts. If you do not understand them, please Baidu what is vs plug-in.
Next, I will teach you how to install and use this plug-in.
First, Click Tools and click scale and update.
Click online and search for Reflector in the search box on the right.
Finally, select the first one and click Install.
Latest Version 9.2
After the installation is complete, multiple tabs are added to.
The. NET Reflector Object Browser is A. net reflection Object Browser, which is used to control the display and hiding of. net reflection Object browsers.
The browser length of the. net reflection object is as follows:
This. net reflection Object Browser allows you to browse the default assembly of the current. net Framework. You can click it one by one and finally point it to the class you want to see.
However, you can only see the source code and cannot debug it.
You also need to right-click the dll and select Enable Debugging, which means to start the dll to the debugable state. When you click this option, the plug-in will convert the dll code to a local file ,. NET Reflector first tries to locate the PDB file on the local machine. If not, it will create its own PDB file for debugging.
After you click it, an interface is displayed, which is the process of changing the current status.
This is the case after successful execution:
Click Done to close it.
Next we can start breakpoint debugging!
Select a breakpoint and debug it as you like! Both F5 and append processes are supported.
Why can't I debug some codes?
Sometimes, even if you break a breakpoint, you can find that debugging fails.
There are many possible reasons, including Conditional compilation, compiler optimization results, and target architecture. In short, you cannot debug.
Next I want to put one. Net Reflector decompilation code and an il spy decompilation code.
We can find that the two software with the same dll have different decompilation results.
Therefore, we need to have a basic concept for compilation and decompilation. It is not amazing to give you the real source code for decompilation, but to speculate on the compiled algorithm, then, the result of the reverse push is processed by the software to reach 100% close to the source code.
If there is a decompilation, there will be anti-cracking encryption.
Some code, after shell obfuscation, is very embarrassing for decompilation.
If you are interested in dll encryption, you can learn about it on your own.
In terms of decompilation, apart from il spy,. Net Reflector, JetBrains dotPeek, Telerik JustDecompile, and so on, the difference is that different decompilation codes, charges, and functions of algorithms are different.
I just demonstrated the. Net Reflector, there are many functions, here only the simplest getting started tutorial, interested please learn on your own, this is the people's site, http://www.red-gate.com/products/dotnet-development/reflector/
Author: xiaozeng
Source: http://www.cnblogs.com/1996V/p/7396913.html welcome to reprint, but any reprint must retain the complete article, in the display of the title and the original link. If you have any questions or authorization negotiation, please leave a message for me