From 816a3eb456534ada80c04945190bddd77d423c55 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 6 Oct 2010 13:32:08 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : Ricompilazione Demo : [ ] Commento : Eliminata gestione assistenza prepagata dalla chiave Eutron git-svn-id: svn://10.65.10.50/branches/R_10_00@20956 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/dongle.cpp | 148 +-------------------------------------------- include/dongle.h | 18 +----- 2 files changed, 5 insertions(+), 161 deletions(-) diff --git a/include/dongle.cpp b/include/dongle.cpp index 55ff78222..7c5f2e9d6 100755 --- a/include/dongle.cpp +++ b/include/dongle.cpp @@ -35,54 +35,8 @@ struct TEutronHeader unsigned short _size_of_bits; // 32 }; -struct TEutronFooter -{ - unsigned long _size; // Should be sizeof(TEutronFooter) - unsigned long _checksum; // Much smarter position than header - unsigned long _filler1; - unsigned long _filler2; - unsigned long _filler3; - unsigned long _filler4; - unsigned long _filler5; - unsigned long _last_assist; // Last date of assistance query - unsigned long _assistance[MAX_DONGLE_ASSIST]; // Pre-payed assistance - - unsigned long checksum(bool set); - bool valid(); - TEutronFooter(); -}; - #pragma pack(pop) -TEutronFooter::TEutronFooter() -{ - const int s = sizeof(TEutronFooter); - memset(&_size, 0, s); - _size = s; -} - -unsigned long TEutronFooter::checksum(bool set) -{ - if (set) _size = sizeof(TEutronFooter); - - const word offset = sizeof(_size) + sizeof(_checksum); - byte* ptr = (byte*)(&_size) + offset; - const word len = word(_size - offset); - - unsigned long cs = 0; - for (word i = 0; i < len; i++, ptr++) - cs += *ptr | ~(short(*ptr << 8)); - if (set) _checksum = cs; - return cs; -} - -bool TEutronFooter::valid() -{ - if (_size == 0 || _checksum == 0) - return false; - return _checksum == checksum(false); -} - /////////////////////////////////////////////////////////// // Current dongle /////////////////////////////////////////////////////////// @@ -139,7 +93,6 @@ TDongle::TDongle() _max_users(1), _year_assist(2009), _dirty(false), _OEM(-1) { memset(_eprom, 0, sizeof(_eprom)); - memset(_assist, 0, sizeof(_assist)); } TDongle::~TDongle() @@ -401,18 +354,7 @@ bool TDongle::eutron_login(bool test_all_keys) module++; } } - } - - memset(_assist, 0, sizeof(_assist)); // Azzera pre-pagato - TEutronFooter ef; - if (read_words(otb+sob, sizeof(ef)/2, (word*)&ef)) - { - if (ef.valid()) - { - _last_assist = ef._last_assist; - memcpy(_assist, ef._assistance, sizeof(_assist)); - } - } + } } else _dirty = true; @@ -848,17 +790,7 @@ bool TDongle::burn_eutron() } ok = write_words(otb, sob, data); } - - if (ok) - { - TEutronFooter ef; - CHECK(sizeof(ef._assistance) == sizeof(_assist), "Assistance size mismatch"); - ef._last_assist = _last_assist.year()*10000L + _last_assist.month()*100L + _last_assist.day(); - memcpy(ef._assistance, _assist, sizeof(_assist)); - ef.checksum(true); - ok = write_words(otb+sob, word(ef._size/2), (word*)&ef); - } - + return ok; } @@ -882,82 +814,6 @@ bool TDongle::burn() return ok; } -/* -#define BIT31 (1L<<31) -#define MSK31 (~BIT31) - -real TDongle::residual_assist(int index, bool lire) const -{ - real imp; - if (index >= 0 && index < MAX_DONGLE_ASSIST) - { - imp = (_assist[index] & MSK31) / 100.0; - if (lire) - { imp *= 1936.27; imp.round(-2); } - } - return imp; -} - -bool TDongle::can_require_assist(int index) const -{ - bool ok = false; - if (index >= 0 && index < MAX_DONGLE_ASSIST) - { - const TDate oggi(TODAY); - if (oggi == _last_assist) - ok = (_assist[index] & BIT31) == 0; - else - ok = oggi > _last_assist; - } - return ok; -} - -bool TDongle::require_assist(int index, real imp, bool lire) -{ - imp *= 100; - if (lire) { imp /= 1936.27; imp.round(2); } - - bool ok = false; - if (imp > ZERO) - { - if (can_require_assist(index)) - { - const TDate oggi(TODAY); - if (oggi > _last_assist) - { - for (int i = 0; i < MAX_DONGLE_ASSIST; i++) - _assist[index] &= MSK31; - _last_assist = oggi; - } - _assist[index] &= MSK31; - _assist[index] += imp.integer(); - _assist[index] |= BIT31; - _dirty = true; - ok = burn(); - } - } - return ok; -} - -bool TDongle::pay_assist(int index, real imp, bool lire) -{ - bool ok = imp > ZERO; - if (ok) - { - imp *= 100; - if (lire) { imp /= 1936.27; imp.round(2); } - - unsigned long old_bit31 = _assist[index] & BIT31; - _assist[index] &= MSK31; - _assist[index] -= imp.integer(); - _assist[index] |= old_bit31; - _dirty = true; - ok = burn(); - } - return ok; -} -*/ - const TString_array& TDongle::info() const { if (_info.items() == 0) diff --git a/include/dongle.h b/include/dongle.h index fa0e67734..b8525cb41 100755 --- a/include/dongle.h +++ b/include/dongle.h @@ -9,9 +9,8 @@ #include #endif -enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_network }; +enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_network, _dongle_hasp }; enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle }; -enum { MAX_DONGLE_ASSIST = 8 }; class TDongle : public TObject { @@ -28,9 +27,6 @@ class TDongle : public TObject TBit_array _shown; bool _dirty; - TDate _last_assist; - unsigned long _assist[MAX_DONGLE_ASSIST]; // Centesimi di Euro pre-pagati - TString_array _info; // Informazioni sui moduli protected: @@ -48,9 +44,7 @@ protected: public: // TObject virtual bool ok() const - { return _hardware != _dongle_unknown && - _type != _no_dongle && - _serno != 0xFFFF; } + { return _hardware != _dongle_unknown && _type != _no_dongle && _serno != 0xFFFF; } public: bool login(bool test_all_dongles = false); @@ -81,12 +75,6 @@ public: TDongleHardware hardware() const { return _hardware; } bool local() const { return _hardware == _dongle_hardlock || _hardware == _dongle_eutron; } bool network() const { return _hardware == _dongle_network; } - /* - real residual_assist(int index, bool lire) const; - bool can_require_assist(int index) const; - bool require_assist(int index, real imp, bool lire); - bool pay_assist(int index, real imp, bool lire); - */ const TString& administrator(TString* pwd = NULL) const; int oem() const; const TString& reseller() const; @@ -131,4 +119,4 @@ public: TDongle& dongle(); bool destroy_dongle(); -#endif \ No newline at end of file +#endif