Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
4.5 KiB

  1. #include <windows.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <io.h>
  5. #include <fcntl.h>
  6. #include "..\..\inc\pidgen.h"
  7. #include "..\inc\DigPid.h"
  8. extern "C" extern WORD _C000H;
  9. extern "C" extern WORD _F000H;
  10. // LPBYTE lpbSystemBiosRom = (LPBYTE)MAKELONG(0, &_F000H);
  11. // LPBYTE lpbVideoBiosRom = (LPBYTE)MAKELONG(0, &_C000H);
  12. int PASCAL WinMain(
  13. HINSTANCE hInstance,
  14. HINSTANCE hPrevInstance,
  15. LPSTR lpszCmdLine,
  16. int cmdShow)
  17. {
  18. BOOL fOk;
  19. ////char *lpszProductKey;
  20. char achPid2[32];
  21. BYTE abPid3[DIGITALPIDMAXLEN];
  22. DWORD dwSeq = 0;
  23. BOOL fCCP = FALSE;
  24. BOOL fPSS = FALSE;
  25. int iValidCnt = 0;
  26. int iKeyCnt = 0;
  27. char szLineBuf[128];
  28. char szMsgBuf[128];
  29. FILE *pfIn = NULL;
  30. LPDIGITALPID pdp = (LPDIGITALPID) abPid3;
  31. #if 0 /////////////////////////////////
  32. if (argc <= 1)
  33. {
  34. lpszProductKey = "PXGAD-G3CCE-G8DB8-PPXFT-DRPY3";
  35. //// lpszProductKey = "GRHQ2-CDPWX-WWJBT-RXWFG-6CXCT";
  36. }
  37. else
  38. {
  39. lpszProductKey = argv[1]
  40. }
  41. #endif ////////////////////////////////
  42. pfIn = fopen(lpszCmdLine,"r");
  43. if (NULL == pfIn)
  44. {
  45. sprintf(
  46. szMsgBuf,
  47. "Error: unable to open file '%s'\n",
  48. (char *)lpszCmdLine);
  49. MessageBoxA(
  50. NULL,
  51. (char *)szMsgBuf,
  52. "Doh!",
  53. MB_OK);
  54. }
  55. else
  56. {
  57. while (NULL != fgets(szLineBuf, sizeof(szLineBuf), pfIn))
  58. {
  59. szLineBuf[39] = '\0';
  60. ++iKeyCnt;
  61. *(LPDWORD)abPid3 = sizeof(abPid3);
  62. fOk = PIDGen(
  63. &szLineBuf[10], // [IN] 25-character Secure CD-Key (gets U-Cased)
  64. "12345", // [IN] 5-character Release Product Code
  65. "123-12345", // [IN] Stock Keeping Unit (formatted like 123-12345)
  66. "MSFT", // [IN] 4-character OEM ID or NULL
  67. NULL, // [IN] 24-character ordered set to use for decode base conversion or NULL for default set (gets U-Cased)
  68. NULL, // [IN] pointer to optional public key or NULL
  69. 0, // [IN] byte length of optional public key
  70. 0, // [IN] key index of optional public key
  71. FALSE, // [IN] is this an OEM install?
  72. achPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
  73. abPid3, // [OUT] pointer to binary PID3 buffer. First DWORD is the length.
  74. &dwSeq, // [OUT] optional ptr to sequence number (can be NULL)
  75. &fCCP, // [OUT] optional ptr to Compliance Checking flag (can be NULL)
  76. &fPSS); // [OUT] optional ptr to 'PSS Assigned' flag (can be NULL)
  77. if (fOk)
  78. {
  79. ++iValidCnt;
  80. }
  81. else
  82. {
  83. sprintf(
  84. szMsgBuf,
  85. "Warning: failure to validate %s\n",
  86. &szLineBuf[10]);
  87. MessageBoxA(
  88. NULL,
  89. szMsgBuf,
  90. "Doh!",
  91. MB_OK);
  92. }
  93. }
  94. sprintf(
  95. szMsgBuf,
  96. "Info: %d successful validations out of %d Product Keys\n",
  97. (int)iValidCnt,
  98. (int)iKeyCnt);
  99. MessageBoxA(
  100. NULL,
  101. (char *)szMsgBuf,
  102. (iValidCnt == iKeyCnt) ? "Woo Hoo!" : "Doh!",
  103. MB_OK);
  104. }
  105. #if 0 /////////////////////////////////
  106. FILE *pf = fopen("test.dpi", "wb");
  107. fwrite(pdp, sizeof(*pdp), 1, pf);
  108. fclose(pf);
  109. MessageBox(
  110. NULL,
  111. (char *)&abPid3[8],
  112. fOk ? "Woo Hoo!" : "Doh!",
  113. MB_OK);
  114. if (fOk)
  115. {
  116. MessageBox(
  117. NULL,
  118. (char *)pdp->aszHardwareIdStatic,
  119. "Woo Hoo!",
  120. MB_OK);
  121. char szMessage[128];
  122. wsprintf(
  123. szMessage,
  124. "seq: %ld, %s%s - lictype: %ld",
  125. dwSeq,
  126. (fCCP) ? "CCP" : "FPP",
  127. (fPSS) ? ", PSS" : "",
  128. (LONG)pdp->dwlt);
  129. MessageBox(
  130. NULL,
  131. szMessage,
  132. (char *)&abPid3[8],
  133. MB_OK);
  134. }
  135. #endif ////////////////////////////////
  136. return 0;
  137. }