How it works
When VMProtect protects an application, it records the build date. The licensing system treats this date as the build date of the application. You can include a maximum build date in a serial number that defines up to which build this serial number is valid. Therefore, if you set the current date plus one year in the serial number, it will work with all versions of your program released within that year. A version released one year and one day later will not work with this serial number, and the user will have a choice: use an older version of the program or purchase a new key to work with the latest version for another year.
Let’s try it
Put a line formatted as MaxBuildDate=YYYYMMDD into the INI file:
MaxBuildDate=20000101
In test mode, the licensing system treats today as the build date, so it is important that the date specified in this line is already in the past. That is, the maximum date should be yesterday. Modify the code of the main() function so that it looks like this:
int main(int argc, char **argv)
{
char *serial = "Xserialnumber"; // we set the serial number directly in the code for simplicity
int res = VMProtectSetSerialNumber(serial);
print_state(res);
if (res)
{
VMProtectSerialNumberData sd = {0};
VMProtectGetSerialNumberData(&sd, sizeof(sd));
printf("max. build date: y = %d, m = %d, d = %d\n",
sd.dtMaxBuild.wYear,
sd.dtMaxBuild.bMonth,
sd.dtMaxBuild.bDay);
printf("please register!\n");
return 0;
}
printf("I'm registered\n");
return 0;
}
Then, upon running the program, you should see the following:
state = SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED
max. build date: y = 2000, m = 1, d = 1
please register!
By replacing the date in the INI file with today or tomorrow, we get a “working” program:
state = 0
I'm registered
Remove the MaxBuildDate=… line from the INI file so it does not affect further steps.