@@ -178,6 +178,99 @@ bool CVerification_XAuthKey::Verification_XAuthKey_FileWrite(VERIFICATION_XAUTHK
178178
179179 return true ;
180180}
181+ bool CVerification_XAuthKey::Verification_XAuthKey_MemoryRead (VERIFICATION_XAUTHKEY* pSt_XAuthInfo, LPCXSTR lpszMSGBuffer, int nMSGLen, LPCXSTR lpszKeyPass /* = NULL */ )
182+ {
183+ Verification_IsErrorOccur = false ;
184+
185+ int nRet = nMSGLen;
186+ XCHAR tszDECodecBuffer[4096 ] = {};
187+ XCHAR tszENCodecBuffer[4096 ] = {};
188+
189+ memcpy (tszENCodecBuffer, lpszMSGBuffer, nMSGLen);
190+
191+ if (NULL == lpszKeyPass)
192+ {
193+ // 读取
194+ if (!Verification_XAuthKey_ReadMemory (tszENCodecBuffer, nRet, pSt_XAuthInfo))
195+ {
196+ return false ;
197+ }
198+ }
199+ else
200+ {
201+ // 解密
202+ if (!Cryption_XCrypto_Decoder (tszENCodecBuffer, &nRet, tszDECodecBuffer, lpszKeyPass))
203+ {
204+ Verification_IsErrorOccur = true ;
205+ Verification_dwErrorCode = Cryption_GetLastError ();
206+ return false ;
207+ }
208+ // 读取
209+ if (!Verification_XAuthKey_ReadMemory (tszDECodecBuffer, nRet, pSt_XAuthInfo))
210+ {
211+ return false ;
212+ }
213+ }
214+
215+ if (ENUM_VERIFICATION_MODULE_SERIAL_TYPE_DAY == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
216+ {
217+ XENGINE_LIBTIME st_SysTime = {};
218+ XENGINE_LIBTIME st_EndTime = {};
219+ BaseLib_Time_GetSysTime (&st_SysTime);
220+ BaseLib_Time_StrToTime (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime , &st_EndTime);
221+ if ((st_EndTime.wYear != st_SysTime.wYear ) || (st_EndTime.wMonth != st_SysTime.wMonth ) || (st_EndTime.wDay != st_SysTime.wDay ))
222+ {
223+ pSt_XAuthInfo->st_AuthRegInfo .nHasTime --;
224+ _xstprintf (pSt_XAuthInfo->st_AuthRegInfo .tszLeftTime , _X (" %lld" ), pSt_XAuthInfo->st_AuthRegInfo .nHasTime );
225+ BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime );
226+ }
227+ }
228+ else
229+ {
230+ BaseLib_Time_TimeToStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime );
231+ }
232+ pSt_XAuthInfo->st_AuthAppInfo .nExecTime ++;
233+ return true ;
234+ }
235+ bool CVerification_XAuthKey::Verification_XAuthKey_MemoryWrite (VERIFICATION_XAUTHKEY* pSt_XAuthInfo, XCHAR* ptszMSGBuffer, int * pInt_MSGLen, LPCXSTR lpszKeyPass /* = NULL */ )
236+ {
237+ Verification_IsErrorOccur = false ;
238+
239+ int nSize = 0 ;
240+ XCHAR tszDECodecBuffer[4096 ] = {};
241+ // 更新使用时间
242+ if (ENUM_VERIFICATION_MODULE_SERIAL_TYPE_SECOND == pSt_XAuthInfo->st_AuthRegInfo .enSerialType )
243+ {
244+ XCHAR tszTimeEnd[64 ] = {};
245+ __int64x nUsedTime = 0 ;
246+
247+ BaseLib_Time_TimeToStr (tszTimeEnd);
248+ BaseLib_TimeSpan_GetForStr (pSt_XAuthInfo->st_AuthRegInfo .tszStartTime , tszTimeEnd, &nUsedTime, ENUM_XENGINE_BASELIB_TIME_TYPE_SECOND);
249+ pSt_XAuthInfo->st_AuthRegInfo .nHasTime -= nUsedTime;
250+ _xstprintf (pSt_XAuthInfo->st_AuthRegInfo .tszLeftTime , _X (" %lld" ), pSt_XAuthInfo->st_AuthRegInfo .nHasTime );
251+ }
252+ // 准备数据
253+ if (!Verification_XAuthKey_WriteMemory (tszDECodecBuffer, &nSize, pSt_XAuthInfo))
254+ {
255+ return false ;
256+ }
257+ // 写数据
258+ if (NULL == lpszKeyPass)
259+ {
260+ memcpy (ptszMSGBuffer, tszDECodecBuffer, nSize);
261+ }
262+ else
263+ {
264+ if (!Cryption_XCrypto_Encoder (tszDECodecBuffer, &nSize, (XBYTE*)ptszMSGBuffer, lpszKeyPass))
265+ {
266+ Verification_IsErrorOccur = true ;
267+ Verification_dwErrorCode = Cryption_GetLastError ();
268+ return false ;
269+ }
270+ }
271+ *pInt_MSGLen = nSize;
272+ return true ;
273+ }
181274/* *******************************************************************
182275函数名称:Verification_XAuthKey_KeyParse
183276函数功能:解析CDKEY内容,判断是否超时
0 commit comments