//---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- // File : ENkDllMain.cpp Data : 08.01.14 Versione : 1.5a1 // Contenuto : Inizializzazione della DLL. // // // // Modifiche : 08.01.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "\EgtDev\Include\ENkDllMain.h" #include "\EgtDev\Include\EGnGetModuleVer.h" #include "\EgtDev\Include\EgtTrace.h" //--------------------------- Costanti ---------------------------------------- #if defined( _WIN64) #if defined( _DEBUG) const char* ENK_STR = "EgtNumKernelD64.dll ver. " ; #else const char* ENK_STR = "EgtNumKernelR64.dll ver. " ; #endif #elif defined( _WIN32) #if defined( _DEBUG) const char* ENK_STR = "EgtNumKernelD32.dll ver. " ; #else const char* ENK_STR = "EgtNumKernelR32.dll ver. " ; #endif #endif const int STR_DIM = 40 ; //----------------------------------------------------------------------------- static HINSTANCE s_hModule = nullptr ; static char s_szENkNameVer[STR_DIM] ; //----------------------------------------------------------------------------- extern "C" int 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 // se debug, imposto stampe memory leaks all'uscita #if defined ( _DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) ; #endif // eseguo s_hModule = hModule ; EGT_TRACE( "EgtNumKernel.dll Initializing!\n") ; } else if ( dwReason == DLL_PROCESS_DETACH) { s_hModule = nullptr ; EGT_TRACE( "EgtNumKernel.dll Terminating!\n") ; } return 1 ; } //----------------------------------------------------------------------------- const char* GetENkVersion( void) { std::string sVer ; GetModuleVersion( s_hModule, sVer) ; sprintf_s( s_szENkNameVer, STR_DIM, "%s%s", ENK_STR, sVer.c_str()) ; return s_szENkNameVer ; } //----------------------------------------------------------------------------- static ILogger* s_pLogger = nullptr ; //----------------------------------------------------------------------------- void SetENkLogger( ILogger* pLogger) { s_pLogger = pLogger ; } //----------------------------------------------------------------------------- ILogger* GetENkLogger( void) { return s_pLogger ; }