@@ -99,6 +99,7 @@ int main(int argc, char** argv)
9999 WSAStartup (MAKEWORD (2 , 2 ), &st_WSAData);
100100#endif
101101 bIsRun = true ;
102+ FILE* pSt_File = NULL ;
102103 HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
103104 THREADPOOL_PARAMENT** ppSt_ListTCPThread;
104105 THREADPOOL_PARAMENT** ppSt_ListWSThread;
@@ -315,6 +316,51 @@ int main(int argc, char** argv)
315316 XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X (" 启动服务中,信息报告给API服务器没有启用" ));
316317 }
317318 XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X (" 启动服务中,功能开关选项,删除功能:%d,登录功能:%d,找回密码:%d,充值功能:%d,注册功能:%d,CDKey功能:%d,公告系统:%d,动态验证:%d,多端登录:%d,临时试用:%d,黑名单功能:%d" ), st_FunSwitch.bSwitchDelete , st_FunSwitch.bSwitchLogin , st_FunSwitch.bSwitchPass , st_FunSwitch.bSwitchPay , st_FunSwitch.bSwitchRegister , st_FunSwitch.bSwitchCDKey , st_FunSwitch.bSwitchNotice , st_FunSwitch.bSwitchDCode , st_FunSwitch.bSwitchMulti , st_FunSwitch.bSwitchTry , st_FunSwitch.bSwitchBlack );
319+
320+ pSt_File = _xtfopen (st_AuthConfig.st_XVerification .st_XCDKey .tszKeyFile , _X (" rb" ));
321+ if (NULL == pSt_File)
322+ {
323+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X (" 启动服务中,授权文件验证失败,授权文件没有找到" ));
324+ }
325+ else
326+ {
327+ // 一个简单的示例,没有验证硬件码
328+ XCHAR tszENCodecBuffer[4096 ] = {};
329+ XCHAR tszDECodecBuffer[4096 ] = {};
330+ XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {};
331+
332+ int nRet = fread (tszENCodecBuffer, 1 , sizeof (tszENCodecBuffer), pSt_File);
333+ fclose (pSt_File);
334+
335+ if (OPenSsl_XCrypto_Decoder (tszENCodecBuffer, &nRet, tszDECodecBuffer, st_AuthConfig.st_XVerification .st_XCDKey .tszKeyPass ))
336+ {
337+ Authorize_CDKey_ReadMemory (tszDECodecBuffer, nRet, &st_AuthLocal);
338+ bool bRet = Authorize_CDKey_GetLeftTimer (&st_AuthLocal);
339+ // 无论成功失败需要重写CDKEY
340+ memset (tszENCodecBuffer, ' \0 ' , sizeof (tszENCodecBuffer));
341+ memset (tszDECodecBuffer, ' \0 ' , sizeof (tszDECodecBuffer));
342+ Authorize_CDKey_WriteMemory (tszDECodecBuffer, &nRet, &st_AuthLocal);
343+ OPenSsl_XCrypto_Encoder (tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, st_AuthConfig.st_XVerification .st_XCDKey .tszKeyPass );
344+ pSt_File = _xtfopen (st_AuthConfig.st_XVerification .st_XCDKey .tszKeyFile , _X (" wb" ));
345+ fwrite (tszENCodecBuffer, 1 , nRet, pSt_File);
346+ fclose (pSt_File);
347+ if (bRet)
348+ {
349+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X (" 启动服务中,授权文件验证成功,总可运行次数:%s,剩余可运行次数:%lld" ), st_AuthLocal.st_AuthRegInfo .tszLeftTime , st_AuthLocal.st_AuthRegInfo .nHasTime );
350+ }
351+ else
352+ {
353+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X (" 启动服务中,授权文件验证失败,总可运行次数:%s,剩余可运行次数:%lld,错误码:%lX" ), st_AuthLocal.st_AuthRegInfo .tszLeftTime , st_AuthLocal.st_AuthRegInfo .nHasTime , Authorize_GetLastError ());
354+ }
355+ }
356+ else
357+ {
358+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X (" 启动服务中,授权文件失败,解密失败,数据不正确" ));
359+ }
360+
361+ fclose (pSt_File);
362+ }
363+
318364 XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X (" 所有服务成功启动,网络验证服务运行中,XEngien版本:%s%s,发行版本次数:%d,当前运行版本:%s。。。" ), BaseLib_OperatorVer_XNumberStr (), BaseLib_OperatorVer_XTypeStr (), st_AuthConfig.st_XVer .pStl_ListVer ->size (), st_AuthConfig.st_XVer .pStl_ListVer ->front ().c_str ());
319365 while (true )
320366 {
0 commit comments