diff --git a/KeyGenerator.cpp b/KeyGenerator.cpp index 4b1a113..1849975 100644 --- a/KeyGenerator.cpp +++ b/KeyGenerator.cpp @@ -18,6 +18,7 @@ #include "/EgtDev/Include/EGnGetModuleVer.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtIniFile.h" +#include "/EgtDev/Include/SELkLockId.h" #include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; @@ -82,6 +83,7 @@ CKeyGeneratorApp::InitInstance( void) m_pszProfileName = p ; // verifico la protezione + SetLockType( KEY_LOCK_TYPE_HW) ; string sKey = GetPrivateProfileStringUtf8( "General", "Key", "", m_pszProfileName) ; if ( VerifyKey( sKey, 1230, 16, 10) != KEY_OK) return FALSE ; diff --git a/KeyGenerator.rc b/KeyGenerator.rc index 1e7c8bb..73e157c 100644 Binary files a/KeyGenerator.rc and b/KeyGenerator.rc differ diff --git a/KeyGenerator.vcxproj b/KeyGenerator.vcxproj index f9d5875..c64bce0 100644 --- a/KeyGenerator.vcxproj +++ b/KeyGenerator.vcxproj @@ -46,12 +46,14 @@ $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ $(Configuration)$(PlatformArchitecture)\ $(ProjectName)D$(PlatformArchitecture) + C:\;$(IncludePath) false $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ $(Configuration)$(PlatformArchitecture)\ $(ProjectName)R$(PlatformArchitecture) + C:\;$(IncludePath) @@ -64,6 +66,7 @@ Windows true + c:\EgtDev\Extern\OxySec\Lib\x32\oxyxlt.obj;%(AdditionalDependencies) false @@ -96,6 +99,7 @@ false true true + c:\EgtDev\Extern\OxySec\Lib\x32\oxyxlt.obj;%(AdditionalDependencies) false diff --git a/KeyGeneratorDlg.cpp b/KeyGeneratorDlg.cpp index 99f0b52..435fcf8 100644 --- a/KeyGeneratorDlg.cpp +++ b/KeyGeneratorDlg.cpp @@ -263,8 +263,8 @@ CKeyGeneratorDlg::LoadFile( const char* szFile) sSec += ToString( nLast) ; string sCust = GetPrivateProfileStringUtf8( sSec.c_str(), "Customer", "", szFile) ; GetDlgItem( IDC_CUSTOMER)->SetWindowTextW( stringtoW( sCust)) ; - string sMachId = GetPrivateProfileStringUtf8( sSec.c_str(), "MachineId", "", szFile) ; - GetDlgItem( IDC_MACHID)->SetWindowTextW( stringtoW( sMachId)) ; + string sLockId = GetPrivateProfileStringUtf8( sSec.c_str(), "LockId", "", szFile) ; + GetDlgItem( IDC_MACHID)->SetWindowTextW( stringtoW( sLockId)) ; int nProd = GetPrivateProfileInt( sSec.c_str(), "Product", 0, szFile) ; ((CComboBox*)GetDlgItem( IDC_PROD))->SetCurSel( nProd - 1230) ; int nVer = GetPrivateProfileInt( sSec.c_str(), "Ver", 0, szFile) ; @@ -306,12 +306,12 @@ CKeyGeneratorDlg::OnGenerate( void) WritePrivateProfileStringUtf8( "Licence", "Customer", sCust.c_str(), AfxGetApp()->m_pszProfileName) ; // recupero l'identificativo macchina (tipo 2) GetDlgItem( IDC_MACHID)->GetWindowTextW( wszTemp) ; - string sMachId = wstrztoA( wszTemp) ; - if ( ! mKey.SetMachineId( sMachId)) { - AfxMessageBox( L"Id Macchina vuoto o errato") ; + string sLockId = wstrztoA( wszTemp) ; + if ( ! mKey.SetLockId( sLockId)) { + AfxMessageBox( L"Id Serratura vuoto o errato") ; return ; } - WritePrivateProfileStringUtf8( "Licence", "MachineId", sMachId.c_str(), AfxGetApp()->m_pszProfileName) ; + WritePrivateProfileStringUtf8( "Licence", "LockId", sLockId.c_str(), AfxGetApp()->m_pszProfileName) ; // recupero il prodotto GetDlgItem( IDC_PROD)->GetWindowTextW( wszTemp) ; string sProd = wstrztoA( wszTemp) ; diff --git a/KeyMaker.cpp b/KeyMaker.cpp index f9cec26..fe13be1 100644 --- a/KeyMaker.cpp +++ b/KeyMaker.cpp @@ -14,7 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "KeyMaker.h" -#include "/EgtDev/Include/SELkMachineId.h" +#include "/EgtDev/Include/SELkLockId.h" #include "/EgtDev/Include/SELkKeyProc.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EgtIniFile.h" @@ -31,8 +31,8 @@ using namespace std ; KeyMaker::KeyMaker( void) { m_sCustomer.clear() ; - m_sMachineId.clear() ; - m_sMachineId2.clear() ; + m_sLockId.clear() ; + m_sLockId2.clear() ; m_sScramKey.clear() ; m_nProd = 0 ; m_nVer = 0 ; @@ -56,19 +56,32 @@ KeyMaker::SetCustomer( const string& sCustomer) //---------------------------------------------------------------------------- bool -KeyMaker::SetMachineId( const string& sMachineId2) +KeyMaker::SetLockId( const string& sLockId2) { - // calcolo identificativo macchina in chiaro - string sMachineId ; - if ( ! ConvertMachineId2ToMachineId( sMachineId2, sMachineId)) - return false ; - // calcolo chiave di scramble - string sScramKey ; - if ( ! ConvertMachineId2ToScramKey( sMachineId2, sScramKey)) - return false ; - m_sMachineId2 = sMachineId2 ; - m_sMachineId = sMachineId ; - m_sScramKey = sScramKey ; + // se identificativo di chiave, è direttamente in chiaro + if ( sLockId2.find( KEY_LOCK_HW_START) != string::npos) { + m_sLockId2 = sLockId2 ; + m_sLockId = sLockId2 ; + // calcolo chiave di scramble + string sScramKey ; + if ( ! ConvertLockIdToScramKey( m_sLockId, sScramKey)) + return false ; + m_sScramKey = sScramKey ; + } + // altrimenti + else { + // calcolo identificativo macchina in chiaro + string sLockId ; + if ( ! ConvertLockId2ToLockId( sLockId2, sLockId)) + return false ; + // calcolo chiave di scramble + string sScramKey ; + if ( ! ConvertLockId2ToScramKey( sLockId2, sScramKey)) + return false ; + m_sLockId2 = sLockId2 ; + m_sLockId = sLockId ; + m_sScramKey = sScramKey ; + } return true ; } @@ -210,11 +223,11 @@ KeyMaker::DiffLicence( const char* szFile) string sCust = GetPrivateProfileStringUtf8( sSec.c_str(), "Customer", "", szFile) ; if ( sCust != m_sCustomer) return true ; - string sMachId = GetPrivateProfileStringUtf8( sSec.c_str(), "MachineId", "", szFile) ; - if ( sMachId != m_sMachineId2) + string sLockId = GetPrivateProfileStringUtf8( sSec.c_str(), "LockId", "", szFile) ; + if ( sLockId != m_sLockId2) return true ; - string sClearMachId = GetPrivateProfileStringUtf8( sSec.c_str(), "ClearMachineId", "", szFile) ; - if ( sClearMachId != m_sMachineId) + string sClearLockId = GetPrivateProfileStringUtf8( sSec.c_str(), "ClearLockId", "", szFile) ; + if ( sClearLockId != m_sLockId) return true ; int nProd = GetPrivateProfileInt( sSec.c_str(), "Product", 0, szFile) ; if ( nProd != m_nProd) @@ -250,9 +263,9 @@ KeyMaker::WriteLicence( const char* szSec, const char* szFile, bool bAll) if ( bAll) WritePrivateProfileStringUtf8( szSec, "Date", CurrDateTime().c_str(), szFile) ; WritePrivateProfileStringUtf8( szSec, "Customer", m_sCustomer.c_str(), szFile) ; - WritePrivateProfileStringUtf8( szSec, "MachineId", m_sMachineId2.c_str(), szFile) ; + WritePrivateProfileStringUtf8( szSec, "LockId", m_sLockId2.c_str(), szFile) ; if ( bAll) - WritePrivateProfileStringUtf8( szSec, "ClearMachineId", m_sMachineId.c_str(), szFile) ; + WritePrivateProfileStringUtf8( szSec, "ClearLockId", m_sLockId.c_str(), szFile) ; WritePrivateProfileInt( szSec, "Product", m_nProd, szFile) ; WritePrivateProfileInt( szSec, "Ver", m_nVer, szFile) ; WritePrivateProfileInt( szSec, "Lev", m_nLev, szFile) ; diff --git a/KeyMaker.h b/KeyMaker.h index ceea631..fc56326 100644 --- a/KeyMaker.h +++ b/KeyMaker.h @@ -22,7 +22,7 @@ class KeyMaker public : KeyMaker(void) ; bool SetCustomer( const std::string& sCustomer) ; - bool SetMachineId( const std::string& sMachineId2) ; + bool SetLockId( const std::string& sLockId2) ; bool SetProduct( const std::string& sProd) ; bool SetVersion( const std::string& sVer) ; bool SetLevel( const std::string& sLev) ; @@ -39,8 +39,8 @@ class KeyMaker private : std::string m_sCustomer ; - std::string m_sMachineId ; - std::string m_sMachineId2 ; + std::string m_sLockId ; + std::string m_sLockId2 ; std::string m_sScramKey ; std::string m_sKey ; int m_nProd ;