Convert w p code to hybrid

Source: Internet
Author: User

Preface

Since the launch of. NET Framework, it has been widely used and welcomed. I believe you have heard of native code and managed code. Applications executed in. Net CLR EnvironmentProgramAll belong to the scope of managed code, while managed code will first be compiled into msil (Microsoft intermediate language) during compilation, and the actual execution will be handed over to JIT (just-in-time) compile the code into a machine code and execute it. Due to architecture changes, msil (that is, our.. Net EXE, DLL files, etc.) are relatively easy to interpret, so there is a obfuscator, used to reduce the post-Interpretation ProgramCodeTo protect our applications, such as readability, obfuscation processes, and variable renaming. This article describes how to use obfuscators to protect your Windows Phone 7 applications.

Agenda
    • Obtain Software
    • Why use obfuscators?
    • Start to use
    • Test applications generated by obfuscators
Obtain Software

First, to protect our applications, you must first obtain the software. Preemptive solutions works with Microsoft to release a free version that allows you to protect your WP7 applications, how can we get it? First, go to the application location

Http://www.preemptive.com/windowsphone7.html

Then you will see the request Download button on the right, as shown in the following figure:

After clicking this button, you will be taken to the application page, where you need to enter your personal information.

Pay special attention to the fact that the serial number and download location of your software will be sent to your personal mailbox via email. Therefore, pay special attention to the correctness when entering the email field; enter WP7 in the remarks field, indicating that you want to apply for use in the Windows Phone 7 Application.

After the data is filled in and sent out, you will receive an email containing the software download location and installation serial number in about one working day. The content is similar

Then you can download and install the software. If you want to use intelligence-related functions, you can reply to this email, and provide the software serial number you have installed to him, and then reply to your intelligence startup serial number, the software serial number can be seen in the "Help \ about" figure after installation.

Why use obfuscators?

You may wonder why obfuscators are used? It is still unclear about the functions and main functions of the obfuscator. The following is a simple example. For example, in the example program of the former burshdemoSource codeYes.

In the case of a program code file (exe or DLL) that has not been compiled by the obfuscator, The result displayed after the anti-group translation will look like this

You will find that the process is almost complete and simple. Therefore, you must use obfuscators to make the event difficult, this is also the purpose of the obfuscator.

Start to use

The software installation process is quite simple and I will not go into details here. After the installation is complete, you will see the following items in the menu:

Here, the PDF file (userguide) is the description file, and the other is the main program we want to use. After the execution, the first screen will show the screen for opening the project or creating a new project.

In this screen, you choose to create a new project or open a previously used project. This is because there are many settings in dotfuscator that allow you to set and adjust the project, A project is used to store these settings and corresponding Visual Studio projects.

Next, you need to set the reference position for using the component. This setting is located on the setting page. You can refer to the addition method; here, the reference component is set to enable dotfuscator to analyze the type, used component, and other related information in the program code.

The reference positions of components to be added are different according to the operating system and

    • X64

      C: \ Program Files (x86) \ reference assemblies \ Microsoft \ framework \ Silverlight \ v4.0 \ profile \ windowsphone

    • X86

      C: \ Program Files \ reference assemblies \ Microsoft \ framework \ Silverlight \ v4.0 \ profile \ windowsphone

The second step is to add the project to be obfuscated. This setting is on the input page, for example

In this case, you can specify the xap file generated after compilation. After the file is specified, other configuration items are displayed. Go back to the setting page first, first, let's see where the files compiled by the obfuscators are stored? This can be set in build setting. For example, in this case, the directory is set to D: \ WP7.The original setting of this part is "$ {configdir} \ dotfuscated". You can also keep this setting, this setting means that the files compiled by the obfuscator will be placed in the same location as your xml configuration file., This part can be set according to your preferences.

