//---------------------------------------------------------------------------- // EgalTech 2018-2021 //---------------------------------------------------------------------------- // File : DongleSN.cpp Data : 20.08.21 Versione : 2.3h1 // Contenuto : Funzioni per lettura SN chiave OxySec. // // // // Modifiche : 13.05.18 DS Creazione modulo. // 20.08.21 DS Eliminati goto. // //---------------------------------------------------------------------------- //------------------ Include ------------------------------------------------- #include "stdafx.h" #include "Obfuscate.h" #include "DongleId.h" #include "/EgtDev/Include/EgtBase64.h" #include "/EgtDev/Include/EgtCrc32.h" #include "/EgtDev/Extern/OxySec/Include/xnd.h" using namespace std ; //---------------------------------------------------------------------------- bool GetDongleSN( int& nDongleSN) { // cerco la chiave unsigned char label[XLT_LABEL_SIZE] ; string sLabel = "EgalTech s.r.l. - CAD/CAM/CIM Software Solutions" ; strcpy_s( (char*)label, XLT_LABEL_SIZE, sLabel.c_str()) ; memset( label + sLabel.size(), 0x00, sizeof( label) - sLabel.size()) ; XND_XLT_ENV env = xnd_xlt_env_create() ; if ( env == nullptr) return false ; int nStatus = 0 ; XND_DEVICE_CONTEXT dev_ctx = xnd_xlt_locate( env, label, &nStatus) ; if ( dev_ctx == nullptr) { xnd_xlt_env_release( env) ; return false ; } // eseguo la lettura del Serial Number unsigned int nVer ; unsigned int nModel ; unsigned int nFlags ; unsigned int nSerial ; unsigned char szLabelPrint[XLT_LABEL_SIZE + 1] ; int nRes = xnd_xlt_getinfo( dev_ctx, &nVer, &nModel, &nFlags, &nSerial, szLabelPrint) ; bool bOk = ( nRes == XLT_ERROR_SUCCESS) ; if ( bOk) { szLabelPrint[XLT_LABEL_SIZE] = '\0' ; nDongleSN = int( nSerial) ; } // rilascio xnd_xlt_devctx_release( dev_ctx) ; xnd_xlt_env_release( env) ; return bOk ; }