Browse Source

Z991239-5184 #comment 区分VS2019和VS2010适配器的实现方案

80374374 1 year ago
parent
commit
a42addf201

+ 11 - 1
DevAdapter/cmbsz/FingerPrint.1.1/FingerPrint_Impl.cpp

@@ -92,4 +92,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass*& pBaseObj)
 		return Error_Succeed;
 	}
 	return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/FingerPrint.7.1/FingerPrint_Impl.cpp

@@ -92,4 +92,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass*& pBaseObj)
 		return Error_Succeed;
 	}
 	return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/cardissuer.1.1/cardissuer_impl.cpp

@@ -68,4 +68,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
     return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+    retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+    return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/cardswiper.1.1/cardswiper_impl.cpp

@@ -199,4 +199,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass*& pInDevAptObj
         return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/contactlesscard.1.1/contactless_impl.cpp

@@ -68,4 +68,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
     return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/gpio.1.1/gpio_impl.cpp

@@ -68,4 +68,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
     return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/gpio.1.2/gpio_impl.cpp

@@ -153,4 +153,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
     return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/hspscanner.1.1/hspscanner_impl.cpp

@@ -68,4 +68,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
     return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/idcer.1.1/idcer_impl.cpp

@@ -131,4 +131,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
     return Error_Succeed;
     }
     return Error_Param;
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 1
DevAdapter/cmbsz/pinpad.1.1/pinpad_impl.cpp

@@ -206,4 +206,14 @@ DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass*& pInDevAptObj
     }
     return Error_Param;
 
-}
+}
+
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion)
+{
+	retVesion.wMajor = retVesion.wMinor = retVesion.wBuild = retVesion.wRevision = 0;
+	return Error_Succeed;
+}
+
+#endif // NEWER_COMPILER_WORKAROUNDS

+ 11 - 0
DevAdapter/include/DeviceBaseClass.h

@@ -56,6 +56,11 @@
 #   define DEVICEBASE_API
 #endif
 
+#ifdef _MSC_VER
+#   if _MSC_VER >= 1920
+#       define NEWER_COMPILER_WORKAROUNDS
+#   endif
+#endif
 
 #ifdef __cplusplus
 extern "C"
@@ -149,6 +154,12 @@ public:
 DEVICEBASE_API ErrorCodeEnum  CreateDevComponent(DeviceBaseClass*& baseObj);
 DEVICEBASE_API ErrorCodeEnum  ReleaseDevComponent(DeviceBaseClass*& pBaseObj);
 
+#ifdef NEWER_COMPILER_WORKAROUNDS
+
+DEVICEBASE_API ErrorCodeEnum  GetDevAdapterVersion(DevSoftVersion& retVesion);
+
+#endif // NEWER_COMPILER_WORKAROUNDS
+
 #ifdef __cplusplus
 }
 #endif

+ 30 - 2
Module/include/DevFSMCommBase.hpp

@@ -15,15 +15,14 @@
 #include "fileutil.h"
 
 #if defined(_MSC_VER)
-
 #pragma comment(lib, "Version.lib")
-
 typedef ErrorCodeEnum(*DevAdaptObjCreateFunc)(DeviceBaseClass*& baseObj);
 typedef ErrorCodeEnum(*DevAdaptObjReleaseFunc)(DeviceBaseClass*& pBaseObj);
 #else //C/C++ Compiler 
 using DevAdaptObjCreateFunc = ErrorCodeEnum(*)(DeviceBaseClass*& pOutDevAptObj);
 using DevAdaptObjReleaseFunc = ErrorCodeEnum(*)(DeviceBaseClass*& pInDevAptObj);
 #endif //_MSC_VER
+typedef ErrorCodeEnum(*GetDevAdapterVersionFunc)(DevSoftVersion& retVersion);
 
 #define HARDWARE_ENTITY_RESET_ENTITYID(ent, entityID)	\
 do{\
@@ -173,6 +172,9 @@ private:
 		for (int i = 0; i < strTest.GetLength(); ++i) {
 			if (strTest[i] >= 'A' && strTest[i] <= 'Z') strTest[i] = strTest[i] + ('a' - 'A');
 		}
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("strTest:%s", strPath.GetData());
+
+
 		if (strTest.IndexOf("pinpad") != -1) {
 			replaceAdapterName = "PinPad.self.1.1.dll";
 			result = true;
@@ -207,8 +209,33 @@ private:
 		DWORD d3;
 		DWORD d4;
 
+		if (!ExistsFileA(strFullLibPath)) {
+			return result;
+		}
+		/** Test Gifur@2024322]*/
 		GetDllVersionInfo(strFullLibPath, d1, d2, d3, d4);
 		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("dll version: %d.%d.%d.%d", d1, d2, d3, d4);
+
+		do 
+		{
+			toolkit_lib_t libHandle;
+			int res = toolkit_dlopen(strFullLibPath, &libHandle);
+			if (res != 0) {
+				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("tmp: toolkit_dlopen[%s] failed with error %s.", strFullLibPath.GetData(), toolkit_dlerror(&libHandle));
+				toolkit_dlclose(&libHandle);
+				return result;
+			}
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tmp: try to get GetDevAdapterVersion pointer address...");
+			if ((res = toolkit_dlsym(&libHandle, "GetDevAdapterVersion", (void**)&pFuncGetDevAdapterVer)) != 0) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("try  to get 'GetDevAdapterVersion' Func address failed with error: %s", toolkit_dlerror(&libHandle));
+				toolkit_dlclose(&libHandle);
+			} else {
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get 'GetDevAdapterVersion' Func address  succ, seem it as built with vs2019, skip latter procedure");
+				toolkit_dlclose(&libHandle);
+				return result;
+			}
+		} while (false);
+
 		CSimpleStringA strTest = strFullLibPath.GetData();
 		CSimpleStringA strSelf(true);
 		if (CheckAndGetMapAdatperName(strTest, strSelf)) {
@@ -462,6 +489,7 @@ private:
 	toolkit_lib_t m_lib;
 	DevAdaptObjCreateFunc pFuncCreateAdapt;
 	DevAdaptObjReleaseFunc pFuncReleaseAdapt;
+	GetDevAdapterVersionFunc pFuncGetDevAdapterVer;
 
 	TSubAdpt* m_AdptObjPtr;
 	bool m_VS2010BridgeMode;