void GetKey() { TCHAR szKey[32]; memset(szKey, 0, sizeof(szKey)); LPCTSTR lpCharSet = _T("BCDFGHJKMPQRTVWXY2346789"); LPCTSTR lpKey = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"); LPCTSTR lpValue = _T("DigitalProductId"); HKEY hKey; LONG hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpKey, 0, KEY_READ, &hKey); if (hr == ERROR_SUCCESS) { // Определение размера данных "DigitalProductId" DWORD cbData; RegQueryValueEx(hKey, lpValue, 0, 0, 0, &cbData); PBYTE pData = (PBYTE)LocalAlloc(LPTR, cbData); if (pData) { // Чтение данных "DigitalProductId" hr = RegQueryValueEx(hKey, lpValue, 0, 0, pData, &cbData); if (hr == ERROR_SUCCESS) { PBYTE pCryptedKey = &pData[52]; int nCount = 24; // расшифровка ключа __asm { push edi; push esi; push ecx; Loop_1: xor ecx, ecx; mov edi, 0Eh; mov esi, pCryptedKey; Loop_2: xor edx, edx; mov eax, 2AAAAAABh; mov dl, byte ptr [esi+edi]; shl ecx, 8; add ecx, edx; imul ecx; sar edx, 2; mov eax, edx; shr eax, 1Fh; add edx, eax; mov eax, ecx; mov byte ptr [esi+edi], dl; mov ecx, 18h; cdq; idiv ecx; dec edi; mov ecx, edx; jns Loop_2; mov eax, lpCharSet; lea esi, szKey; #ifdef _UNICODE mov dx, word ptr [eax][2*ecx]; mov ecx, nCount; mov word ptr [esi][2*ecx], dx; #else mov dl, byte ptr [eax][ecx]; mov ecx, nCount; mov byte ptr [esi][ecx], dl; #endif dec ecx; mov nCount, ecx; jns Loop_1; pop ecx; pop esi; pop edi; } TRACE(_T("Key is: %.5s-%.5s-%.5s-%.5s-%.5s\n\n"), &szKey[0], &szKey[5], &szKey[10], &szKey[15], &szKey[20]); } LocalFree(pData); } RegCloseKey(hKey); } } |