Unity3d the project program encryption 2--to confuse the DLL

Source: Internet
Author: User
Tags goto


Reproduced from: http://liweizhaolili.blog.163.com/blog/static/1623074420145110502776/



Previous article Azhao has simply introduced how to write their own code into DLL dynamic link library, and then in the Unity3d inside. So the next thing seems to be very simple, we write a script in the Unity3d, to the end of the final, the core of the code to cut out the package into a DLL file and back into the project. It doesn't seem like someone else is going to be able to modify your code directly. Is that really the case? This assumes that the code we write in Unity3d is abstracted into a test class that contains both open and private variables, with the Start method, the Update method, the Ongui method, and the public, private, and protected methods. Although the abstract class represents the actual class in the project, in order to be able to see the code effect, so in the method probably wrote some simple print commands.
Put this test class in the last Class library project, and then build the DLL, put into the Unity3d project: In fact, to see the contents of the DLL, a lot of software can be, we take the Unity3d from the MonoDevelop to see. Find the DLL file referenced inside, this is AzhaoDll.dll.
You can browse directly to the contents of the DLL, to see just that test class, is not every variable, each method is a word of the lack of a display.
There is also the last written Math3d method, can also be seen directly. DLL is such an uninsured thing, so we're going to introduce the content of this article: confusing DLLs. NET, there are several kinds of code obfuscation, such as vs Dotfuscator, compact reactor, or relatively professional xeoncode. Here I use the Xeoncode 2010 version. The interface is as follows:
When you come to application, you can add DLL files:
Select the DLL you want to confuse:

Then in project you can see the classes, variables, and methods inside the DLL. See some variables and methods in front of the tick, this is the need to confuse the meaning, this can adjust their own, and then say: in output to select an output path:
Then click on the build application in the lower right corner to release the confusing DLL.
Putting the confused DLL back into the Unity3d project, you can see that there are many random numbers and letters of variable names and method names in this DLL:
Look carefully, you can see that the methods and variables have just been ticked into garbled names, then there will be some changes in the method call, in addition to the name change, the code itself will have some changes, no previous so direct display of the case of the call, if it is a complex call, will appear goto to replace. As a result, even those who write code have a hard time understanding the code. Of course, if the very heart of the variable method name to the corresponding, a goto call to find, but also can be restored, but it is estimated that few people talk this time to do this kind of thing. Here, the purpose of confusion is reached.
But now take this DLL to actually run, will find a lot of problems, such as Unity3d with the method of start, update and the like will not be executed. This is because the confusion of the time to confuse something should not be mixed.
Then let's take note of the following matters: 1, public and protected variables and methods, the default is not confusing, you can also manually put the hook, let it confused, but because these are externally called variables and methods, you confuse its name, then the external call is inevitable error. 2, like Unity3d's start, Update, Ongui and other monobehaviour methods, are specific meaning, although it is a private method, but should not be confused, or to the implementation of the time will not be implemented. 3, some names that have a specific meaning, or useful to use a string to identify variables or method names, these methods and strings should not be confused, otherwise there will be no call to the situation.

The above is a simple way to use, the specific situation may be the real use of the time will appear, so just improvise.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.