From 5490eaa2ddcc4d46e12cb1b82267d0481431e085 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 6 Feb 2026 10:24:36 +0100 Subject: [PATCH] EgtLock : - aggiunta lettura Serial Number anche per chiavi di rete. --- LockId.cpp | 3 +-- NetDongleId.cpp | 21 ++++++++++++++++++++- NetDongleId.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/LockId.cpp b/LockId.cpp index 8badace..6c7f234 100644 --- a/LockId.cpp +++ b/LockId.cpp @@ -188,8 +188,7 @@ GetLockSN( int& nLockSN) if ( ! s_bNetHwKey) return GetDongleSN( nLockSN) ; else { - nLockSN = 0 ; - return false ; + return GetNetDongleSN( nLockSN) ; } } } diff --git a/NetDongleId.cpp b/NetDongleId.cpp index ec68542..755acc8 100644 --- a/NetDongleId.cpp +++ b/NetDongleId.cpp @@ -137,7 +137,7 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort) strcpy_s( (char*)label, XLT_LABEL_SIZE, sLabel.c_str()) ; memset( label + sLabel.size(), 0x00, sizeof( label) - sLabel.size()) ; int nStatusND = 0 ; - if ( &sAddrPort == nullptr || sAddrPort.empty() || + if ( sAddrPort.empty() || sAddrPort.find_first_not_of( " \t\r\n") == std::string::npos) s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 10000, 0, 0, &nStatusND) ; else { @@ -255,6 +255,25 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort) return true ; } +//---------------------------------------------------------------------------- +bool +GetNetDongleSN( int& nDongleSN) +{ + // default + nDongleSN = 0 ; + // verifico validità contesto + if ( s_dev_ctx == nullptr) + return false ; + // recupero informazioni sulla chiave + XND_INFO xInfo ; + int nStatIF = xnd_get_info( s_dev_ctx, &xInfo) ; + if ( nStatIF != 0) + return false ; + // ricavo il SN + nDongleSN = *((unsigned int*)&xInfo.sn[12]) ; + return true ; +} + //---------------------------------------------------------------------------- bool NetDongleClose( void) diff --git a/NetDongleId.h b/NetDongleId.h index fcf59c3..f7ad54e 100644 --- a/NetDongleId.h +++ b/NetDongleId.h @@ -18,5 +18,6 @@ //------------------------------------------------------------------------------- bool GetNetDongleId( int nNetUserId, const std::string& sAddrPort, std::string& sDongleId) ; bool NetDongleConnect( int nNetUserId, const std::string& sAddrPort) ; +bool GetNetDongleSN( int& nDongleSN) ; bool NetDongleClose( void) ; bool NetDongleNotFound( void) ;