15633ec6d7
- modifiche per spostamento import/export da dll Exchange a dll Exch3dm.
182 lines
5.5 KiB
C++
182 lines
5.5 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2023-2023
|
|
//----------------------------------------------------------------------------
|
|
// File : DllExch3dm.cpp Data : 14.11.23 Versione : 2.5k2
|
|
// Contenuto : Funzioni di gestione della libreria opzionale EgtExch3dme.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 14.11.23 DS Creazione modulo.
|
|
//
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "DllExch3dm.h"
|
|
#include "/EgtDev/Include/EE3DllMain.h"
|
|
#define NOMINMAX
|
|
#include <windows.h>
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Nome della libreria
|
|
#if defined( _WIN64) && defined( _DEBUG)
|
|
static const wchar_t* EE3_NAME = L"EgtExch3dmD64.dll" ;
|
|
#elif defined( _WIN64)
|
|
static const wchar_t* EE3_NAME = L"EgtExch3dmR64.dll" ;
|
|
#elif defined( _WIN32) && defined( _DEBUG)
|
|
static const wchar_t* EE3_NAME = L"EgtExch3dmD32.dll" ;
|
|
#else
|
|
static const wchar_t* EE3_NAME = L"EgtExch3dmR32.dll" ;
|
|
#endif
|
|
// Nome delle funzioni caricate
|
|
static const char* EE3_SETEE3LOGGER = "SetEE3Logger" ;
|
|
static const char* EE3_GETEE3VERSION = "GetEE3Version" ;
|
|
static const char* EE3_SETEE3KEY = "SetEE3Key" ;
|
|
static const char* EE3_SETEE3NETHWKEY = "SetEE3NetHwKey" ;
|
|
static const char* EE3_CREATEIMPORT3DM = "CreateImport3dm" ;
|
|
static const char* EE3_CREATEEXPORT3DM = "CreateExport3dm" ;
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
HMODULE s_hEE3 = nullptr ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
LoadExch3dmDll( ILogger* pLogger, const string& sKey, bool bNetHwKey)
|
|
{
|
|
// verifico la chiave
|
|
if ( ! TestKeyForEE3( sKey, 0, pLogger)) {
|
|
FreeExch3dmDll() ;
|
|
return false ;
|
|
}
|
|
// se già caricata
|
|
if ( s_hEE3 != nullptr)
|
|
return true ;
|
|
// carico la libreria EgtExch3dm
|
|
s_hEE3 = LoadLibrary( EE3_NAME) ;
|
|
if ( s_hEE3 == nullptr)
|
|
return false ;
|
|
// imposto logger
|
|
MySetEE3Logger( pLogger) ;
|
|
// imposto i codici della chiave
|
|
MySetEE3Key( sKey) ;
|
|
// imposto eventuale chiave di rete
|
|
MySetEE3NetHwKey( bNetHwKey) ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
FreeExch3dmDll( void)
|
|
{
|
|
// se non è già caricata
|
|
if ( s_hEE3 == nullptr)
|
|
return true ;
|
|
// libero la libreria EgtExch3dm
|
|
FreeLibrary( s_hEE3) ;
|
|
s_hEE3 = nullptr ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
IsLoadedExch3dmDll( void)
|
|
{
|
|
return ( s_hEE3 != nullptr) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
MySetEE3Logger( ILogger* pLogger)
|
|
{
|
|
// verifico caricamento libreria EgtExch3dm
|
|
if ( s_hEE3 == nullptr)
|
|
return ;
|
|
// recupero funzione che imposta il logger
|
|
typedef void (* PF_SetEE3Logger) ( ILogger* pLogger) ;
|
|
PF_SetEE3Logger pFun = (PF_SetEE3Logger)GetProcAddress( s_hEE3, EE3_SETEE3LOGGER) ;
|
|
if ( pFun == nullptr)
|
|
return ;
|
|
pFun( pLogger) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
const char*
|
|
MyGetEE3Version( void)
|
|
{
|
|
// verifico caricamento libreria EgtExch3dm
|
|
if ( s_hEE3 == nullptr)
|
|
return "" ;
|
|
// recupero funzione che restituisce la versione della libreria
|
|
typedef const char* (* PF_GetEE3Version) ( void) ;
|
|
PF_GetEE3Version pFun = (PF_GetEE3Version)GetProcAddress( s_hEE3, EE3_GETEE3VERSION) ;
|
|
if ( pFun == nullptr)
|
|
return "" ;
|
|
return pFun() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
MySetEE3Key( const string& sKey)
|
|
{
|
|
// verifico caricamento libreria EgtExch3dm
|
|
if ( s_hEE3 == nullptr)
|
|
return ;
|
|
// recupero funzione che imposta i codici di protezione
|
|
typedef void (* PF_SetEE3Key) ( const string& sKey) ;
|
|
PF_SetEE3Key pFun = (PF_SetEE3Key)GetProcAddress( s_hEE3, EE3_SETEE3KEY) ;
|
|
if ( pFun == nullptr)
|
|
return ;
|
|
pFun( sKey) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
MySetEE3NetHwKey( bool bNetHwKey)
|
|
{
|
|
// verifico caricamento libreria EgtExch3dm
|
|
if ( s_hEE3 == nullptr)
|
|
return ;
|
|
// recupero funzione che imposta il flag per chiave di rete
|
|
typedef void (* PF_SetEE3NetHwKey) ( bool bNetHwKey) ;
|
|
PF_SetEE3NetHwKey pFun = (PF_SetEE3NetHwKey)GetProcAddress( s_hEE3, EE3_SETEE3NETHWKEY) ;
|
|
if ( pFun == nullptr)
|
|
return ;
|
|
pFun( bNetHwKey) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
IImport3dm*
|
|
MyCreateImport3dm( void)
|
|
{
|
|
// verifico caricamento libreria EgtExch3dm
|
|
if ( s_hEE3 == nullptr)
|
|
return nullptr ;
|
|
// recupero funzione creazione oggetto
|
|
typedef IImport3dm* (* PF_CreateImport3dm) ( void) ;
|
|
PF_CreateImport3dm pFun = (PF_CreateImport3dm)GetProcAddress( s_hEE3, EE3_CREATEIMPORT3DM) ;
|
|
if ( pFun == nullptr)
|
|
return nullptr ;
|
|
return pFun() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
IExport3dm*
|
|
MyCreateExport3dm( void)
|
|
{
|
|
// verifico caricamento libreria EgtExch3dm
|
|
if ( s_hEE3 == nullptr)
|
|
return nullptr ;
|
|
// recupero funzione creazione oggetto
|
|
typedef IExport3dm* (* PF_CreateExport3dm) ( void) ;
|
|
PF_CreateExport3dm pFun = (PF_CreateExport3dm)GetProcAddress( s_hEE3, EE3_CREATEEXPORT3DM) ;
|
|
if ( pFun == nullptr)
|
|
return nullptr ;
|
|
return pFun() ;
|
|
}
|