Skip to content

Commit e69db03

Browse files
committed
fixed:example build failure
1 parent 05b5f4d commit e69db03

File tree

7 files changed

+87
-310
lines changed

7 files changed

+87
-310
lines changed

XEngine_Apps/Authorize_APPClient.sln

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Authorize_APPClient", "Auth
77
EndProject
88
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Authorize_APPLocal", "Authorize_APPLocal\Authorize_APPLocal.vcxproj", "{767151F7-230E-431B-AC6D-683F19F43C13}"
99
EndProject
10-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Authorize_ClientModule", "Authorize_ClientModule\Authorize_ClientModule.vcxproj", "{82B923A9-2F4A-4784-A245-BAA6ABF5A358}"
11-
EndProject
1210
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Authorize_CDKeyNetVer", "Authorize_CDKeyNetVer\Authorize_CDKeyNetVer.vcxproj", "{1D584651-5E93-43BA-9A48-E7D199DC587F}"
1311
EndProject
12+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Authorize_ClientModule", "Authorize_ClientModule\Authorize_ClientModule.vcxproj", "{82B923A9-2F4A-4784-A245-BAA6ABF5A358}"
13+
EndProject
1414
Global
1515
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1616
Debug|x64 = Debug|x64
@@ -35,14 +35,6 @@ Global
3535
{767151F7-230E-431B-AC6D-683F19F43C13}.Release|x64.Build.0 = Release|x64
3636
{767151F7-230E-431B-AC6D-683F19F43C13}.Release|x86.ActiveCfg = Release|Win32
3737
{767151F7-230E-431B-AC6D-683F19F43C13}.Release|x86.Build.0 = Release|Win32
38-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x64.ActiveCfg = Debug|x64
39-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x64.Build.0 = Debug|x64
40-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x86.ActiveCfg = Debug|Win32
41-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x86.Build.0 = Debug|Win32
42-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x64.ActiveCfg = Release|x64
43-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x64.Build.0 = Release|x64
44-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x86.ActiveCfg = Release|Win32
45-
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x86.Build.0 = Release|Win32
4638
{1D584651-5E93-43BA-9A48-E7D199DC587F}.Debug|x64.ActiveCfg = Debug|x64
4739
{1D584651-5E93-43BA-9A48-E7D199DC587F}.Debug|x64.Build.0 = Debug|x64
4840
{1D584651-5E93-43BA-9A48-E7D199DC587F}.Debug|x86.ActiveCfg = Debug|Win32
@@ -51,6 +43,14 @@ Global
5143
{1D584651-5E93-43BA-9A48-E7D199DC587F}.Release|x64.Build.0 = Release|x64
5244
{1D584651-5E93-43BA-9A48-E7D199DC587F}.Release|x86.ActiveCfg = Release|Win32
5345
{1D584651-5E93-43BA-9A48-E7D199DC587F}.Release|x86.Build.0 = Release|Win32
46+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x64.ActiveCfg = Debug|x64
47+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x64.Build.0 = Debug|x64
48+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x86.ActiveCfg = Debug|Win32
49+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Debug|x86.Build.0 = Debug|Win32
50+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x64.ActiveCfg = Release|x64
51+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x64.Build.0 = Release|x64
52+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x86.ActiveCfg = Release|Win32
53+
{82B923A9-2F4A-4784-A245-BAA6ABF5A358}.Release|x86.Build.0 = Release|Win32
5454
EndGlobalSection
5555
GlobalSection(SolutionProperties) = preSolution
5656
HideSolutionNode = FALSE

XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ using namespace std;
2929
#include <XEngine_Include/XEngine_Client/XClient_Error.h>
3030
#include <XEngine_Include/XEngine_Client/APIClient_Define.h>
3131
#include <XEngine_Include/XEngine_Client/APIClient_Error.h>
32+
#include "../../XEngine_Source/XEngine_DependLibrary/XEngine_Module/XEngine_Verification/Verification_Define.h"
3233
#include "../../XEngine_Source/XAuth_Protocol.h"
3334

