与 dogprotect / linux-build 分支同一次改名,等价内容:
- 产品名/展示串、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;VM 代码节名默认 .dog(产物节 .dog0/.dog1/...)
- 授权数据/配置: DogProtect.dat、DogProtectLicense.ini、Global\\DogProtect.dat
- 域名占位 dogprotect.example、bundle id com.dogprotect.dogprotect
- 保留 VMP_* 内部宏与 third-party/
99 lines
3.2 KiB
HTML
99 lines
3.2 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 2.1: Creating a new protected application</title>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Step 2.1: Creating a new protected application</h1>
|
|
|
|
<p>At the first stage we made several simple apps to test the API of the licensing system. Now, on the second stage we'll create just one application. It will also be a console app with the <strong>foo()</strong> function working only in the registered version. Here is the code of our test application:</p>
|
|
<pre class="code">#include <windows.h>
|
|
#include <stdio.h>
|
|
#include "DogProtectSDK.h"
|
|
|
|
#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");
|
|
}
|
|
|
|
char *read_serial(const char *fname)
|
|
{
|
|
FILE *f;
|
|
if (0 != fopen_s(&f, fname, "rb")) return NULL;
|
|
fseek(f, 0, SEEK_END);
|
|
int s = ftell(f);
|
|
fseek(f, 0, SEEK_SET);
|
|
char *buf = new char[s + 1];
|
|
fread(buf, s, 1, f);
|
|
buf[s] = 0;
|
|
fclose(f);
|
|
return buf;
|
|
}
|
|
|
|
// The foo() method is very short, but we need it to be an individual function
|
|
// so we asked the compiler to not compile it inline
|
|
__declspec(noinline) void foo()
|
|
{
|
|
printf("I'm foo!\n");
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
char *serial = read_serial("serial.txt");
|
|
int res = DogProtectSetSerialNumber(serial);
|
|
delete [] serial;
|
|
if (res)
|
|
{
|
|
printf("serial number is bad\n");
|
|
print_state(res);
|
|
return 0;
|
|
}
|
|
printf("serial number is correct, calling foo()\n");
|
|
foo();
|
|
printf("done\n");
|
|
return 0;
|
|
}
|
|
</pre>
|
|
|
|
<p>Compile the program without the debug information, but in the linker settings we enable creating of the MAP-file - we will need it to work with DogProtect. After we run the program, we should see the following text:</p>
|
|
<pre class="code">serial number is bad
|
|
state = SERIAL_STATE_FLAG_INVALID
|
|
</pre>
|
|
|
|
<p>Currently, the licensing system still works in the test mode, because the file wasn't processed by DogProtect and doesn't contain a licensing module in it. On the <a href=
|
|
"step22_vmp.htm">next step</a> we will create a DogProtect project and will try to protect our application.</p><br />
|
|
<br />
|
|
<br />
|
|
<br />
|
|
<br />
|
|
<hr noshade="noshade" size="1" />
|
|
|
|
<div align="center">
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|