Blame view

src/VPT/MD5/mID.cpp 2.87 KB
e30d6793   Zou XiKun   v0.0.1
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
  // mID.cpp : ???? DLL Ӧ?ó????ĵ?????????
  //
  #ifdef _MSC_VER
          #include "checkID.h"
  #else
          #include <stdlib.h>
          #include <stdio.h>
  #endif
  
  //#include "checkID.h"
  #include "mID.h"
  #include <time.h>
  #ifdef _MSC_VER
  void getMIDKeyfile()
  {
  	getid();//???ɻ?????????????ڵ?ǰĿ¼?µġ?key.nlpr??????
  }
  //-1ʧ?? 1?ɹ?
  int checkMID(unsigned short buf[8])
  {
  	//???????к?
  	if(checkid2(buf) != 0)
  	{
  		printf("Software license is incorrect! Please contact software developers.\n");
  		return -1;
  	}
  	else
  	{
  		printf("Software license has been detected.\n");
  		return 1;
  	}
  }
  
  //????ID 1???ɹ? -1??ʧ??
  int checkMIDbyKeyfile(const char * keyname)
  {
  	Key key;
  	FILE* fp = NULL;
  	fp = fopen(keyname, "rb");
  	if (!fp)
  	{
  		printf("Software license hasn't been detected! Please contact software developers.\n");
  		return -1;
  	}
  	fread(&key,sizeof(struct Key), 1, fp);
  	fclose(fp);
  	return checkMID(key.id);
  }
  
  
  //??keyfileתΪ??????
  void convertMID(const char * keyname)
  {
  	Key key;
  	FILE* fp = NULL;
  	fp = fopen(keyname, "rb");
  	if (!fp)
  	{
  		printf("Software license hasn't been detected! Please contact software developers.\n");
  		return;
  	}
  	fread(&key,sizeof(struct Key), 1, fp);
  	fclose(fp);
  
  	fstream fout;
  	fout.open("key.txt", ios::app);
  	for (int i = 0; i < 8; i++)
  	{
  		fout<<key.id[i]<<" ";
  	}
  
  
  	printf("key.nlpr convert to key.txt, finished.\n");
  	fout.close();
  	return;
  
  }
  const int keySetsize = 11;
  static unsigned short keySet[keySetsize][8] = {
  	{ 60280, 29123, 64972, 28608, 42326, 43010, 17034, 9842 },//me
  	{ 54610, 49296, 17300, 1983, 42201, 25658, 27899, 15918 },
  	{ 51921, 64665, 60699, 6297, 37277, 4362, 7441, 17980 },		//serverkey
  	{ 54403, 43908, 15062, 37979, 57014, 28987, 56456, 56066 },//kasunkey
  	{ 28537, 34734, 3114, 915, 54880, 7310, 10766, 27417 },//boyunkey
  	{ 11890, 53417, 16475, 24791, 13011, 52249, 17680, 27091 },		//udeepakey
  	{ 3171, 32275, 64786, 50734, 44271, 48479, 4756, 58717 },//key_win7descktop_boyun
  	{ 18028, 23776, 43617, 63275, 46751, 6676, 43704, 44873 },//key_win7server
  	{ 5806, 55060, 56104, 44332, 16887, 50392, 33885, 29295 },//key_workstation_test
  	{ 43875, 40104, 629, 48720, 45312, 39621, 16828, 64614 },//key_workstation_udeepa
  	{21008, 18966, 38940, 35542, 48605, 27361, 60074, 24005 }//new_server
  }; 
  
  //????ID 1???ɹ? 0??ʧ??
  int checkMIDkeySet()
  {
  	for (int i = 0; i < keySetsize; i++)
  	{
  		if(checkid2(keySet[i]) == 0)
  		{
  			printf("Software license has been detected.\n");
  			return 1;
  		}
  	}
  	printf("Software license is incorrect! Please contact software developers.\n");
  	exit(0);
  	return -1;
  }
  #endif
  int checkTime()
  {
  	struct tm* info;
  	int nYear, nMonth, nDay;
  	time_t raw;
  	time(&raw);
  	info = localtime(&raw);
  	nYear = info->tm_year + 1900;
  	nMonth = info->tm_mon + 1;
  	nDay = info->tm_mday;
  	if(nYear == 2019 && nMonth < 7)
  		return 1;
  	printf("Software license is out of time! Please contact software developers.\n");
  	//exit(0);
  	return -1;
  }