3435
//Windows::vs2022 x86 debug 编译即可
@@ -48,7 +49,7 @@ XSOCKET m_Socket = 0;
4849
LPCXSTR lpszUser = _X("123123aa");
4950
LPCXSTR lpszPass = _X("123123");
5051
LPCXSTR lpszHWCode = _X("2FDWAD02JD2091");
51-
LPCXSTR lpszSerial = _X("XAUTH-XYRYS-JKG60-N510G-ZUFDH-54-V7I3H");
52+
LPCXSTR lpszSerial = _X("Y5V0Y-03O2L-E7G8Y-NX1DR-3EGVO-UDIRQ-GBBKO-FGX0C");
5253
LPCXSTR lpszEmail = _X("[email protected]");
5354
__int64x nPhoneNumber = 1366666666;
5455
__int64x nIDNumber = 511025111111111111;
@@ -91,7 +92,7 @@ XHTHREAD AuthClient_Thread()
9192
printf(_X("登录失败,错误:%d\n"), st_ProtocolHdr.wReserve);
9293
}
9394
}
94-
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_TIMEDOUT == st_ProtocolHdr.unOperatorCode)
95+
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_EXPIRED == st_ProtocolHdr.unOperatorCode)
9596
{
9697
bTimeOut = false;
9798
printf(_X("用户过期\n"));
@@ -258,16 +259,16 @@ int AuthClient_Login()
258259
{
259260
XCHAR tszMsgBuffer[2048];
260261
XENGINE_PROTOCOLHDR st_ProtocolHdr; //协议头
261-
AUTHORIZE_PROTOCOL_USERAUTHEX st_AuthUser;
262+
XENGINE_PROTOCOL_USERAUTHEX st_AuthUser;
262263

263264
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
264265
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
265-
memset(&st_AuthUser, '\0', sizeof(AUTHORIZE_PROTOCOL_USERAUTHEX));
266+
memset(&st_AuthUser, '\0', sizeof(XENGINE_PROTOCOL_USERAUTHEX));
266267

267268
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
268269
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
269270
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGIN;
270-
st_ProtocolHdr.unPacketSize = sizeof(AUTHORIZE_PROTOCOL_USERAUTHEX);
271+
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_USERAUTHEX);
271272
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
272273

273274
st_AuthUser.enDeviceType = ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS;
@@ -308,7 +309,7 @@ int AuthClient_Login()
308309
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
309310
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), &st_AuthUser, st_ProtocolHdr.unPacketSize);
310311

311-
nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + sizeof(AUTHORIZE_PROTOCOL_USERAUTHEX);
312+
nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_USERAUTHEX);
312313
}
313314

