Home » Support » User Manual » Licensing system » Integrating to application » Step 1.10: User data

Step 1.10: User data

A serial number can hold up to 255 bytes of arbitrary data that the licensing system passes to the program as they are. The data can hold any additional information about the sale, data required for operation of the full version or something else. Let’s modify our main() function so that it would read data from a serial number and display them on the screen:

int main(int argc, char **argv)
        char *serial = "Xserialnumber";
        int res = VMProtectSetSerialNumber(serial);
        if (res) return 0;

        VMProtectSerialNumberData sd = {0};
        VMProtectGetSerialNumberData(&sd, sizeof(sd));
        printf("Serial number has %d byte(s) of data\n", sd.nUserDataLength);
        for (int i = 0; i < sd.nUserDataLength; i++)
                printf("%02X ", sd.bUserData[i]);
        return 0;

We also reduce the Ini-file to this:


Now, we run the program and make sure our serial number works well, but doesn’t contain any data:

state = 0
Serial number has 0 byte(s) of data

To add new user data into the serial number, we need to create the UserData variable in the ini-file and assign data to it in the HEX format. Symbols must go in pairs, that is the length of a line must be a multiple of 2. Like this:


In this case, if we runthe program we will receive the following result:

state = 0
Serial number has 8 byte(s) of data
01 02 03 A0 B0 C0 D0 E0