INT_PTR CALLBACK Registration::RegistrationProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { return TRUE; } case WM_COMMAND: { int wmId = LOWORD(wParam); int wmEvent = HIWORD(wParam); switch (wmId) { case IDC_BUTTON1: { EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON1), FALSE); char szName[16]; char szKeyIn[20]; unsigned int iLength = GetDlgItemText(hwndDlg, IDC_EDIT1, szName, sizeof(szName)); unsigned int iLengthKey = GetDlgItemText(hwndDlg, IDC_EDIT2, szKeyIn, sizeof(szKeyIn)); char szCorrectKey[20]; GenerateKey(szName, iLength, szCorrectKey); if (iLength < 8) { MessageBox(hwndDlg, "Your name is too short!\nIt has to be at least 8 characters long.", "Warning", 0); break; } if ((iLengthKey == 19) && (!strcmp(szCorrectKey, szKeyIn))) { // Correct SetRegistryKey<char*>(HKEY_CURRENT_USER, g_pszPath, "hack_username", REG_SZ, szName); SetRegistryKey<char*>(HKEY_CURRENT_USER, g_pszPath, "hack_key", REG_SZ, szKeyIn); CheckRegistration(); EndDialog(hwndDlg, 0); } else { MessageBox(hwndDlg, "Your Key is incorrect!\nTry Again", "Error", 0); } EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON1), TRUE); break; } } return TRUE; } case WM_CLOSE: { EndDialog(hwndDlg, 0); } } return FALSE; }
BOOL WINPROC EXPORT DlgRoomPuzzleStart (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam) { BOOL bHandled = TRUE; switch (wMsg) { case WM_COMMAND: switch (wParam) { case HS_PUZZLE_EASY: case IDOK: iHardness = 1; if (CheckRegistration (TRUE)) GoRoom (hInstAstral, RM_PUZZLE, FALSE); break; case HS_PUZZLE_TOUGH: iHardness = 2; if (CheckRegistration (TRUE)) GoRoom (hInstAstral, RM_PUZZLE, FALSE); break; case HS_PUZZLE_HARD: iHardness = 3; if (CheckRegistration (TRUE)) GoRoom (hInstAstral, RM_PUZZLE, FALSE); break; default: bHandled = FALSE; } break; default: bHandled = FALSE; } if (!bHandled) bHandled = DefRoomProc (hWnd,wMsg,wParam,lParam); return bHandled; }
GSM::RegistrationStatus GSM::isRegistered(void) { #define NUM_OF_ATTEMPT 40 #define TIME_OF_ATTRMPT 10000 DEBUG(F("Checking registration...")); RegistrationStatus retVal; for (int i = 0; i <= NUM_OF_ATTEMPT; i++) { retVal = CheckRegistration(); if (retVal == REG_REGISTERED) { #ifdef LEVEL_DEBUG char buff[40]; sprintf(buff, "Time is: %dms", i * (TIME_OF_ATTRMPT / NUM_OF_ATTEMPT)); DEBUG(buff); #endif break;; } if (i < NUM_OF_ATTEMPT) delay(TIME_OF_ATTRMPT/NUM_OF_ATTEMPT); else WARNING(F("Not Registered")); } #ifdef LEVEL_INFO char buff[40]; sprintf(buff, "Signal level is: %d (0-31 or 99)", getSignalLevel()); INFO(buff); #endif return retVal; }
extern "C" void __declspec(dllexport) GetRegistrationInfo(RegistrationInfo* info) { long size = 0; LONG ret = 0; time_t ltime = 0; time_t currTime = 0; memset(info, 0, sizeof(*info)); // get name size = sizeof(info->name); info->name[0] = 0; ret = RegQueryValue(HKEY_CLASSES_ROOT, RegKeyValues[3][0], (char*)&(info->name), &size); // get organization size = sizeof(info->organization); info->organization[0] = 0; ret = RegQueryValue(HKEY_CLASSES_ROOT, RegKeyValues[4][0], (char*)&(info->organization), &size); // get registration code static char regbuf[16]; size = sizeof(regbuf); regbuf[0] = 0; ret = RegQueryValue(HKEY_CLASSES_ROOT, RegKeyValues[5][0], (char*)®buf, &size); if (regbuf[0]) info->registrationCode = atoi(regbuf); // get timeout static char timeoutbuf[128]; size = sizeof(timeoutbuf); timeoutbuf[0] = 0; ret = RegQueryValue(HKEY_CLASSES_ROOT, TimeoutRegKeyValues[3][0], timeoutbuf, &size); if (ret != ERROR_SUCCESS) { // install 30 day evaluation time InstallTimeout(30); timeoutbuf[0] = 0; ret = RegQueryValue(HKEY_CLASSES_ROOT, TimeoutRegKeyValues[3][0], timeoutbuf, &size); } if (ret != ERROR_SUCCESS) { info->timeout = -1; info->daysRemaining = 0; } else if (timeoutbuf[0]) { currTime = time(<ime); info->timeout = atoi(timeoutbuf); info->daysRemaining = static_cast<int>(((time_t)(info->timeout) - currTime)) / (60 * 60 * 24); } info->version = CheckRegistration(info->name, info->organization, regbuf); info->isRegistered = (info->version >= 25); }