314315
if (!XClient_TCPSelect_SendMsg(m_Socket, tszMsgBuffer, nMsgLen))
@@ -516,40 +517,6 @@ int AuthClient_Delete()
516517
}
517518
return 0;
518519
}
519-
int AuthClient_Try()
520-
{
521-
Json::Value st_JsonRoot;
522-
Json::Value st_JsonObject;
523-
LPCXSTR lpszSerialNet = _X("cpuid:112233"); //通过此可以做临时网络验证,安全性比本地临时验证高
524-
LPCXSTR lpszUrl = _X("http://127.0.0.1:5302/auth/user/try");
525-
526-
st_JsonObject["tszVSerial"] = lpszSerialNet;
527-
st_JsonRoot["st_VERTemp"] = st_JsonObject;
528-
529-
int nMsgLen = 0;
530-
XCHAR* ptszMsgBuffer = NULL;
531-
532-
if (bEncrypto)
533-
{
534-
XCHAR tszENBuffer[2048] = {};
535-
XCHAR tszDEBuffer[2048] = {};
536-
537-
nMsgLen = st_JsonRoot.toStyledString().length();
538-
Cryption_XCrypto_Encoder(st_JsonRoot.toStyledString().c_str(), &nMsgLen, (XBYTE*)tszENBuffer, lpszPass);
539-
APIClient_Http_Request(_X("POST"), lpszUrl, tszENBuffer, NULL, &ptszMsgBuffer, &nMsgLen);
540-
541-
Cryption_XCrypto_Decoder(ptszMsgBuffer, &nMsgLen, tszDEBuffer, lpszPass);
542-
printf("AuthClient_Try:\n%s\n", tszDEBuffer);
543-
BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
544-
}
545-
else
546-
{
547-
APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), NULL, &ptszMsgBuffer, &nMsgLen);
548-
printf("AuthClient_Try:\n%s\n", ptszMsgBuffer);
549-
BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
550-
}
551-
return 0;
552-
}
553520
int main()
554521
{
555522
#ifdef _MSC_BUILD
@@ -578,7 +545,6 @@ int main()
578545

579546
std::this_thread::sleep_for(std::chrono::seconds(10));
580547
AuthClient_Delete();
581-
AuthClient_Try();
582548

583549
bRun = false;
584550
XClient_TCPSelect_Close(m_Socket);

XEngine_Apps/Authorize_APPLocal/Authorize_APPLocal.cpp

Lines changed: 28 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#pragma comment(lib,"XEngine_SystemSdk/XEngine_SystemApi")
88
#ifdef _WIN64
99
#pragma comment(lib,"../../XEngine_Source/x64/Debug/jsoncpp")
10-
#pragma comment(lib,"../../XEngine_Source/x64/Debug/AuthorizeModule_CDKey")
10+
#pragma comment(lib,"../../XEngine_Source/x64/Debug/XEngine_Verification")
1111
#else
1212
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
13-
#pragma comment(lib,"../../XEngine_Source/Debug/AuthorizeModule_CDKey")
13+
#pragma comment(lib,"../../XEngine_Source/Debug/XEngine_Verification")
1414
#endif
1515
#endif
1616
#include <stdio.h>
@@ -27,173 +27,65 @@
2727
#include <XEngine_Include/XEngine_Core/Cryption_Error.h>
2828
#include <XEngine_Include/XEngine_SystemSdk/SystemApi_Define.h>
2929
#include <XEngine_Include/XEngine_SystemSdk/SystemApi_Error.h>
30+
#include "../../XEngine_Source/XEngine_DependLibrary/XEngine_Module/XEngine_Verification/Verification_Define.h"
31+
#include "../../XEngine_Source/XEngine_DependLibrary/XEngine_Module/XEngine_Verification/Verification_Error.h"
3032
#include "../../XEngine_Source/XAuth_Protocol.h"
31-
#include "../../XEngine_Source/AuthorizeModule_CDKey/CDKey_Define.h"
32-
#include "../../XEngine_Source/AuthorizeModule_CDKey/CDKey_Error.h"
3333

3434
//需要优先配置XEngine
3535
//WINDOWS支持VS2022 x86 debug 编译调试
36-
//g++ -std=c++17 -Wall -g Authorize_APPLocal.cpp -o Authorize_APPLocal.exe -I ../../XEngine_Source/XEngine_DependLibrary/XEngine_Module/jsoncpp -L ../../XEngine_Release -lXEngine_BaseLib -lXEngine_Cryption -lXEngine_SystemApi -lAuthorizeModule_CDKey -ljsoncpp -Wl,-rpath=../../XEngine_Release
36+
//g++ -std=c++17 -Wall -g Authorize_APPLocal.cpp -o Authorize_APPLocal.exe -I ../../XEngine_Source/XEngine_DependLibrary/XEngine_Module/jsoncpp -L ../../XEngine_Release -lXEngine_BaseLib -lXEngine_Cryption -lXEngine_SystemApi -lXEngine_Verification -ljsoncpp -Wl,-rpath=../../XEngine_Release
3737

3838
XCHAR tszSerialStr[XPATH_MAX] = {};
3939
//1.创建CDKEY.或者由管理员创建.
4040
bool Authorize_APPLocal_Create(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd)
4141
{
42-
int nRet = 0;
43-
XCHAR tszENCodecBuffer[4096] = {};
44-
XCHAR tszDECodecBuffer[4096] = {};
45-
XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {};
46-
SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
42+
VERIFICATION_XAUTHKEY st_AuthLocal = {};
4743

48-
SystemApi_HardWare_GetSerial(&st_SDKSerial);
49-
//网络信息
50-
st_AuthLocal.nPort = 5302;
51-
_tcsxcpy(st_AuthLocal.tszAddr, _X("http://app.xyry.org"));
52-
//软件信息
53-
st_AuthLocal.st_AuthAppInfo.bInit = false;
54-
st_AuthLocal.st_AuthAppInfo.nExecTime = 0;
55-
_xstprintf(st_AuthLocal.st_AuthAppInfo.tszAppName, _X("XEngine_Authorize"));
56-
_xstprintf(st_AuthLocal.st_AuthAppInfo.tszAppVer, _X("V1.0.0.1"));
57-
//注册信息
58-
st_AuthLocal.st_AuthRegInfo.enHWType = ENUM_AUTHORIZE_MODULE_HW_TYPE_BIOS;
59-
st_AuthLocal.st_AuthRegInfo.enRegType = ENUM_AUTHORIZE_MODULE_CDKEY_TYPE_TRY;
60-
st_AuthLocal.st_AuthRegInfo.enSerialType = ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME;
61-
st_AuthLocal.st_AuthRegInfo.enVModeType = ENUM_AUTHORIZE_MODULE_VERMODE_TYPE_LOCAL;
62-
st_AuthLocal.st_AuthRegInfo.nHasTime = 0;
63-
BaseLib_Time_TimeToStr(st_AuthLocal.st_AuthRegInfo.tszCreateTime);
64-
_tcsxcpy(st_AuthLocal.st_AuthRegInfo.tszHardware, st_SDKSerial.tszBoardSerial);
65-
_xstprintf(st_AuthLocal.st_AuthRegInfo.tszLeftTime, _X("0")); //0次试用
66-
//序列号信息.可以不写,如果不想启用用户自己注册.或者交给管理员填充
67-
int nSerialCount = 3;
68-
XCHAR** pptszSerialList;
69-
Authorize_Serial_Create(&pptszSerialList, _X("XAUTH"), nSerialCount, 9);
70-
_tcsxcpy(tszSerialStr, pptszSerialList[0]);
71-
72-
st_AuthLocal.st_AuthSerial.st_TimeLimit.nTimeCount = 5;
73-
_tcsxcpy(st_AuthLocal.st_AuthSerial.st_TimeLimit.tszTimeSerial, pptszSerialList[0]);
74-
75-
st_AuthLocal.st_AuthSerial.st_DataLimit.bTimeAdd = false;
76-
_tcsxcpy(st_AuthLocal.st_AuthSerial.st_DataLimit.tszDataSerial, pptszSerialList[1]);
77-
XCHAR tszTimeStr[128] = {};
78-
XENGINE_LIBTIME st_LibTime = {};
79-
BaseLib_Time_GetSysTime(&st_LibTime);
80-
st_LibTime.wYear += 1; //一年后过期
81-
BaseLib_Time_TimeToStr(tszTimeStr, NULL, true, &st_LibTime);
82-
83-
_tcsxcpy(st_AuthLocal.st_AuthSerial.st_DataLimit.tszDataTime, tszTimeStr);
84-
85-
_tcsxcpy(st_AuthLocal.st_AuthSerial.st_UNLimit.tszUNLimitSerial, pptszSerialList[2]);
86-
//用户信息
87-
_xstprintf(st_AuthLocal.st_AuthUserInfo.tszUserName, _X("qyt"));
88-
_xstprintf(st_AuthLocal.st_AuthUserInfo.tszUserContact, _X("[email protected]"));
89-
90-
Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal);
91-
Cryption_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd);
92-
FILE* pSt_File = _xtfopen(lpszKeyFile, _X("wb"));
93-
if (NULL == pSt_File)
44+
if (!Verification_XAuthKey_KeyInit(&st_AuthLocal))
9445
{
95-
printf("create key file is failed\n");
46+
printf("Verification_XAuthKey_KeyInit is failed\n");
9647
return false;
9748
}
98-
fwrite(tszENCodecBuffer, 1, nRet, pSt_File);
99-
fclose(pSt_File);
49+
_tcsxcpy(tszSerialStr, st_AuthLocal.st_AuthSerial.st_TimeLimit.tszTimeSerial);
50+
//用户信息
51+
_xstprintf(st_AuthLocal.st_AuthUserInfo.tszUserName, _X("qyt"));
52+
_xstprintf(st_AuthLocal.st_AuthUserInfo.tszUserContact, _X("[email protected]"));
10053

