9ebdf4a8b3
- primo rilascio.
151 lines
4.4 KiB
C++
151 lines
4.4 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2023-2023
|
|
//----------------------------------------------------------------------------
|
|
// File : EE3DllMain.cpp Data : 14.11.23 Versione : 2.5k2
|
|
// Contenuto : Inizializzazione della DLL.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 14.11.23 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "/EgtDev/Include/EE3DllMain.h"
|
|
#include "/EgtDev/Include/EGnGetModuleVer.h"
|
|
#include "/EgtDev/Include/EGnGetKeyData.h"
|
|
#include "/EgtDev/Include/EgtTrace.h"
|
|
|
|
//--------------------------- Costanti ----------------------------------------
|
|
#if defined( _WIN64) && defined( _DEBUG)
|
|
const char* EE3_STR = "EgtExch3dmD64.dll ver. " ;
|
|
#elif defined( _WIN64)
|
|
const char* EE3_STR = "EgtExch3dmR64.dll ver. " ;
|
|
#elif defined( _WIN32) && defined( _DEBUG)
|
|
const char* EE3_STR = "EgtExch3dmD32.dll ver. " ;
|
|
#else
|
|
const char* EE3_STR = "EgtExch3dmR32.dll ver. " ;
|
|
#endif
|
|
const int STR_DIM = 40 ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
static HINSTANCE s_hModule = NULL ;
|
|
static char s_szEE3NameVer[STR_DIM] ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL APIENTRY
|
|
DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
|
|
{
|
|
|
|
if ( dwReason == DLL_PROCESS_ATTACH) {
|
|
// Controllo commentato per problemi con VB.NET
|
|
//#if defined( NDEBUG)
|
|
// BOOL IsDbgPresent = FALSE ;
|
|
// CheckRemoteDebuggerPresent( GetCurrentProcess(), &IsDbgPresent) ;
|
|
// if ( IsDbgPresent)
|
|
// return 0 ;
|
|
//#endif
|
|
s_hModule = hModule ;
|
|
EGT_TRACE( "EgtExch3dm.dll Initializing!\n") ;
|
|
}
|
|
else if ( dwReason == DLL_PROCESS_DETACH) {
|
|
s_hModule = NULL ;
|
|
EGT_TRACE( "EgtExch3dm.dll Terminating!\n") ;
|
|
}
|
|
|
|
return 1 ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
const char*
|
|
GetEE3Version( void)
|
|
{
|
|
std::string sVer ;
|
|
|
|
GetModuleVersion( s_hModule, sVer) ;
|
|
sprintf_s( s_szEE3NameVer, STR_DIM, "%s%s", EE3_STR, sVer.c_str()) ;
|
|
|
|
return s_szEE3NameVer ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
static ILogger* s_pLogger = nullptr ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
SetEE3Logger( ILogger* pLogger)
|
|
{
|
|
s_pLogger = pLogger ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
ILogger*
|
|
GetEE3Logger( void)
|
|
{
|
|
return s_pLogger ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
static std::string s_sKey ;
|
|
static bool s_bNetHwKey = false ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
SetEE3Key( const std::string& sKey)
|
|
{
|
|
s_sKey = sKey ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
SetEE3NetHwKey( bool bNetHwKey)
|
|
{
|
|
s_bNetHwKey = bNetHwKey ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
const std::string&
|
|
GetEE3Key( void)
|
|
{
|
|
return s_sKey ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
GetEE3NetHwKey( void)
|
|
{
|
|
return s_bNetHwKey ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
VerifyKey( int nKeyOpt)
|
|
{
|
|
// Controllo della licenza
|
|
unsigned int nOpt1, nOpt2 ;
|
|
int nOptExpDays ;
|
|
int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
|
nOpt1, nOpt2, nOptExpDays) ;
|
|
if ( ! GetEE3NetHwKey())
|
|
nRet = GetKeyOptions( GetEE3Key(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
|
nOpt1, nOpt2, nOptExpDays) ;
|
|
if ( nRet != KEY_OK && ! EqualNoCase( GetEE3Key(), "EE3Base")) {
|
|
if ( nRet != KEY_OK) {
|
|
std::string sErr = "Error on Key (EE3/" + ToString( nRet) + ")" ;
|
|
LOG_ERROR( GetEE3Logger(), sErr.c_str()) ;
|
|
return false ;
|
|
}
|
|
if ( ( nOpt1 & ( KEYOPT_EEX_INPBASE|KEYOPT_EEX_EXPBASE)) == 0 ||
|
|
( nKeyOpt != 0 && ( nOpt1 & nKeyOpt) == 0) ||
|
|
nOptExpDays < GetCurrDay()) {
|
|
std::string sErr = "Warning on Key (EE3/OPT)" ;
|
|
LOG_ERROR( GetEE3Logger(), sErr.c_str()) ;
|
|
return false ;
|
|
}
|
|
}
|
|
return true ;
|
|
}
|