Files
vmprotect/help/en/manager/usage/step12_code.htm
Cmake 195f02a41d dogprotect: VMProtect → DogProtect 全量改名 + VM 节名改 .dog
- 产品名/展示串、SDK 与运行时导出 API、.NET 命名空间全部换为 DogProtect
- 文件与目录改名: dogprotect.sln / DogProtect/ / DogProtectCon/ / sdk/DogProtect.SDK /
  sdk/DogProtectSDK.{h,pas,bas,inc} / runtime/DogProtect.Runtime/ / core/dogprotect.rc /
  app/dogprotect_gui.app
- 项目文件扩展名 .vmp → .dog(含 GUI 过滤器、默认输出名、示例工程、单测)
- VM 代码节名默认 .dog(上游为随机 ".xyz"),产物节为 .dog0/.dog1/...
- 授权数据与配置: DogProtect.dat / DogProtectLicense.ini / Global\\DogProtect.dat
- 域名占位 dogprotect.example,bundle id com.dogprotect.dogprotect
- 保留 VMP_* 内部宏与 third-party/
- BUILD-LINUX.md 增补改名说明与 SDK 兼容性提示
2026-11-23 16:15:28 +08:00

80 lines
3.6 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.2: Adding the license checking code</title>
</head>
<body>
<h1>Step 1.2: Adding the license checking code</h1><strong>Include DogProtect SDK</strong>
<p>If you haven't do this before, it is time to include DogProtect SDK to your project. The SDK is three files: the header file (DogProtectSDK.h), the library file (DogProtectSDK32.lib) and the dll-file with implementation (DogProtectSDK32.dll). There are individual implementations of the library and the dll-file for 64-bit systems.</p>
<p>Put the dll-file, the header file and the library file to the working folder of our application, where the source files are, and include the header file to the main file:</p>
<pre class="code">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include "DogProtectSDK.h"
</pre>
<p>Build the project and make sure it compiles and runs as before. The licensing system is inactive yet.</p><strong>Sending a serial number to the licensing system</strong>
<p>Now, right below the line with the serial number, we add a call to the SDK function of the licensing system:</p>
<pre class="code">char *serial = "Xserialnumber"; // we set the serial number directly in the code, for simplicity
int res = DogProtectSetSerialNumber(serial);
printf("res = 0x%08X\n", res);
</pre>
<p>If after you did this the program stops with an error saying the required dll-file is missing, make sure you put the corresponding DLL-file to the working folder of our application. In case of a successful execution, you should see the following message:</p>
<pre class="code">res = 0x00000002
</pre>
<p>2 corresponds to the SERIAL_STATE_FLAG_INVALID flag
<a href="api.htm">described in the API</a>. This means the licensing system thinks our key is incorrect, which is pretty true, as we didn't "explain" to the system which keys are correct, and which ones are not.</p><strong>Specifying the "correct" serial number</strong>
<p>In the test mode, the licensing system analyzes the
DogProtectLicense.ini file and reacts to function calls in accordance with the specified settings. We will thoroughly review the file on later steps, and now we simply create such a file and add the following text there:</p>
<pre class="code">[TestLicense]
AcceptedSerialNumber=Xserialnumber
</pre>
<p>Now, run our program again. If you still receive the "2" error code, make sure the ini-file is located in the working folder of the app. This time we should receive "0". That's the sign that the licensing system accepted and approved the serial number. Now we can remove the
<strong>is_registered()</strong> function from the code - the licensing system is now in charge for checking serial numbers:</p>
<pre class="code">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include "DogProtectSDK.h"
int main(int argc, char **argv)
{
char *serial = "Xserialnumber"; // we set the serial number directly in the code, for simplicity
int res = DogProtectSetSerialNumber(serial);
printf("res = 0x%08X\n", res);
if (res)
{
printf("please register!\n");
return 0;
}
printf("We are registered.\n");
return 0;
}
</pre><br />
<a href="step13_flags.htm">Next step</a>
<br />
<br />
<br />
<br />
<hr noshade="noshade" size="1" />
<div align="center">
</div>
</body>
</html>