//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : EMkDllMain.cpp Data : 22.03.15 Versione : 1.6c6 // Contenuto : Inizializzazione della DLL. // // // // Modifiche : 22.03.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DllMain.h" #include "/EgtDev/Include/EMkDllMain.h" #include "/EgtDev/Include/EGnGetModuleVer.h" #include "/EgtDev/Include/EgtTrace.h" //--------------------------- Costanti ---------------------------------------- #if defined( _WIN64) && defined( _DEBUG) const char* EMK_STR = "EgtMachKernelD64.dll ver. " ; #elif defined( _WIN64) const char* EMK_STR = "EgtMachKernelR64.dll ver. " ; #elif defined( _WIN32) && defined( _DEBUG) const char* EMK_STR = "EgtMachKernelD32.dll ver. " ; #else const char* EMK_STR = "EgtMachKernelR32.dll ver. " ; #endif const int STR_DIM = 40 ; //----------------------------------------------------------------------------- static HINSTANCE s_hModule = NULL ; //----------------------------------------------------------------------------- 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 s_hModule = hModule ; EGT_TRACE( "EgtMachKernel.dll Initializing!\n") ; } else if ( dwReason == DLL_PROCESS_DETACH) { s_hModule = NULL ; EGT_TRACE( "EgtMachKernel.dll Terminating!\n") ; } return 1 ; } //----------------------------------------------------------------------------- const char* GetEMkVersion( void) { static char s_szEMkNameVer[STR_DIM] = "" ; if ( s_szEMkNameVer[0] == '\0') { static std::string sVer ; GetModuleVersion( s_hModule, sVer) ; sprintf_s( s_szEMkNameVer, STR_DIM, "%s%s", EMK_STR, sVer.c_str()) ; } return s_szEMkNameVer ; } //----------------------------------------------------------------------------- const std::string& GetEMkVer( void) { static std::string s_sVer ; if ( s_sVer.empty()) GetModuleVersion( s_hModule, s_sVer) ; return s_sVer ; } //----------------------------------------------------------------------------- static ILogger* s_pLogger = nullptr ; //----------------------------------------------------------------------------- void SetEMkLogger( ILogger* pLogger) { s_pLogger = pLogger ; } //----------------------------------------------------------------------------- ILogger* GetEMkLogger( void) { return s_pLogger ; } //----------------------------------------------------------------------------- static std::string s_sKey ; static bool s_bNetHwKey = false ; //----------------------------------------------------------------------------- void SetEMkKey( const std::string& sKey) { s_sKey = sKey ; } //----------------------------------------------------------------------------- void SetEMkNetHwKey( bool bNetHwKey) { s_bNetHwKey = bNetHwKey ; } //----------------------------------------------------------------------------- const std::string& GetEMkKey( void) { return s_sKey ; } //----------------------------------------------------------------------------- bool GetEMkNetHwKey( void) { return s_bNetHwKey ; }