In the several steps described below, we will create a test application that interacts with the licensing system: it provides serial numbers, receives their status, and reads their contents. In the first stage, we use the licensing system in test mode; in the second stage, we use it as it would be in actual production.
Work modes of the licensing system
Building protection always goes through two main stages: development and release. For licensing, you first create an application, integrate protection into it, and then add checks and functional limitations. Only after thorough testing can you make the product available to users and begin the second stage. Testing a protected application is a complex process, because you need to ensure that all checks and conditional branches work correctly. Creating “real” serial numbers for all possible test cases is inconvenient. That is why the licensing system also offers a “developer mode” (also known as “test mode”). In this mode, no real protection is applied to the application, and the system’s responses to serial numbers are defined in a configuration file. When the application is free of bugs and correctly works with the licensing system, VMProtect replaces the “test” licensing module with the real one, which performs actual serial number validation. This happens during protection, so it cannot be skipped accidentally.
Stage 1: Test mode
In test mode, all responses of the licensing system (statuses and returned data) to serial numbers are described in a configuration file. The file is called “VMProtectLicense.ini” and should be located in the application’s working directory. In the 10 steps provided below, we will go from creating a simple application to full-featured use of the licensing system in test mode, including hardware locking and limiting the free upgrade period.
- Step 1.1: Creating a protected application
- Step 1.2: Adding the license checking code
- Step 1.3: Retrieving serial number status flags
- Step 1.4: Retrieving the name and the e-mail of a user
- Step 1.5: Checking the expiration date of the serial number
- Step 1.6: Limiting the operation time of the program
- Step 1.7: Limiting the free upgrades period
- Step 1.8: Serial numbers in the blacklist
- Step 1.9: Hardware lock
- Step 1.10: User data
Stage 2: Real mode
In real mode, the VMProtect licensing system embeds a special licensing module into the protected application. This module performs the same functions as the test SDK module, but works with the contents of a serial number instead of a configuration INI file. The next five steps illustrate the process of protecting a simple application with full-featured protection based on VMProtect and the licensing system.
- Step 2.1: Creating a new protected application
- Step 2.2: Creating a VMProtect protection project
- Step 2.3: First start of the protected product
- Step 2.4: Testing the results
- Step 2.5: Locking the code to a serial number
Additional information
Values of all bit flags, structure formats, and function call parameters can be found in the Licensing system API section of this help file. Use this section as a reference, while the steps above help you implement a typical ready-to-use protection.