Files
EgtMachKernel/EMkDllMain.cpp
DarioS 156f0f8ef8 EgtMachKernel 2.4e3 :
- modifiche per prima versione chiave di rete.
2022-05-17 08:26:38 +02:00

130 lines
3.6 KiB
C++

//----------------------------------------------------------------------------
// 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 ;
static char s_szEMkNameVer[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
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)
{
std::string sVer ;
GetModuleVersion( s_hModule, sVer) ;
sprintf_s( s_szEMkNameVer, STR_DIM, "%s%s", EMK_STR, sVer.c_str()) ;
return s_szEMkNameVer ;
}
//-----------------------------------------------------------------------------
std::string
GetEMkVer( void)
{
std::string sVer ;
GetModuleVersion( s_hModule, sVer) ;
return 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 ;
}