keygen.cpp
上传用户:graphite
上传日期:2020-09-09
资源大小:2587k
文件大小:5k
源码类别:

破解

开发平台:

Others

  1. // keygen.cpp : Defines the entry point for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include "includeaspr_keygen.h"
  6. #define MAX_LOADSTRING                                  100
  7. #define RegistrationKeyGenerateName             "RegistrationKeyGenerate"
  8. typedef DWORD (__stdcall *ASPRegistrationKeyGenerate)(IN OUT PARAMS *Params);
  9. HINSTANCE KeyGenDll;
  10. ASPRegistrationKeyGenerate RegKeyGenerate;
  11. //---------------------------------------------------------------------
  12. // Source Code Template, KeyGen v0.01
  13. BOOL GenerateKey( LPSTR* KeyStr, LPSTR NameStr, DWORD& Res )
  14. {
  15.         PARAMS  P;
  16.         memset(&P, 0, sizeof(PARAMS));
  17.     // Registration name
  18.     P.RegName = NameStr;
  19.     // Mode number (1..15)
  20.     P.ModeID  = 2;
  21.     // Expiration date
  22.     P.ExpirationDate.Day   = 0;
  23.     P.ExpirationDate.Month = 0;
  24.     P.ExpirationDate.Year  = 0;
  25.     // Constant for encryption
  26.     P.EncryptionConst = 699935518;
  27.     // HardwareID
  28.     P.HardwareID      = "";
  29.     // Signature size in bits
  30.     P.SignatureBits   = 96;
  31.     // Constants from project file
  32.     P.C1 = 
  33.      "AC08B45461D28EB";
  34.     P.C3 = 
  35.      "A93A5FB8C78D04F1";
  36.     P.C6 = 
  37.      "26D6BB434014649375231C68A655B81D314AEAF3CE32C6DC8BD"
  38.      "CBCB9EEDC61EBA3C4A2119685E22205B782C88BFAF21FE98D4"
  39.      "474FBDB1AFA539B05F09EF60DDF5BA8224161942B9582D37DD"
  40.      "D624A97C373E5BB33BFC2335A674E4839D72253BA62B97F0B3"
  41.      "6BCA5B4001353FED5D28FED31FA53C343F381BE121E106F669"
  42.      "5B3CB";
  43.     P.C7 = 
  44.      "1726DAE1BD153379F1FB0F4F2E00C06D39A733B7715D108EF0C"
  45.      "518A11DF528394E37F744E1CEE1B4B411FEAFD7DDE0E281042"
  46.      "A728F85FEDB91C8C2ECECF31873C77D68053D550EB8549FDE2"
  47.      "C1885F40B68E1F0FF3383B747882AA517EB6F9061E23650222"
  48.      "85F1B1BEA91F83E2C4CD66BF0C636FC79B81A738D65D6F5BF8"
  49.      "0234D7";
  50.         memset(KeyStr, 0, 100 );
  51.         P.RegKey = (LPTSTR)KeyStr;      // Buffer for registration key
  52.         P.RegKeySize = 100;             // Size of a buffer for reg. key
  53.     // Generating...
  54.                 Res = RegKeyGenerate(&P);
  55.         if(Res == kgERROR_SUCCESS)
  56.         {
  57.                 memcpy(KeyStr, P.RegKey, P.RealKeySize);
  58.                 return TRUE;
  59.         }
  60.         else return FALSE;
  61. }
  62. //---------------------------------------------------------------------
  63. void ProcessRegistration( HWND hwnd )
  64. {
  65.         DWORD   Res;
  66.         char*   ResStr;
  67. char KeyStr[256];
  68. char NameStr[256];
  69. int size;
  70. size = GetDlgItemText(hwnd, IDC_REGNAME_EDIT, NameStr, 256);
  71. if (size > 0) NameStr[size] = 0;
  72.         memset(&KeyStr, 0, sizeof(KeyStr));
  73.         if(GenerateKey( (LPSTR*)KeyStr, (LPSTR)NameStr, Res ) == FALSE)
  74.         {
  75.                 switch (Res)
  76.                 {
  77.                         case kgERROR_KG_ERROR            : ResStr = "Key generator error!"; break;
  78.                         case kgERROR_MODE_UNKNOWN        : ResStr = "Unknown mode number!"; break;
  79.                         case kgERROR_REGNAME_ERROR       : ResStr = "Incorrect registration name!"; break;
  80.                         case kgERROR_SIGNATURE_ERROR     : ResStr = "Unknown mode signature!"; break;
  81.                         case kgERROR_BUFFER_TOO_SMALL    : ResStr = "Result buffer too small!"; break;
  82.                         case kgERROR_CONSTANTS_UNDEFINED : ResStr = "Incorrect constants!"; break;
  83.                         case kgERROR_HARDWAREID_ERROR    : ResStr = "Invalid HardwareID key!"; break;
  84.                 }
  85.                 MessageBox(hwnd, ResStr, "Error", MB_ICONINFORMATION);
  86.         }
  87.         else
  88.         {
  89.                 SetDlgItemText(hwnd, IDC_REGKEY_EDIT, KeyStr);
  90.         }
  91. }
  92. //---------------------------------------------------------------------
  93. BOOL APIENTRY DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  94. {
  95.         switch (msg) {
  96.                 // Cmd
  97. case WM_INITDIALOG:
  98. SetDlgItemText(hwnd, IDC_REGNAME_EDIT, "Registered User");
  99. return TRUE;
  100.         case WM_COMMAND:
  101. switch (LOWORD(wParam)) {
  102. case IDC_GENERATE:
  103. ProcessRegistration( hwnd );
  104. break;
  105.                 case IDC_EXIT:
  106.                     EndDialog(hwnd, IDC_EXIT);
  107.                     break;
  108.                 case IDCANCEL:
  109.                     EndDialog(hwnd, IDCANCEL);
  110.                     break;
  111.             }
  112.             break;
  113.     }
  114.     return FALSE;
  115. }
  116. //---------------------------------------------------------------------
  117. int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  118.                     PSTR szCmdLine, int iCmdShow){
  119.         // LoadLibrary "keygen.dll"
  120.         KeyGenDll = LoadLibrary("keygen.dll");
  121.         if(KeyGenDll == NULL)
  122.         {
  123.                 MessageBox(0, "keygen.dll not found!", "Error", MB_ICONSTOP);
  124.                 return 0;
  125.         }
  126.         // GetProcAddress "ASPRegistrationKeyGenerate"
  127.         RegKeyGenerate = (ASPRegistrationKeyGenerate)GetProcAddress(KeyGenDll, RegistrationKeyGenerateName);
  128.         if(RegKeyGenerate == NULL)
  129.         {
  130.                 MessageBox(0, "`ASPRegistrationKeyGenerate` function not found!", "Error", MB_ICONSTOP);
  131.                 FreeLibrary(KeyGenDll);
  132.                 return 0;
  133.         }
  134.         // DialogBox "IDD_DIALOG"
  135.         DialogBox(NULL,(LPSTR)MAKEINTRESOURCE(IDD_DIALOG),NULL,(DLGPROC/*WNDPROC*/)DlgProc);
  136.         if(KeyGenDll != NULL) FreeLibrary(KeyGenDll);
  137.         return 0;
  138. }