54+
Verification_XAuthKey_FileWrite(&st_AuthLocal, lpszKeyFile, lpszPasswd);
10155
return true;
10256
}
10357
//2.打开CDKEY并且授权(授权只能通过自我授权或者由管理员授权,用户不应该可以自己随意授权)
104-
bool Authorize_APPLocal_Auth(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd, LPCXSTR lpszSerialStr)
58+
bool Authorize_APPLocal_Auth(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd)
10559
{
106-
XCHAR tszENCodecBuffer[4096] = {};
107-
XCHAR tszDECodecBuffer[4096] = {};
108-
XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {};
60+
VERIFICATION_XAUTHKEY st_AuthLocal = {};
10961

110-
FILE* pSt_File = _xtfopen(lpszKeyFile, _X("rb"));
111-
if (NULL == pSt_File)
62+
if (!Verification_XAuthKey_FileRead(&st_AuthLocal, lpszKeyFile, lpszPasswd))
11263
{
113-
printf("open key file is failed\n");
64+
printf("Verification_XAuthKey_FileRead is failed\n");
11465
return false;
11566
}
116-
int nRet = fread(tszENCodecBuffer, 1, sizeof(tszENCodecBuffer), pSt_File);
117-
fclose(pSt_File);
118-
119-
Cryption_XCrypto_Decoder(tszENCodecBuffer, &nRet, tszDECodecBuffer, lpszPasswd);
120-
//printf("大小:%d,内容:\n%s\n", nRet, tszDECodecBuffer);
121-
122-
Authorize_CDKey_ReadMemory(tszDECodecBuffer, nRet, &st_AuthLocal);
123-
if (!Authorize_CDKey_UserRegister(&st_AuthLocal, lpszSerialStr))
67+
if (!Verification_XAuthKey_UserRegister(&st_AuthLocal, tszSerialStr))
12468
{
125-
printf("serila verifacation is failed,error code:%lX\n", Authorize_GetLastError());
69+
printf("serila verifacation is failed,error code:%lX\n", Verification_GetLastError());
12670
return false;
12771
}
128-
129-
memset(tszENCodecBuffer, '\0', sizeof(tszENCodecBuffer));
130-
memset(tszDECodecBuffer, '\0', sizeof(tszDECodecBuffer));
131-
Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal);
132-
Cryption_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd);
133-
pSt_File = _xtfopen(lpszKeyFile, _X("wb"));
134-
fwrite(tszENCodecBuffer, 1, nRet, pSt_File);
135-
fclose(pSt_File);
72+
Verification_XAuthKey_FileWrite(&st_AuthLocal, lpszKeyFile, lpszPasswd);
13673
return true;
13774
}
13875
//3.验证CDkey
139-
bool Authorize_APPLocal_Auth(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd)
76+
bool Authorize_APPLocal_Ver(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd)
14077
{
141-
XCHAR tszENCodecBuffer[4096] = {};
142-
XCHAR tszDECodecBuffer[4096] = {};
143-
XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {};
144-
145-
FILE* pSt_File = _xtfopen(lpszKeyFile, _X("rb"));
146-
if (NULL == pSt_File)
78+
VERIFICATION_XAUTHKEY st_AuthLocal = {};
79+
if (!Verification_XAuthKey_FileRead(&st_AuthLocal, lpszKeyFile, lpszPasswd))
14780
{
148-
printf("open key file is failed\n");
81+
printf("Verification_XAuthKey_FileRead is failed\n");
14982
return false;
15083
}
151-
int nRet = fread(tszENCodecBuffer, 1, sizeof(tszENCodecBuffer), pSt_File);
152-
fclose(pSt_File);
153-
154-
Cryption_XCrypto_Decoder(tszENCodecBuffer, &nRet, tszDECodecBuffer, lpszPasswd);
155-
//printf("大小:%d,内容:\n%s\n", nRet, tszDECodecBuffer);
156-
Authorize_CDKey_ReadMemory(tszDECodecBuffer, nRet, &st_AuthLocal);
157-
if (!Authorize_CDKey_GetLeftTimer(&st_AuthLocal))
84+
if (!Verification_XAuthKey_KeyParse(&st_AuthLocal))
15885
{
159-
//失败也需要重写CDKEY
160-
memset(tszENCodecBuffer, '\0', sizeof(tszENCodecBuffer));
161-
memset(tszDECodecBuffer, '\0', sizeof(tszDECodecBuffer));
162-
Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal);
163-
Cryption_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd);
164-
pSt_File = _xtfopen(lpszKeyFile, _X("wb"));
165-
fwrite(tszENCodecBuffer, 1, nRet, pSt_File);
166-
fclose(pSt_File);
167-
16886
printf("verifaction is failed\n");
169-
return false;
170-
}
171-
SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
172-
SystemApi_HardWare_GetSerial(&st_SDKSerial);
173-
174-
if (ENUM_AUTHORIZE_MODULE_VERMODE_TYPE_LOCAL != st_AuthLocal.st_AuthRegInfo.enVModeType)
175-
{
176-
printf("cdkey does not support local verification\n");
177-
return false;
17887
}
179-
if (ENUM_AUTHORIZE_MODULE_HW_TYPE_BIOS != st_AuthLocal.st_AuthRegInfo.enHWType)
180-
{
181-
printf("cdkey serial type is incorrect\n");
182-
return false;
183-
}
184-
if (0 != _tcsxnicmp(st_SDKSerial.tszBoardSerial, st_AuthLocal.st_AuthRegInfo.tszHardware, _tcsxlen(st_SDKSerial.tszBoardSerial)))
185-
{
186-
printf("cdkey serial verification is failed\n");
187-
return false;
188-
}
189-
190-
memset(tszENCodecBuffer, '\0', sizeof(tszENCodecBuffer));
191-
memset(tszDECodecBuffer, '\0', sizeof(tszDECodecBuffer));
192-
Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal);
193-
Cryption_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd);
194-
pSt_File = _xtfopen(lpszKeyFile, _X("wb"));
195-
fwrite(tszENCodecBuffer, 1, nRet, pSt_File);
196-
fclose(pSt_File);
88+
Verification_XAuthKey_FileWrite(&st_AuthLocal, lpszKeyFile, lpszPasswd);
19789
return true;
19890
}
19991
int main()
@@ -213,14 +105,14 @@ int main()
213105
}
214106
Authorize_APPLocal_Auth(lpszFileStr, lpszPasswd);
215107

216-
if (!Authorize_APPLocal_Auth(lpszFileStr, lpszPasswd, tszSerialStr))
108+
if (!Authorize_APPLocal_Ver(lpszFileStr, lpszPasswd))
217109
{
218110
return -1;
219111
}
220112

221113
for (int i = 0; i < 10; i++)
222114
{
223-
if (!Authorize_APPLocal_Auth(lpszFileStr, lpszPasswd))
115+
if (!Authorize_APPLocal_Ver(lpszFileStr, lpszPasswd))
224116
{
225117
break;
226118
}

0 commit comments

Comments
 (0)