Patch level : 2.2

Files correlati     : installa.exe
Ricompilazione Demo : [ ]
Commento            :
Supportate chiavi di eutron di sviluppo


git-svn-id: svn://10.65.10.50/trunk@13938 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2006-04-20 12:41:58 +00:00
parent b771db4b41
commit b01b5d7a1c

View File

@ -17,6 +17,10 @@ extern "C"
static HINSTANCE _hInstance = NULL; static HINSTANCE _hInstance = NULL;
static int _dongle_type = 0; static int _dongle_type = 0;
/****************************/
/* Utility */
/****************************/
void ErrorBox(LPCSTR str) void ErrorBox(LPCSTR str)
{ {
MessageBox(GetFocus(), str, "Installazione", MB_ICONSTOP|MB_OK); MessageBox(GetFocus(), str, "Installazione", MB_ICONSTOP|MB_OK);
@ -27,6 +31,19 @@ void WarningBox(LPCSTR str)
MessageBox(GetFocus(), str, "Installazione", MB_ICONEXCLAMATION|MB_OK); MessageBox(GetFocus(), str, "Installazione", MB_ICONEXCLAMATION|MB_OK);
} }
int ThisYear()
{
int anno = 2006;
time_t lt;
if (time(&lt) == 0)
{
struct tm* timeloc = localtime(&lt) ;
if (timeloc != NULL)
anno = timeloc->tm_year + 1900;
}
return anno;
}
/****************************/ /****************************/
/* Gestione chiave Hardlock */ /* Gestione chiave Hardlock */
/****************************/ /****************************/
@ -79,12 +96,15 @@ unsigned short EutronLogin(int& year)
{ {
unsigned short serno = 0xFFFF; unsigned short serno = 0xFFFF;
const char* const login[2] = { "AGA.CAMPO", "25EBAI" };
for (int i = 0; i < 2; i++)
{
KEY_NET eutron_key; KEY_NET eutron_key;
memset(&eutron_key, 0, sizeof(KEY_NET)); memset(&eutron_key, 0, sizeof(KEY_NET));
eutron_key.net_command = NET_KEY_OPEN; eutron_key.net_command = NET_KEY_OPEN;
eutron_key.command = LOCATING_MODE; eutron_key.command = LOCATING_MODE;
const char* chiaro = "AGA.CAMPO"; const char* const chiaro = login[i];
char cifrato[16]; char cifrato[16];
strcpy(cifrato, chiaro); strcpy(cifrato, chiaro);
EncodeEutronPassword(cifrato); EncodeEutronPassword(cifrato);
@ -107,10 +127,18 @@ unsigned short EutronLogin(int& year)
if (eutron_key.status == ST_OK) if (eutron_key.status == ST_OK)
{ {
serno = (unsigned short)atol((const char*)eutron_key.data+4); serno = (unsigned short)atol((const char*)eutron_key.data+4);
if (i == 0)
{
const unsigned short y = *(unsigned short*)(eutron_key.data+12); const unsigned short y = *(unsigned short*)(eutron_key.data+12);
if (y > 2000 && y < 3000) if (y > 2000 && y < 3000)
year = y; year = y;
} }
else
year = ThisYear();
break;
}
}
} }
return serno; return serno;
@ -120,9 +148,7 @@ unsigned short EutronLogin(int& year)
/* Gestione cifratura lista codici */ /* Gestione cifratura lista codici */
/***********************************/ /***********************************/
static char key[16] = ""; void BuildKey(char* key)
void BuildKey()
{ {
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
key[i] = 'A'+ rand()%26; key[i] = 'A'+ rand()%26;
@ -130,27 +156,16 @@ void BuildKey()
void DecodeString(char* data) void DecodeString(char* data)
{ {
char key[8] = "";
BuildKey(key);
char tmp[256]; char tmp[256];
BuildKey();
for (int i = 0; data[i]; i++) for (int i = 0; data[i]; i++)
tmp[i] = data[i] - (i < 8 ? key[i] : tmp[i - 8]); tmp[i] = data[i] - (i < 8 ? key[i] : tmp[i - 8]);
tmp[i] = '\0'; tmp[i] = '\0';
strcpy(data, tmp); strcpy(data, tmp);
} }
int ThisYear()
{
int anno = 2003;
time_t lt;
if (time(&lt) == 0)
{
struct tm* timeloc = localtime(&lt) ;
if (timeloc != NULL)
anno = timeloc->tm_year + 1900;
}
return anno;
}
int VersionYear() int VersionYear()
{ {
char ver[32]; char ver[32];
@ -497,8 +512,6 @@ BOOL InitApplication (HINSTANCE hinst)
int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hinstPrev, LPSTR pCmdLine, int nCmdShow) int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hinstPrev, LPSTR pCmdLine, int nCmdShow)
{ {
MSG msg;
if (!InitApplication(hInst)) // Register window class if (!InitApplication(hInst)) // Register window class
return 0; return 0;
@ -532,10 +545,10 @@ int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hinstPrev, LPSTR pCmdLine, int nC
CreateWindow("BUTTON", prompt, dwFlags, CreateWindow("BUTTON", prompt, dwFlags,
offx, offy+80, 300, 32, hwndDlg , (HMENU)1001, hInst, NULL ); offx, offy+80, 300, 32, hwndDlg , (HMENU)1001, hInst, NULL );
CreateWindow("BUTTON","Uscita", CreateWindow("BUTTON","Uscita",
WS_CHILD| WS_VISIBLE,offx,offy+160,300,32, hwndDlg ,(HMENU)2,hInst,NULL ); WS_CHILD| WS_VISIBLE,offx,offy+160,300,32, hwndDlg ,(HMENU)2,hInst,NULL );
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) while (GetMessage(&msg, NULL, 0, 0))
{ {
TranslateMessage(&msg); TranslateMessage(&msg);