@@ -47,8 +47,8 @@ bool CVerification_XAuthKey::Verification_XAuthKey_FileRead(VERIFICATION_XAUTHKE
4747{
4848 Verification_IsErrorOccur = false ;
4949
50- XCHAR tszDECodecBuffer[XPATH_MAX ] = {};
51- XCHAR tszENCodecBuffer[XPATH_MAX ] = {};
50+ XCHAR tszDECodecBuffer[4096 ] = {};
51+ XCHAR tszENCodecBuffer[4096 ] = {};
5252
5353 FILE* pSt_File = _xtfopen (lpszKeyFile, _X (" rb" ));
5454 if (NULL == pSt_File)
@@ -83,6 +83,7 @@ bool CVerification_XAuthKey::Verification_XAuthKey_FileRead(VERIFICATION_XAUTHKE
8383 return false ;
8484 }
8585 }
86+ BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime );
8687 return true ;
8788}
8889/* *******************************************************************
@@ -113,8 +114,8 @@ bool CVerification_XAuthKey::Verification_XAuthKey_FileWrite(VERIFICATION_XAUTHK
113114 Verification_IsErrorOccur = false ;
114115
115116 int nSize = 0 ;
116- XCHAR tszDECodecBuffer[XPATH_MAX ] = {};
117- XCHAR tszENCodecBuffer[XPATH_MAX ] = {};
117+ XCHAR tszDECodecBuffer[4096 ] = {};
118+ XCHAR tszENCodecBuffer[4096 ] = {};
118119
119120 // 更新使用时间
120121 if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_SECOND == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
@@ -187,11 +188,8 @@ bool CVerification_XAuthKey::Verification_XAuthKey_KeyParse(VERIFICATION_XAUTHKE
187188 }
188189 // ////////////////////////////////////////////////////////////////////////验证
189190 // 验证CDKEY本身情况
190- XENGINE_LIBTIME st_StartTimer = {};
191191 XENGINE_LIBTIME st_EndTimer = {};
192192 XENGINE_LIBTIME st_SysTimer = {};
193-
194- BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime );
195193 // 处理注册类型
196194 if (ENUM_AUTHORIZE_MODULE_CDKEY_TYPE_UNLIMIT == pSt_XAuthInfo->st_AuthRegInfo .enRegType )
197195 {
@@ -221,24 +219,24 @@ bool CVerification_XAuthKey::Verification_XAuthKey_KeyParse(VERIFICATION_XAUTHKE
221219 // 计算超时时间
222220 if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_DAY == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
223221 {
224- XENGINE_LIBTIME st_EndTimer;
225- XENGINE_LIBTIME st_StartTime;
226-
227- memset (&st_EndTimer, ' \0 ' , sizeof (XENGINE_LIBTIME));
228- memset (&st_StartTime, ' \0 ' , sizeof (XENGINE_LIBTIME));
229-
230- BaseLib_Time_GetSysTime (&st_EndTimer);
231- BaseLib_Time_StrToTime (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime , &st_StartTime);
232- if ((st_EndTimer.wYear != st_StartTime.wYear ) || (st_EndTimer.wMonth != st_StartTime.wMonth ) || (st_EndTimer.wDay != st_StartTime.wDay ))
222+ BaseLib_Time_GetSysTime (&st_SysTimer);
223+ BaseLib_Time_StrToTime (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime , &st_EndTimer);
224+ if ((st_EndTimer.wYear != st_SysTimer.wYear ) || (st_EndTimer.wMonth != st_SysTimer.wMonth ) || (st_EndTimer.wDay != st_SysTimer.wDay ))
233225 {
234226 pSt_XAuthInfo->st_AuthRegInfo .nHasTime --;
235227 }
236- BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime );
237228 }
238229 else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_SECOND == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
239230 {
240- memset (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime , ' \0 ' , sizeof (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime ));
241- BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime );
231+ XCHAR tszTimeEnd[64 ] = {};
232+ __int64x nUsedTime = 0 ;
233+
234+ BaseLib_Time_TimeToStr (tszTimeEnd);
235+ BaseLib_TimeSpan_GetForStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime , tszTimeEnd, &nUsedTime, ENUM_XENGINE_BASELIB_TIME_TYPE_SECOND);
236+ if (nUsedTime <= 0 )
237+ {
238+ pSt_XAuthInfo->st_AuthRegInfo .nHasTime = nUsedTime;
239+ }
242240 }
243241 else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
244242 {
@@ -290,6 +288,152 @@ bool CVerification_XAuthKey::Verification_XAuthKey_KeyParse(VERIFICATION_XAUTHKE
290288 return true ;
291289}
292290/* *******************************************************************
291+ 函数名称:Verification_XAuthKey_KeyInit
292+ 函数功能:KEY结构初始化
293+ 参数.一:pSt_XAuthInfo
294+ In/Out:In/Out
295+ 类型:数据结构指针
296+ 可空:N
297+ 意思:输出初始化后的结构信息
298+ 返回值
299+ 类型:逻辑型
300+ 意思:是否成功
301+ 备注:
302+ *********************************************************************/
303+ bool CVerification_XAuthKey::Verification_XAuthKey_KeyInit (VERIFICATION_XAUTHKEY* pSt_XAuthInfo)
304+ {
305+ Verification_IsErrorOccur = false ;
306+
307+ if (NULL == pSt_XAuthInfo)
308+ {
309+ Verification_IsErrorOccur = true ;
310+ Verification_dwErrorCode = ERROR_XENGINE_MODULE_VERIFICATION_XAUTH_PARAMENT;
311+ return false ;
312+ }
313+ if (_tcsxlen (pSt_XAuthInfo->tszAddr ) <= 0 )
314+ {
315+ _xstprintf (pSt_XAuthInfo->tszAddr , _X (" http://app.libxengine.com" ));
316+ }
317+ if (0 == pSt_XAuthInfo->nPort )
318+ {
319+ pSt_XAuthInfo->nPort = 5302 ;
320+ }
321+ // 应用信息
322+ pSt_XAuthInfo->st_AuthAppInfo .bInit = true ;
323+ if (_tcsxlen (pSt_XAuthInfo->st_AuthAppInfo .tszAppName ) <= 0 )
324+ {
325+ _xstprintf (pSt_XAuthInfo->st_AuthAppInfo .tszAppName , _X (" XEngine_AuthorzeApp" ));
326+ }
327+ if (_tcsxlen (pSt_XAuthInfo->st_AuthAppInfo .tszAppVer ) <= 0 )
328+ {
329+ _xstprintf (pSt_XAuthInfo->st_AuthAppInfo .tszAppVer , _X (" V1.0.0.1001" ));
330+ }
331+ // 注册信息
332+ SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
333+ SystemApi_HardWare_GetSerial (&st_SDKSerial);
334+
335+ BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszCreateTime );
336+ if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_UNKNOW == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
337+ {
338+ pSt_XAuthInfo->st_AuthRegInfo .enSerialType = ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME;
339+ _xstprintf (pSt_XAuthInfo->st_AuthRegInfo .tszLeftTime , _X (" 5" ));
340+ pSt_XAuthInfo->st_AuthRegInfo .nHasTime = 5 ;
341+ }
342+ if (ENUM_AUTHORIZE_MODULE_CDKEY_TYPE_UNKNOW == pSt_XAuthInfo->st_AuthRegInfo .enRegType )
343+ {
344+ pSt_XAuthInfo->st_AuthRegInfo .enRegType = ENUM_AUTHORIZE_MODULE_CDKEY_TYPE_TRY;
345+ }
346+ if (ENUM_AUTHORIZE_MODULE_HW_TYPE_UNKNOW == pSt_XAuthInfo->st_AuthRegInfo .enHWType )
347+ {
348+ pSt_XAuthInfo->st_AuthRegInfo .enHWType = ENUM_AUTHORIZE_MODULE_HW_TYPE_BOARD;
349+ if (_tcsxlen (pSt_XAuthInfo->st_AuthRegInfo .tszHardware ) <= 0 )
350+ {
351+ _xstprintf (pSt_XAuthInfo->st_AuthRegInfo .tszHardware , _X (" %s" ), st_SDKSerial.tszBoardSerial );
352+ }
353+ }
354+ if (ENUM_AUTHORIZE_MODULE_VERMODE_TYPE_UNKNOW == pSt_XAuthInfo->st_AuthRegInfo .enVModeType )
355+ {
356+ pSt_XAuthInfo->st_AuthRegInfo .enVModeType = ENUM_AUTHORIZE_MODULE_VERMODE_TYPE_LOCAL;
357+ }
358+ // 临时序列号
359+ if (0 == pSt_XAuthInfo->st_AuthSerial .st_TimeLimit .nTimeCount )
360+ {
361+ pSt_XAuthInfo->st_AuthSerial .st_TimeLimit .nTimeCount = 9999 ;
362+ }
363+ if (_tcsxlen (pSt_XAuthInfo->st_AuthSerial .st_TimeLimit .tszTimeSerial ) <= 0 )
364+ {
365+ Verification_XAuthKey_KeySerial (pSt_XAuthInfo->st_AuthSerial .st_TimeLimit .tszTimeSerial , 7 , 0 );
366+ }
367+ pSt_XAuthInfo->st_AuthSerial .st_DataLimit .bTimeAdd = true ;
368+ if (_tcsxlen (pSt_XAuthInfo->st_AuthSerial .st_DataLimit .tszDataSerial ) <= 0 )
369+ {
370+ XENGINE_LIBTIME st_LibTime = {};
371+ BaseLib_Time_GetSysTime (&st_LibTime);
372+ st_LibTime.wYear += 1 ;
373+ BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthSerial .st_DataLimit .tszDataTime , NULL , true , &st_LibTime);
374+ Verification_XAuthKey_KeySerial (pSt_XAuthInfo->st_AuthSerial .st_DataLimit .tszDataSerial , 7 , 0 );
375+ }
376+ if (_tcsxlen (pSt_XAuthInfo->st_AuthSerial .st_UNLimit .tszUNLimitSerial ) <= 0 )
377+ {
378+ Verification_XAuthKey_KeySerial (pSt_XAuthInfo->st_AuthSerial .st_UNLimit .tszUNLimitSerial , 7 , 0 );
379+ }
380+ return true ;
381+ }
382+ /* *******************************************************************
383+ 函数名称:Verification_XAuthKey_KeySerial
384+ 函数功能:序列号生成函数
385+ 参数.一:ptszSerialStr
386+ In/Out:Out
387+ 类型:字符指针
388+ 可空:N
389+ 意思:输出生成的序列号
390+ 参数.二:nCount
391+ In/Out:In
392+ 类型:整数型
393+ 可空:N
394+ 意思:输入要生成的段数
395+ 参数.三:nType
396+ In/Out:In
397+ 类型:整数型
398+ 可空:N
399+ 意思:输入生成的类型0随机,1数字,2字母
400+ 返回值
401+ 类型:逻辑型
402+ 意思:是否成功
403+ 备注:
404+ *********************************************************************/
405+ bool CVerification_XAuthKey::Verification_XAuthKey_KeySerial (XCHAR* ptszSerialStr, int nCount, int nType)
406+ {
407+ Verification_IsErrorOccur = false ;
408+
409+ for (int i = 0 ; i < nCount; i++)
410+ {
411+ XCHAR tszRandomStr[6 ] = {};
412+
413+ if (0 != i)
414+ {
415+ _tcsxcat (ptszSerialStr, _X (" -" ));
416+ }
417+
418+ if (0 == nType)
419+ {
420+ BaseLib_Handle_CreateStr (tszRandomStr, 5 , nType, 1 );
421+ _tcsxcat (ptszSerialStr, tszRandomStr);
422+ }
423+ else if (1 == nType)
424+ {
425+ BaseLib_Handle_CreateStr (tszRandomStr, 5 , nType, 1 );
426+ _tcsxcat (ptszSerialStr, tszRandomStr);
427+ }
428+ else
429+ {
430+ BaseLib_Handle_CreateStr (tszRandomStr, 5 , nType, 1 );
431+ _tcsxcat (ptszSerialStr, tszRandomStr);
432+ }
433+ }
434+ return true ;
435+ }
436+ /* *******************************************************************
293437函数名称:Verification_XAuthKey_UserRegister
294438函数功能:用户注册CDKEY函数
295439 参数.一:pSt_AuthLocal
@@ -398,7 +542,7 @@ bool CVerification_XAuthKey::Verification_XAuthKey_UserRegister(VERIFICATION_XAU
398542 意思:是否成功
399543备注:记录次数越多,文件越大.读取需要的内存就越多
400544*********************************************************************/
401- bool CVerification_XAuthKey::Verification_XAuthKey_WriteTime (VERIFICATION_XAUTHKEY* pSt_AuthLocal, int nCount /* = 0 */ )
545+ bool CVerification_XAuthKey::Verification_XAuthKey_WriteTime (VERIFICATION_XAUTHKEY* pSt_AuthLocal, int nCount /* = 10 */ )
402546{
403547 Verification_IsErrorOccur = false ;
404548
0 commit comments