//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Main.h" #include "Des.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RXSpin" #pragma resource "*.dfm" TForm1 *Form1; typedef void WINAPI (*THASP)(int Service, int SeedCode, int LptNum, int Pass1, int Pass2, int *p1, int *p2, int *p3, int *p4); //--------------------------------------------------------------------------- #define IS_HASP 1 #define GET_HASP_CODE 2 #define READ_MEMO 3 #define WRITE_MEMO 4 #define GET_HASP_STATUS 5 #define GET_ID_NUM 6 #define READ_MEMO_BLOCK 50 #define WRITE_MEMO_BLOCK 51 //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { HINSTANCE hLibrary = NULL; THASP hasp = NULL; unsigned char blk[8], key[14][13] = { " ", "eUvJ-nvh?aq9", "EmTxOX'60af#", "i'/[E15)'FU9", "5sv1Bt<_M,c!", "KF/ZPw7Value; /* * Check if any HASP is connected */ hasp( IS_HASP, SeedCode, 0, Pass1, Pass2, &p1, &p2, &p3, &p4 ); if ( p1 == 0 ) { ShowMessage( "No HASP key was found." ); goto fail; } /* * Get HASP code */ hasp(GET_HASP_CODE, SeedCode, 0, Pass1, Pass2, &Pass[0], &Pass[1], &Pass[2], &p4); blk[0] = SeedCode & 0xFF; blk[1] = (SeedCode >> 8) & 0xFF; blk[2] = Pass[0] & 0xFF; blk[3] = (Pass[0] >> 8) & 0xFF; blk[4] = Pass[1] & 0xFF; blk[5] = (Pass[1] >> 8) & 0xFF; blk[6] = Pass[2] & 0xFF; blk[7] = (Pass[2] >> 8) & 0xFF; encrypt(k, blk); Label1->Caption = Format("Password : %d - %d - %d - %d", OPENARRAY(TVarRec, ((blk[1]<<8)|blk[0], (blk[3]<<8)|blk[2], (blk[5]<<8)|blk[4], (blk[7]<<8)|blk[6]))); p2 = 0; if (CheckBox1->Checked) p2 |= 1; if (CheckBox2->Checked) p2 |= 2; if (CheckBox3->Checked) p2 |= 4; if (CheckBox4->Checked) p2 |= 8; if (CheckBox5->Checked) p2 |= 0x10; if (CheckBox6->Checked) p2 |= 0x20; /* * Write word to memory */ p1 = 0; /* Address */ hasp( WRITE_MEMO, SeedCode, 0, Pass1, Pass2, &p1, &p2, &p3, &p4); if ( p3 != 0 ) { ShowMessage(Format( "Write operation failed. Error number: %d.\n", OPENARRAY(TVarRec, (p3))) ); goto fail; } /* Report_Tool ÀÇ HASP Check (»õ·Î¿î °ªÀ» ±â¾ï)*/ if (CheckBox7->Checked) { p1 = 2; // Address p2 = 1; // ReportTool À» Check °ªÀ» ±â¾ï½ÃŲ´Ù. hasp( WRITE_MEMO, SeedCode, 0, Pass1, Pass2, &p1, &p2, &p3, &p4); if ( p3 != 0 ) { ShowMessage(Format( "Write operation failed. Error number: %d.\n", OPENARRAY(TVarRec, (p3))) ); goto fail; } } else { p1 = 2; // Address p2 = 0; // °ªÀ» ÃʱâÈ­ ½ÃŲ´Ù. hasp( WRITE_MEMO, SeedCode, 0, Pass1, Pass2, &p1, &p2, &p3, &p4); if ( p3 != 0 ) { ShowMessage(Format( "Write operation failed. Error number: %d.\n", OPENARRAY(TVarRec, (p3))) ); goto fail; } } /* Professional(0), Education(1), Demo(2), Academy(3)¿ëÀ¸·Î ±¸º° */ p2 = RadioGroup1->ItemIndex; /* * Write word to memory */ p1 = 1; /* Address */ hasp( WRITE_MEMO, SeedCode, 0, Pass1, Pass2, &p1, &p2, &p3, &p4); if ( p3 != 0 ) { ShowMessage(Format( "Write operation failed. Error number: %d.\n", OPENARRAY(TVarRec, (p3))) ); goto fail; } for (i=1; i<=13; i++) { p1 = i*4; strcpy(key[0], key[i]); blk[0] = SeedCode & 0xFF; blk[1] = (SeedCode >> 8) & 0xFF; blk[2] = Pass[0] & 0xFF; blk[3] = (Pass[0] >> 8) & 0xFF; blk[4] = Pass[1] & 0xFF; blk[5] = (Pass[1] >> 8) & 0xFF; blk[6] = Pass[2] & 0xFF; blk[7] = (Pass[2] >> 8) & 0xFF; encrypt(key[0], blk); p2 = 4; p4 = (int)blk; hasp(WRITE_MEMO_BLOCK, SeedCode, 0, Pass1, Pass2, &p1, &p2, &p3, &p4); } FreeLibrary(hLibrary); return; fail: if (hLibrary) FreeLibrary(hLibrary); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { Application->Terminate(); } //---------------------------------------------------------------------------