#ifdef HASPSRM //--------------------------------------------------------------------------- #include #pragma hdrstop #include #include #include #include "HaspCheckThread.h" #include "define.h" #include "Common.h" #pragma package(smart_init) //--------------------------------------------------------------------------- // Important: Methods and properties of objects in VCL can only be // used in a method called using Synchronize, for example: // // Synchronize(&UpdateCaption); // // where UpdateCaption could look like: // // void __fastcall THaspCheckThread::UpdateCaption() // { // Form1->Caption = "Updated in a thread"; // } //--------------------------------------------------------------------------- __fastcall THaspCheckThread::THaspCheckThread(EHaspProgramIndex Index, String ProgramVersion) : TThread(false) { Priority = tpTimeCritical; index = Index; programVersion = ProgramVersion; FreeOnTerminate = true;//ÀÚµ¿À¸·Î »èÁ¦ µÇµµ·Ï ó¸® (false¸é ÀÚµ¿À¸·Î »èÁ¦ µÇÁö ¾Ê´Â´Ù.) } //--------------------------------------------------------------------------- void __fastcall THaspCheckThread::Execute() { //---- Place thread code here ---- //Synchronize(&isHacked); isHacked(); } //--------------------------------------------------------------------------- void __fastcall THaspCheckThread::isHacked() { while(ProtectCard->LockIsHacked) { Sleep(100); }; ProtectCard->LockIsHacked = true; TRegIniFile *RegIniFile = NULL; AnsiString pw; //unsigned char blk[8] = {0}; //unsigned char k[8] = { 'T', 'E', 'X', 'p', 'i', 'a', 0, 0 }; int pw_bySerial[4] = {0}, stNo = 0; unsigned char data[112] = {0}; unsigned char pbData[112] = {0}; ProtectCard->IsHacking = false; if (!ProtectCard->Login()) goto fail; //if (!GetHaspID()) goto fail; if (!ProtectCard->Hasp_Read(data)) goto fail; if (!ProtectCard->DecryptData(data, pbData)) goto fail; //if (!Get8Bytes_ForSerial(pbData)) goto fail; if (!ProtectCard->Get8Bytes_ForSerialOld(pbData)) goto fail; stNo = pbData[0]; memset(ProtectCard->program, 0, sizeof(unsigned char)*6); memset(ProtectCard->version, 0, sizeof(unsigned char)*30); memcpy(ProtectCard->program, &pbData[2+stNo], 5); memcpy(ProtectCard->version, &pbData[7+stNo], 29); if (!ProtectCard->isProgram(index)) goto fail; if (ProtectCard->getVersion() != programVersion) goto fail; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); if (RegIniFile) { pw = RegIniFile->ReadString("Common", "Serial", ""); sscanf(pw.c_str(), "%d-%d-%d-%d", &Password[0], &Password[1], &Password[2], &Password[3]); delete RegIniFile; RegIniFile = NULL; } if (Password[0] != ProtectCard->serial[0] || Password[1] != ProtectCard->serial[1] || Password[2] != ProtectCard->serial[2] || Password[3] != ProtectCard->serial[3]) { Application->MessageBox("Serial No. is invalid!", "Warning", MB_OK); ProtectCard->IsHacking = true; //ÇØÅ· } #ifdef NETHASP if (!ProtectCard->isNetHasp()) ProtectCard->IsHacking = true; #else if (ProtectCard->isNetHasp()) ProtectCard->IsHacking = true; #endif ProtectCard->LockIsHacked = false; return; fail: if (RegIniFile) delete RegIniFile; RegIniFile = NULL; ProtectCard->IsHacking = true; ProtectCard->LockIsHacked = false; return; } //--------------------------------------------------------------------------- #endif