aboutsummaryrefslogtreecommitdiff
path: root/help/en/manager/usage/api.htm
blob: b227735cdc8e38af71d71b524b1415e944bbdb0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!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>Licensing API functions</title>
  <style type="text/css">
/*<![CDATA[*/
                th {text-align:left;}
                table {border-collapse:collapse; margin-top: 4px;}
                td,th {border: 1px solid #B0B0B0; padding-left:10;padding-right:10;}
    /*]]>*/
  </style>
</head>

<body>
  <h1>Licensing API functions</h1>

  <p>The licensing system API is an integral part of VMProtect API and its SDK. API allows you to specify a serial number and retrieve all information about it: whether it suits the program or not, is the serial number expired, the name this product is registered to and so on. Also, the API provides a hardware identifier of the computer the program runs on.</p><strong id=
  "VMProtectSetSerialNumber">VMProtectSetSerialNumber</strong>

  <p>This function loads a serial number to the licensing system. Call syntax:</p>
  <pre class="code">int VMProtectSetSerialNumber(const char *SerialNumber);
</pre>

  <p>The input <strong>SerialNumber</strong> parameter must contain a pointer to a null-terminated string ('\0') containing a base-64 encoded serial number. The function returns a bit mask of serial number status flags, the same as the one <strong>VMProtectGetSerialNumberState()</strong> returns. You can read more about flags below. The serial number is "good" if the function returned 0.</p><br />
  <strong id=
  "VMProtectGetSerialNumberState">VMProtectGetSerialNumberState</strong>

  <p>This function returns status flags for the serial number specified by a call to 
  <strong>VMProtectSetSerialNumber()</strong>.</p>
  <pre class="code">int VMProtectGetSerialNumberState();
</pre>

  <p>If at least one flag is set, there is a problem with the serial number. The program shouldn't work if at least one bit is set. The detailed description of flags and their values is listed in the table below:</p>

  <table border="1" cellspacing="0" cellpadding="2">
    <tr>
      <th>Flag</th>

      <th>Value</th>

      <th>Description</th>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_CORRUPTED</td>

      <td>0x00000001</td>

      <td>The licensing system is corrupted. Possible reasons are: incorrect setup of the protection project, cracking attempt.</td>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_INVALID</td>

      <td>0x00000002</td>

      <td>The serial number is incorrect. The flag is set if the licensing system cannot decrypt the serial number.</td>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_BLACKLISTED</td>

      <td>0x00000004</td>

      <td>The serial number matches the product, but is black listed in VMProtect.</td>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_DATE_EXPIRED</td>

      <td>0x00000008</td>

      <td>The serial number is expired. You can obtain the detailed information about the expiration date by calling 
      <strong>VMProtectGetSerialNumberData()</strong></td>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_RUNNING_TIME_OVER</td>

      <td>0x00000010</td>

      <td>Operating time of the program is depleted. You can obtain the detailed information about the operating time of the program by calling
      <strong>VMProtectGetSerialNumberData()</strong></td>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_BAD_HWID</td>

      <td>0x00000020</td>

      <td>Hardware identifier does not match the hardware identifier prescribed in the key.</td>
    </tr>

    <tr>
      <td>SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED</td>

      <td>0x00000040</td>

      <td>The serial number does not match the current version of the protected program. You can obtain the maximum build date of the program this serial number matches by calling 
      <strong>VMProtectGetSerialNumberData()</strong>.</td>
    </tr>
  </table><br /><br />
  <strong id=
  "VMProtectGetSerialNumberData">VMProtectGetSerialNumberData</strong>

  <p>This function obtains information about contents of the serial number acquired with a call to
  <strong>VMProtectSetSerialNumber()</strong>. Call syntax:</p>
  <pre class="code">bool VMProtectGetSerialNumberData(VMProtectSerialNumberData *Data, int Size);
</pre>

  <p>The first parameter is a pointer to the 
  <strong>VMProtectSerialNumberData</strong> structure, where all necessary information will be written to. The second parameter is the size of the structure passed in the first parameter. It is required to control the structure's format. The function returns FALSE if the licensing system is corrupted (see the SERIAL_STATE_FLAG_CORRUPTED flag), if a zero address of the structure is provided or if the passed size of the structure is incorrect. In all other cases, the function returns TRUE and records all information about the serial number to the provided address. Below are the elements of the structure:</p>

  <table border="1" cellspacing="0" cellpadding="2">
    <tr>
      <th>Element</th>

      <th>Type</th>

      <th>Description</th>
    </tr>

    <tr>
      <td>nState</td>

      <td>int</td>

      <td>A bit flag mask indicating the status of a key. Similar to the one returned by 
      <strong>VMProtectGetSerialNumberState()</strong>.</td>
    </tr>

    <tr>
      <td>wUserName</td>

      <td>wchar_t[256]</td>

      <td>The name of a customer in UNICODE, null-terminated.</td>
    </tr>

    <tr>
      <td>wEMail</td>

      <td>wchar_t[256]</td>

      <td>The e-Mail of a customer in UNICODE, null-terminated.</td>
    </tr>

    <tr>
      <td>dtExpire</td>

      <td>VMProtectDate</td>

      <td>The key expiration date. The format of the 
      VMProtectDate structure is described below.</td>
    </tr>

    <tr>
      <td>dtMaxBuild</td>

      <td>VMProtectDate</td>

      <td>The maximum product build date the given key can work with. The format of the VMProtectDate structure is described below.</td>
    </tr>

    <tr>
      <td>bRunningTime</td>

      <td>int</td>

      <td>The amount of minutes the program will work (maximum duration of a session). The value in minutes counts from the moment the program starts.</td>
    </tr>

    <tr>
      <td>nUserDataLength</td>

      <td>unsigned char</td>

      <td>The length of user data in the
      <strong>bUserData</strong> field.</td>
    </tr>

    <tr>
      <td>bUserData</td>

      <td>unsigned char[255]</td>

      <td>User data put into the key. The actual number of bytes is specified in 
      <strong>nUserDataLength</strong>.</td>
    </tr>
  </table><br />

  <p>The <strong>VMProtectDate</strong> structure is a compact representation of date. Its fields are listed in the table below:</p>

  <table border="1" cellspacing="0" cellpadding="2">
    <tr>
      <th>Element</th>

      <th>Type</th>

      <th>Description</th>
    </tr>

    <tr>
      <td>wYear</td>

      <td>unsigned short</td>

      <td>Year.</td>
    </tr>

    <tr>
      <td>bMonth</td>

      <td>unsigned char</td>

      <td>Month, starts from 1.</td>
    </tr>

    <tr>
      <td>bDay</td>

      <td>unsigned char</td>

      <td>Day, starts from 1.</td>
    </tr>
  </table><br />
  <br />
  <strong id=
  "VMProtectGetCurrentHWID">VMProtectGetCurrentHWID</strong>

  <p>This function obtains a hardware identifier of the PC the program is working on. Call syntax:</p>
  <pre class="code">int VMProtectGetCurrentHWID(char * HWID, int Size);
</pre>

  <p>The first parameter is a pointer to a memory area where the identifier is written to. The second parameter is the size of this area. The function returns the number of bytes written inclusive of the trailing zero byte ('\0'). If NULL is provided in the first parameter, the function returns the number of bytes required to store the hardware identifier. Here is the correct way to use the function:</p>
  <pre class="code"><strong>int</strong> nSize = <strong>VMProtectGetCurrentHWID</strong>(NULL, 0); // get the required buffer size
<strong>char *</strong>pBuf = <strong>new char</strong>[nSize]; // allocate memory for the buffer
<strong>VMProtectGetCurrentHWID</strong>(pBuf, nSize); // obtain the identifier
// use the identifier
<strong>delete</strong> [] pBuf; // release memory
</pre><br />
  <br />
  <br />
  <br />
  <br />
  <hr noshade="noshade" size="1" />

  <div align="center">
    © 2006-2015 Copyright VMProtect Software
  </div>
</body>
</html>