Browse Source

Z991239-5384 #comment 在密钥初始化时候,增加序号的备份,排查win系统api写入问题

oilyang 1 năm trước cách đây
mục cha
commit
9217ca049c
1 tập tin đã thay đổi với 34 bổ sung0 xóa
  1. 34 0
      Module/mod_pinpad/PinPadFSM.cpp

+ 34 - 0
Module/mod_pinpad/PinPadFSM.cpp

@@ -8,6 +8,7 @@
 #include "RVCComm.h"
 #include "sm4.h"
 #include "publicFunExport.h"
+#include <fstream>
 #if defined(RVC_OS_LINUX)
 #include <thread>
 #include <chrono>
@@ -459,6 +460,22 @@ int CPinPadFSM::Initial()
 	LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_DevConnect_CostTime, CSimpleStringA::Format("%d", (SP::Module::Comm::RVCGetTickCount() - m_ullConnectCost) / 1000));
 	LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_PinPad_InfoAboutKey_Onboot, xTmpStr.GetData());
 	LogEvent(Severity_Middle, LOG_EVT_PINPAD_OPEN_SUC, "Open pinpad suc.");
+
+	//oiltmp@20240521 add for redundancy to check
+	CSimpleStringA csRunInfo, csSNBakFile;
+	if ((eErr = GetEntityBase()->GetFunction()->GetPath("RunInfo", csRunInfo)) == Error_Succeed)
+	{
+		csSNBakFile = csRunInfo + SPLIT_SLASH_STR + "snbak.dat";
+		ifstream infile(csSNBakFile, std::ofstream::binary);
+		char* buffer = new char[16];
+		ZeroMemory(buffer, 16);
+		if (infile.is_open())
+			infile.read(buffer, 16);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("bak.sn:%s", buffer);
+		delete[] buffer;
+		infile.close();
+	}
+
 	return 0;
 }
 unsigned int __stdcall DoWork(void *pData)
@@ -1211,6 +1228,23 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
 			}
 			m_keySNSM = ctx->Req.reserved3;
 			LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_PinPad_LoadKey_SMSN, m_keySNSM.GetData());
+
+			//oiltmp@20240521 add for redundancy to check
+			CSimpleStringA csRunInfo,csSNBakFile;
+			if ((eErr = GetEntityBase()->GetFunction()->GetPath("RunInfo", csRunInfo)) == Error_Succeed)
+			{
+				csSNBakFile = csRunInfo + SPLIT_SLASH_STR + "snbak.dat";
+				ofstream outfile(csSNBakFile, std::ofstream::binary|ios::trunc);
+
+				int size = m_keySNSM.GetLength();
+				char* buffer = new char[size + 1];
+				ZeroMemory(buffer, size + 1);
+				memcpy(buffer, m_keySNSM.GetData(), size);
+				outfile.write(buffer, size);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("write sn bak:%s", buffer);
+				delete[] buffer;
+				outfile.close();
+			}
 		}
 		else
 		{