By now, the basic environment settings have been completed, and you need to adjust some settings. these settings are in the Global Options Project, in global option, you can set that dotfuscator functions are enabled or disabled. Here, we disable renaming and control flow projects (according to the preset settings, these two projects are enabled. For example

So Why disable the renaming project function? This is because in an application, you may customize a category to store various types of data. For example, you have created a book category, where attributes such as title and publication date may exist, probably like this

 
Public String title {get {return _ title;} set {_ Title = value;} Public String pubdate {get {return _ pubdate;} set {_ pubdate = value ;}}

In XAML, the data binding function is used for display, for example



  
  
  1. <Textblock verticalalignment = "center" grid. column = "1" margin = "5, 0, 0" grid. row = "1" fontsize = "32" textwrapping = "Wrap" text = "{binding Path = title}"/>
  2. <Textblock verticalalignment = "center" grid. column = "1" margin = "5, 0, 0" grid. row = "1" fontsize = "32" textwrapping = "Wrap" text = "{binding Path = pubdate}"/>

However, the renaming function in the obfuscator will rename the variables and methods, which may not correspond to each other. Therefore, application errors may occur, pay special attention to this part.

The control flow part is to add some program code that obfuscated the program process and architecture to the program code. At this stage, we do not want dotfuscator to do this, so it is also set to disabled.

After the setting is complete, you can press the build project button to create a project. For the button location, see

If there is no accident after the build, a message is displayed in the description window below, for example

Then a new xap file will be generated at the location you specified. What is the difference after obfuscator compilation? Let's take a look at the differences between previous button events.

You can see that part of the program code is not directly visible, isn't it great? Just a few simple steps to protect our applications. This is also the simplest setup method. What if I want to use some other settings? I will give a brief introduction. Here we will use the string encryption section as an example. For example, a string variable is declared in the book category, which is like the following:

 
Namespace dotobfuscatordemo {public class book {Public String title {Get; set;} Public String pubdate {Get; set;} Public String author {Get; set;} Public String temp; public book () {temp = "12345 ";}}}

In the absence of obfuscator compilation, the result of anti-group translation will look like this

The string is directly displayed. If you do not want the string to be seen in such an obvious way, you can use the obfuscator for encryption. What should you do? First, enable the character string encryption part in settings.

Then set the affected scope. Here, the author only sets the book category, for example, the following:

Next, you can re-compile the xap file in the obfuscator. What will the newly generated xap look like if it passes through reverse group translation?

You can see that the string is not directly displayed, and a function named "B" is applied. The content of "B" is

This will protect your strings from being seen so easily. obfuscators will make this action complex and hard to understand, but at the same time they will sacrifice some performance. You can refer to the user guide instructions to learn about other settings.

Test applications generated by obfuscators

How should we test the xap file generated by the obfuscators? We can use the subordinate tool to directly upload the archive to the simulator or device for testing. The tool's position can be seen in the menu as follows:

The following interface is displayed after execution.

With this tool, you can perform subordinate actions. After successful subordinates, you can test your applications on the device or on the simulator.

Conclusion

Obfuscators are mainly used to make it difficult to interpret (Anti-group translation) actions, and thus effectively help us protect our applications, but they are not a panacea, sensitive data is not directly written in the program code. It is also necessary to use an encrypted method to save the data. However, it is important to use obfuscators for compilation,Be sure to go through a complete test againAfter obfuscators are compiled, the logic or data of some programs will be changed according to different settings. Is it difficult to guarantee that some functions may not work properly, remember to verify the correctness of the program.

 

Source Address: http://msdn.microsoft.com/zh-cn/windowsphone/gg491391.aspx

Preface

Since. net Framework has been widely used and welcomed since its launch. I believe you have heard of native code and managed code. applications in the. net clr environment are all within the scope of the managed code, and the managed code is first compiled into msil (Microsoft intermediate language) during compilation ), in actual execution, it is executed after JIT (just-in-time) is compiled into machine code. Due to architecture changes, msil (that is, our.. Net EXE, DLL files, etc.) are easy to interpret. Therefore, obfuscators are used to reduce the readability, obfuscation process, and variable Rename of the program code after interpretation, this article describes how to use obfuscators to protect your Windows Phone 7 applications.

Agenda
    • Obtain Software
    • Why use obfuscators?
    • Start to use
    • Test applications generated by obfuscators
Obtain Software

First, to protect our applications, you must first obtain the software. Preemptive solutions works with Microsoft to release a free version that allows you to protect your WP7 applications, how can we get it? First, go to the application location

Http://www.preemptive.com/windowsphone7.html

Then you will see the request Download button on the right, as shown in the following figure:

After clicking this button, you will be taken to the application page, where you need to enter your personal information.

Pay special attention to the fact that the serial number and download location of your software will be sent to your personal mailbox via email. Therefore, pay special attention to the correctness when entering the email field; enter WP7 in the remarks field, indicating that you want to apply for use in the Windows Phone 7 Application.

After the data is filled in and sent out, you will receive an email containing the software download location and installation serial number in about one working day. The content is similar

Then you can download and install the software. If you want to use intelligence-related functions, you can reply to this email, and provide the software serial number you have installed to him, and then reply to your intelligence startup serial number, the software serial number can be seen in the "Help \ about" figure after installation.

Why use obfuscators?

You may wonder why obfuscators are used? It is still unclear about the functions and main functions of the obfuscator. The following is a simple example. For example, from the example program of the previous author burshdemo, the source code pressed by the btnradialgradient button is as follows:

In the case of a program code file (exe or DLL) that has not been compiled by the obfuscator, The result displayed after the anti-group translation will look like this

You will find that the process is almost complete and simple. Therefore, you must use obfuscators to make the event difficult, this is also the purpose of the obfuscator.

Start to use

The software installation process is quite simple and I will not go into details here. After the installation is complete, you will see the following items in the menu:

Here, the PDF file (userguide) is the description file, and the other is the main program we want to use. After the execution, the first screen will show the screen for opening the project or creating a new project.

In this screen, you choose to create a new project or open a previously used project. This is because there are many settings in dotfuscator that allow you to set and adjust the project, A project is used to store these settings and corresponding Visual Studio projects.

Next, you need to set the reference position for using the component. This setting is located on the setting page. You can refer to the addition method; here, the reference component is set to enable dotfuscator to analyze the type, used component, and other related information in the program code.

The reference positions of components to be added are different according to the operating system and

    • X64

      C: \ Program Files (x86) \ reference assemblies \ Microsoft \ framework \ Silverlight \ v4.0 \ profile \ windowsphone

    • X86

      C: \ Program Files \ reference assemblies \ Microsoft \ framework \ Silverlight \ v4.0 \ profile \ windowsphone

The second step is to add the project to be obfuscated. This setting is on the input page, for example

In this case, you can specify the xap file generated after compilation. After the file is specified, other configuration items are displayed. Go back to the setting page first, first, let's see where the files compiled by the obfuscators are stored? This can be set in build setting. For example, in this case, the directory is set to D: \ WP7.The original setting of this part is "$ {configdir} \ dotfuscated". You can also keep this setting, this setting means that the files compiled by the obfuscator will be placed in the same location as your xml configuration file., This part can be set according to your preferences.

By now, the basic environment settings have been completed, and you need to adjust some settings. these settings are in the Global Options Project, in global option, you can set that dotfuscator functions are enabled or disabled. Here, we disable renaming and control flow projects (according to the preset settings, these two projects are enabled. For example

So Why disable the renaming project function? This is because in an application, you may customize a category to store various types of data. For example, you have created a book category, where attributes such as title and publication date may exist, probably like this

 
Public String title {get {return _ title;} set {_ Title = value;} Public String pubdate {get {return _ pubdate;} set {_ pubdate = value ;}}

In XAML, the data binding function is used for display, for example



  
  
  1. <Textblock verticalalignment = "center" grid. column = "1" margin = "5, 0, 0" grid. row = "1" fontsize = "32" textwrapping = "Wrap" text = "{binding Path = title}"/>
  2. <Textblock verticalalignment = "center" grid. column = "1" margin = "5, 0, 0" grid. row = "1" fontsize = "32" textwrapping = "Wrap" text = "{binding Path = pubdate}"/>

However, the renaming function in the obfuscator will rename the variables and methods, which may not correspond to each other. Therefore, application errors may occur, pay special attention to this part.

The control flow part is to add some program code that obfuscated the program process and architecture to the program code. At this stage, we do not want dotfuscator to do this, so it is also set to disabled.

After the setting is complete, you can press the build project button to create a project. For the button location, see

If there is no accident after the build, a message is displayed in the description window below, for example

Then a new xap file will be generated at the location you specified. What is the difference after obfuscator compilation? Let's take a look at the differences between previous button events.

You can see that part of the program code is not directly visible, isn't it great? Just a few simple steps to protect our applications. This is also the simplest setup method. What if I want to use some other settings? I will give a brief introduction. Here we will use the string encryption section as an example. For example, a string variable is declared in the book category, which is like the following:

 
Namespace dotobfuscatordemo {public class book {Public String title {Get; set;} Public String pubdate {Get; set;} Public String author {Get; set;} Public String temp; public book () {temp = "12345 ";}}}

In the absence of obfuscator compilation, the result of anti-group translation will look like this

The string is directly displayed. If you do not want the string to be seen in such an obvious way, you can use the obfuscator for encryption. What should you do? First, enable the character string encryption part in settings.

Then set the affected scope. Here, the author only sets the book category, for example, the following:

Next, you can re-compile the xap file in the obfuscator. What will the newly generated xap look like if it passes through reverse group translation?

You can see that the string is not directly displayed, and a function named "B" is applied. The content of "B" is

This will protect your strings from being seen so easily. obfuscators will make this action complex and hard to understand, but at the same time they will sacrifice some performance. You can refer to the user guide instructions to learn about other settings.

Test applications generated by obfuscators

How should we test the xap file generated by the obfuscators? We can use the subordinate tool to directly upload the archive to the simulator or device for testing. The tool's position can be seen in the menu as follows:

The following interface is displayed after execution.

With this tool, you can perform subordinate actions. After successful subordinates, you can test your applications on the device or on the simulator.

Conclusion

Obfuscators are mainly used to make it difficult to interpret (Anti-group translation) actions, and thus effectively help us protect our applications, but they are not a panacea, sensitive data is not directly written in the program code. It is also necessary to use an encrypted method to save the data. However, it is important to use obfuscators for compilation,Be sure to go through a complete test againAfter obfuscators are compiled, the logic or data of some programs will be changed according to different settings. Is it difficult to guarantee that some functions may not work properly, remember to verify the correctness of the program.

 

Source Address: http://msdn.microsoft.com/zh-cn/windowsphone/gg491391.aspx

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.