76 lines
3.5 KiB
HTML
76 lines
3.5 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<link rel="Stylesheet" type="text/css" href=
|
|
"../../default.css" />
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=utf-8" />
|
|
|
|
<title>Step 1.3: Retrieving serial number status flags</title>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Step 1.3: Retrieving serial number status flags</h1><strong>A handy function to print flags</strong>
|
|
|
|
<p>First of all, we need a handy function to transform numeric values of flags to comprehensible statuses of a serial number. Here is the code of this function:</p>
|
|
<pre class="code">#define PRINT_HELPER(state, flag) if (state & flag) printf("%s ", #flag)
|
|
void print_state(INT state)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
printf("state = 0\n");
|
|
return;
|
|
}
|
|
|
|
printf("state = ");
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_CORRUPTED);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_INVALID);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_BLACKLISTED);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_DATE_EXPIRED);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_RUNNING_TIME_OVER);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_BAD_HWID);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED);
|
|
printf("\n");
|
|
}
|
|
</pre>
|
|
|
|
<p>Despite the size, function is really simple - checks all bit flags one by one and print all that are present in the status variable. Replace
|
|
<strong>printf</strong> in the code after checking the serial number to the call to
|
|
<strong>print_state</strong>, and make changes to the serial number we pass to the licensing system:</p>
|
|
<pre class="code">char *serial = "Xserialnumber1"; // we set the serial number directly in the code, for simplicity
|
|
int res = VMProtectSetSerialNumber(serial);
|
|
print_state(res);
|
|
</pre>
|
|
|
|
<p>Now, if we run this program, the following message will be printed to the console:</p>
|
|
<pre class="code">state = SERIAL_STATE_FLAG_INVALID
|
|
please register!
|
|
</pre>
|
|
|
|
<p>Now, we put the old key back by removing "1" and run the program again:</p>
|
|
<pre class="code">state = 0
|
|
We are registered.
|
|
</pre>
|
|
|
|
<p>Now, as we can see status flags of a serial number, let's move to retrieving flags and data from a serial number.</p><strong>Retrieving serial number status</strong>
|
|
|
|
<p>You can get the status of a serial number in three ways: by calling
|
|
<strong>VMProtectSetSerialNumber()</strong>, by calling
|
|
<strong>VMProtectGetSerialNumberState()</strong> or by calling
|
|
<strong>VMProtectGetSerialNumberData()</strong> - status flags are put into one of fields of the structure. Each method is intended to use in specific time. The first check of the serial number is performed during installation. At this moment you should decline incorrect numbers, expired numbers, numbers in the black list and so on. Some limitations, for example, the maximum operation time of the program or serial number expiration date should also be checked in run-time. And the <strong>VMProtectGetSerialNumberState()</strong> method is the fastest and the most convenient way here. And if you need to receive complete information about the serial number, you can use the more powerful
|
|
<strong>VMProtectGetSerialNumberData()</strong> function.</p><br />
|
|
<a href="step14_name.htm">Next step</a>
|
|
<br />
|
|
<br />
|
|
<br />
|
|
<br />
|
|
<hr noshade="noshade" size="1" />
|
|
|
|
<div align="center">
|
|
© 2006-2015 Copyright VMProtect Software
|
|
</div>
|
|
</body>
|
|
</html>
|