From 136557b6c22d846807d208801e5c55bd75910d59 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 26 May 2015 15:51:48 +0000 Subject: [PATCH] EgtExecutor : - modifiche per caricare le dll opzionali solo se codici chiave le abilitano. --- DllExchange.cpp | 17 +++++++++++++++-- DllExchange.h | 2 +- DllGraphics.cpp | 17 +++++++++++++++-- DllGraphics.h | 2 +- DllMachKernel.cpp | 17 +++++++++++++++-- DllMachKernel.h | 2 +- EXE_General.cpp | 26 ++++++++++++++++---------- stdafx.h | 1 + 8 files changed, 65 insertions(+), 19 deletions(-) diff --git a/DllExchange.cpp b/DllExchange.cpp index 12675e9..d7454a2 100644 --- a/DllExchange.cpp +++ b/DllExchange.cpp @@ -13,7 +13,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" +#include "EXE.h" #include "DllExchange.h" +#include "/EgtDev/Include/EExDllMain.h" #define NOMINMAX #include @@ -48,14 +50,25 @@ HMODULE s_hEEx = nullptr ; //----------------------------------------------------------------------------- bool -LoadExchangeDll( void) +LoadExchangeDll( ILogger* pLogger, const string& sKey) { + // verifico la chiave + if ( ! TestKeyForEEx( sKey, 0, pLogger)) { + FreeExchangeDll() ; + return false ; + } // se già caricata if ( s_hEEx != nullptr) return true ; // carico la libreria EgtExchange s_hEEx = LoadLibrary( EEX_NAME) ; - return ( s_hEEx != nullptr) ; + if ( s_hEEx == nullptr) + return false ; + // imposto logger + MySetEExLogger( pLogger) ; + // imposto i codici della chiave + MySetEExKey( sKey) ; + return true ; } //----------------------------------------------------------------------------- diff --git a/DllExchange.h b/DllExchange.h index e8c0fce..d615fc3 100644 --- a/DllExchange.h +++ b/DllExchange.h @@ -25,7 +25,7 @@ class IExportStl ; class IExcExecutor ; //---------------------------------------------------------------------------- -bool LoadExchangeDll( void) ; +bool LoadExchangeDll( ILogger* pLogger, const std::string& sKey) ; bool FreeExchangeDll( void) ; bool IsLoadedExchangeDll( void) ; void MySetEExLogger( ILogger* pLogger) ; diff --git a/DllGraphics.cpp b/DllGraphics.cpp index 9573156..ddb32fe 100644 --- a/DllGraphics.cpp +++ b/DllGraphics.cpp @@ -13,7 +13,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" +#include "EXE.h" #include "DllGraphics.h" +#include "/EgtDev/Include/EGrDllMain.h" #define NOMINMAX #include @@ -43,14 +45,25 @@ HMODULE s_hEGr = nullptr ; //----------------------------------------------------------------------------- bool -LoadGraphicsDll( void) +LoadGraphicsDll( ILogger* pLogger, const string& sKey) { + // verifico la chiave + if ( ! TestKeyForEGr( sKey, 0, pLogger)) { + FreeGraphicsDll() ; + return false ; + } // se già caricata if ( s_hEGr != nullptr) return true ; // carico la libreria EgtGraphics s_hEGr = LoadLibrary( EGR_NAME) ; - return ( s_hEGr != nullptr) ; + if ( s_hEGr == nullptr) + return false ; + // imposto logger + MySetEGrLogger( pLogger) ; + // imposto i codici della chiave + MySetEGrKey( sKey) ; + return true ; } //----------------------------------------------------------------------------- diff --git a/DllGraphics.h b/DllGraphics.h index 237950e..194f205 100644 --- a/DllGraphics.h +++ b/DllGraphics.h @@ -20,7 +20,7 @@ class IEGrScene ; class ISceExecutor ; //---------------------------------------------------------------------------- -bool LoadGraphicsDll( void) ; +bool LoadGraphicsDll( ILogger* pLogger, const std::string& sKey) ; bool FreeGraphicsDll( void) ; bool IsLoadedGraphicsDll( void) ; void MySetEGrLogger( ILogger* pLogger) ; diff --git a/DllMachKernel.cpp b/DllMachKernel.cpp index fd14329..038a4d3 100644 --- a/DllMachKernel.cpp +++ b/DllMachKernel.cpp @@ -13,7 +13,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" +#include "EXE.h" #include "DllMachKernel.h" +#include "/EgtDev/Include/EMkDllMain.h" #define NOMINMAX #include @@ -42,14 +44,25 @@ HMODULE s_hEMk = nullptr ; //----------------------------------------------------------------------------- bool -LoadMachKernelDll( void) +LoadMachKernelDll( ILogger* pLogger, const string& sKey) { + // verifico la chiave + if ( ! TestKeyForEMk( sKey, 0, pLogger)) { + FreeMachKernelDll() ; + return false ; + } // se già caricata if ( s_hEMk != nullptr) return true ; // carico la libreria EgtMachKernel s_hEMk = LoadLibrary( EMK_NAME) ; - return ( s_hEMk != nullptr) ; + if ( s_hEMk == nullptr) + return false ; + // imposto logger + MySetEMkLogger( pLogger) ; + // imposto i codici della chiave + MySetEMkKey( sKey) ; + return true ; } //----------------------------------------------------------------------------- diff --git a/DllMachKernel.h b/DllMachKernel.h index babe4ac..711261a 100644 --- a/DllMachKernel.h +++ b/DllMachKernel.h @@ -19,7 +19,7 @@ class ILogger ; class IMachMgr ; //---------------------------------------------------------------------------- -bool LoadMachKernelDll( void) ; +bool LoadMachKernelDll( ILogger* pLogger, const std::string& sKey) ; bool FreeMachKernelDll( void) ; bool IsLoadedMachKernelDll( void) ; void MySetEMkLogger( ILogger* pLogger) ; diff --git a/EXE_General.cpp b/EXE_General.cpp index b418352..3a98aa8 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -23,6 +23,7 @@ #include "/EgtDev/Include/EGnDllMain.h" #include "/EgtDev/Include/ENkDllMain.h" #include "/EgtDev/Include/EGkDllMain.h" +#include "/EgtDev/Include/EGkObjUserFactory.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnPcInfo.h" #include "/EgtDev/Include/EgtLogger.h" @@ -36,6 +37,7 @@ using namespace egtlogger ; static Logger* s_pGenLog = nullptr ; static bool s_bCmdLog = false ; static Logger* s_pCmdLog = nullptr ; +static string s_sKey ; //----------------------------------------------------------------------------- bool @@ -58,13 +60,13 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg) SetENkLogger( s_pGenLog) ; SetEGkLogger( s_pGenLog) ; + // imposto la chiave di protezione + SetEGkKey( s_sKey) ; + // carico librerie opzionali - LoadGraphicsDll() ; - MySetEGrLogger( s_pGenLog) ; - LoadExchangeDll() ; - MySetEExLogger( s_pGenLog) ; - LoadMachKernelDll() ; - MySetEMkLogger( s_pGenLog) ; + LoadGraphicsDll( s_pGenLog, s_sKey) ; + LoadExchangeDll( s_pGenLog, s_sKey) ; + LoadMachKernelDll( s_pGenLog, s_sKey) ; // dichiaro inizio programma LOG_DATETIME( s_pGenLog, " Init") @@ -83,6 +85,13 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg) LOG_INFO( s_pGenLog, sTmp.c_str()) if ( GetMemoryInfo( sTmp)) LOG_INFO( s_pGenLog, sTmp.c_str()) + // Info su gestori ObjUser caricati + STRVECTOR vsOuMgr ; + if ( OBJUSER_GETLIST( vsOuMgr)) { + LOG_INFO( s_pGenLog, "ObjUser Managers :") + for ( size_t i = 0 ; i < vsOuMgr.size() ; ++ i) + LOG_INFO( s_pGenLog, vsOuMgr[i].c_str()) + } // inizializzo l'interprete LUA LuaInit() ; @@ -127,10 +136,7 @@ ExeExit( void) bool ExeSetKey( const string& sKey) { - SetEGkKey( sKey) ; - MySetEGrKey( sKey) ; - MySetEExKey( sKey) ; - MySetEMkKey( sKey) ; + s_sKey = sKey ; return true ; } diff --git a/stdafx.h b/stdafx.h index d41bf0c..5365c66 100644 --- a/stdafx.h +++ b/stdafx.h @@ -32,3 +32,4 @@ #pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua52" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib")