EgtInterface 1.6c9 :
- EgtGraphics, EgtExchange ed EgtMachKernel sono caricabili opzionalmente.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DllMachKernel.cpp Data : 27.03.15 Versione : 1.6c9
|
||||
// Contenuto : Funzioni di gestione della libreria opzionale EgtMachKernel.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.03.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMachKernel.h"
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Nome della libreria
|
||||
#if defined( _WIN64) && defined( _DEBUG)
|
||||
static const wchar_t* EMK_NAME = L"EgtMachKernelD64.dll" ;
|
||||
#elif defined( _WIN64)
|
||||
static const wchar_t* EMK_NAME = L"EgtMachKernelR64.dll" ;
|
||||
#elif defined( _WIN32) && defined( _DEBUG)
|
||||
static const wchar_t* EMK_NAME = L"EgtMachKernelD32.dll" ;
|
||||
#else
|
||||
static const wchar_t* EMK_NAME = L"EgtMachKernelR32.dll" ;
|
||||
#endif
|
||||
// Nome delle funzioni caricate
|
||||
static const char* EMK_SETEMKLOGGER = "SetEMkLogger" ;
|
||||
static const char* EMK_GETEMKVERSION = "GetEMkVersion" ;
|
||||
static const char* EMK_SETEMKKEY = "SetEMkKey" ;
|
||||
static const char* EMK_CREATEMACHMGR = "CreateMachMgr" ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HMODULE s_hEMk = nullptr ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
LoadMachKernelDll( void)
|
||||
{
|
||||
// se già caricata
|
||||
if ( s_hEMk != nullptr)
|
||||
return true ;
|
||||
// carico la libreria EgtMachKernel
|
||||
s_hEMk = LoadLibrary( EMK_NAME) ;
|
||||
return ( s_hEMk != nullptr) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
FreeMachKernelDll( void)
|
||||
{
|
||||
// se non è già caricata
|
||||
if ( s_hEMk == nullptr)
|
||||
return true ;
|
||||
// libero la libreria EgtMachKernel
|
||||
FreeLibrary( s_hEMk) ;
|
||||
s_hEMk = nullptr ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
IsLoadedMachKernelDll( void)
|
||||
{
|
||||
return ( s_hEMk != nullptr) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MySetEMkLogger( ILogger* pLogger)
|
||||
{
|
||||
// verifico caricamento libreria MachMgr
|
||||
if ( s_hEMk == nullptr)
|
||||
return ;
|
||||
// recupero funzione che imposta il logger
|
||||
typedef void (* PF_SetEMkLogger) ( ILogger* pLogger) ;
|
||||
PF_SetEMkLogger pFun = (PF_SetEMkLogger)GetProcAddress( s_hEMk, EMK_SETEMKLOGGER) ;
|
||||
if ( pFun == nullptr)
|
||||
return ;
|
||||
pFun( pLogger) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const char*
|
||||
MyGetEMkVersion( void)
|
||||
{
|
||||
// verifico caricamento libreria MachMgr
|
||||
if ( s_hEMk == nullptr)
|
||||
return "" ;
|
||||
// recupero funzione che restituisce la versione della libreria
|
||||
typedef const char* (* PF_GetEMkVersion) ( void) ;
|
||||
PF_GetEMkVersion pFun = (PF_GetEMkVersion)GetProcAddress( s_hEMk, EMK_GETEMKVERSION) ;
|
||||
if ( pFun == nullptr)
|
||||
return "" ;
|
||||
return pFun() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MySetEMkKey( const string& sKey)
|
||||
{
|
||||
// verifico caricamento libreria MachMgr
|
||||
if ( s_hEMk == nullptr)
|
||||
return ;
|
||||
// recupero funzione che imposta i codici di protezione
|
||||
typedef void (* PF_SetEMkKey) ( const string& sKey) ;
|
||||
PF_SetEMkKey pFun = (PF_SetEMkKey)GetProcAddress( s_hEMk, EMK_SETEMKKEY) ;
|
||||
if ( pFun == nullptr)
|
||||
return ;
|
||||
pFun( sKey) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMachMgr*
|
||||
MyCreateMachMgr( void)
|
||||
{
|
||||
// verifico caricamento libreria MachMgr
|
||||
if ( s_hEMk == nullptr)
|
||||
return nullptr ;
|
||||
// recupero funzione creazione oggetto
|
||||
typedef IMachMgr* (* PF_CreateMachMgr) ( void) ;
|
||||
PF_CreateMachMgr pFun = (PF_CreateMachMgr)GetProcAddress( s_hEMk, EMK_CREATEMACHMGR) ;
|
||||
if ( pFun == nullptr)
|
||||
return nullptr ;
|
||||
return pFun() ;
|
||||
}
|
||||
Reference in New Issue
Block a user