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.

212 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1998-1999, Microsoft Corporation
  3. Module Name:
  4. PIDGen.h
  5. Abstract:
  6. public header
  7. --*/
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #if defined(WIN32) || defined(_WIN32)
  12. #ifdef UNICODE
  13. #define PIDGen PIDGenW
  14. #define PIDGenSimp PIDGenSimpW
  15. #else
  16. #define PIDGen PIDGenA
  17. #define PIDGenSimp PIDGenSimpA
  18. #endif // UNICODE
  19. #else
  20. #include <string.h>
  21. #include <compobj.h>
  22. typedef BOOL NEAR *PBOOL;
  23. typedef BOOL FAR *LPBOOL;
  24. typedef FILETIME FAR *LPFILETIME;
  25. #define PIDGenA PIDGen
  26. #define lstrlenA lstrlen
  27. #define lstrcpyA lstrcpy
  28. #define wsprintfA wsprintf
  29. #define TEXT(s) __T(s)
  30. #define ZeroMemory(pb, cb) memset(pb, 0, cb)
  31. #define CopyMemory(pb, ab, cb) memcpy(pb, ab, cb)
  32. #endif // defined(WIN32) || defined(_WIN32)
  33. #define DIGITALPIDMAXLEN 256 // Max length of digital PID 3.0 data blob
  34. #define INVALID_PID 0xFFFFFFFF
  35. // PidGenSimp error code values
  36. enum PidGenError { // pge
  37. // Call succeded
  38. pgeSuccess = 0,
  39. // Unable to validate product key. Most likely causes:
  40. // * Product Key was mistyped by user
  41. // * Product Key not compatable with this .dll (wrong GroupId)
  42. pgeProductKeyInvalid = 1,
  43. // Product Key's sequence number is not allowed by this .dll.
  44. // Most likely causes:
  45. // * Using Select or MSDN key with a PidGen/PidCa
  46. // that specifically excludes them
  47. pgeProductKeyExcluded = 2,
  48. // NULL was passed in for the required Product Key. (Must
  49. // point to valid Product key.)
  50. pgeProductKeyNull = 3,
  51. // Product Key is wrong length. After removing any dashes, the length
  52. // is required to be 25 characters
  53. pgeProductKeyBadLen = 4,
  54. // NULL was passed in for the required SKU. (Must point to
  55. // valid SKU.)
  56. pgeSkuNull = 5,
  57. // SKU is wrong length (too long).
  58. pgeSkuBadLen = 6,
  59. // NULL was passed in for the required PID2. (Must
  60. // point to buffer for return PID.)
  61. pgePid2Null = 7,
  62. // NULL was passed in for the required DigPid. (Must
  63. // point to buffer for generated DigitalPID.)
  64. pgeDigPidNull = 8,
  65. // DigPid is wrong length (too small).
  66. pgeDigPidBadLen = 9,
  67. // NULL was passed in for the required MPC.
  68. pgeMpcNull = 10,
  69. // MPC is wrong length. Must be exactly 5 characters.
  70. pgeMpcBadLen = 11,
  71. // OemId is bad. If passed (it's not required) it must
  72. // be 4 characters.
  73. pgeOemIdBadLen = 12,
  74. // Local char set is bad. If provided, must be 24 characters.
  75. pgeLocalBad = 13,
  76. };
  77. /*++
  78. Routine Description:
  79. This routine will determine if a sequence is valid for a particular sku.
  80. Return Value:
  81. pgeSuccess if sequence is in range.
  82. pgeProductKeyExcluded if sequence is not in range.
  83. pgeProductKeyInvalid if range table not found.
  84. --*/
  85. DWORD STDAPICALLTYPE VerifyPIDSequenceW(
  86. IN BOOL fOem, // [IN] is this an OEM install?
  87. IN DWORD dwSeq, // [IN] Sequence to check.
  88. IN PCWSTR pszSKU // [IN] Null terminated string for the SKU
  89. );
  90. // Original, outdated, interface to PidGen
  91. BOOL STDAPICALLTYPE PIDGenA(
  92. LPSTR lpstrSecureCdKey, // [IN] 25-character Secure CD-Key (gets U-Cased)
  93. LPCSTR lpstrMpc, // [IN] 5-character Microsoft Product Code
  94. LPCSTR lpstrSku, // [IN] Stock Keeping Unit (formatted like 123-12345)
  95. LPCSTR lpstrOemId, // [IN] 4-character OEM ID or NULL
  96. LPSTR lpstrLocal24, // [IN] 24-character ordered set to use for decode base conversion or NULL for default set (gets U-Cased)
  97. LPBYTE lpbPublicKey, // [IN] pointer to optional public key or NULL
  98. DWORD dwcbPublicKey, // [IN] byte length of optional public key
  99. DWORD dwKeyIdx, // [IN] key pair index optional public key
  100. BOOL fOem, // [IN] is this an OEM install?
  101. LPSTR lpstrPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
  102. LPBYTE lpbDigPid, // [IN/OUT] pointer to DigitalPID buffer. First DWORD is the length
  103. LPDWORD lpdwSeq, // [OUT] optional ptr to sequence number (can be NULL)
  104. LPBOOL pfCCP, // [OUT] optional ptr to Compliance Checking flag (can be NULL)
  105. LPBOOL pfPSS); // [OUT] optional ptr to 'PSS Assigned' flag (can be NULL)
  106. // Simplified interface to PidGen
  107. DWORD STDAPICALLTYPE PIDGenSimpA(
  108. LPSTR lpstrSecureCdKey, // [IN] 25-character Secure CD-Key (gets U-Cased)
  109. LPCSTR lpstrMpc, // [IN] 5-character Microsoft Product Code
  110. LPCSTR lpstrSku, // [IN] Stock Keeping Unit (formatted like 123-12345)
  111. LPCSTR lpstrOemId, // [IN] 4-character OEM ID or NULL
  112. BOOL fOem, // [IN] is this an OEM install?
  113. LPSTR lpstrPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
  114. LPBYTE lpbDigPid, // [IN/OUT] pointer to DigitalPID buffer. First DWORD is the length
  115. LPDWORD lpdwSeq, // [OUT] optional ptr to sequence number or NULL
  116. LPBOOL pfCCP); // [OUT] ptr to Compliance Checking flag or NULL
  117. #if defined(WIN32) || defined(_WIN32)
  118. // Original, outdated, interface to PidGen
  119. BOOL STDAPICALLTYPE PIDGenW(
  120. LPWSTR lpstrSecureCdKey, // [IN] 25-character Secure CD-Key (gets U-Cased)
  121. LPCWSTR lpstrMpc, // [IN] 5-character Microsoft Product Code
  122. LPCWSTR lpstrSku, // [IN] Stock Keeping Unit (formatted like 123-12345)
  123. LPCWSTR lpstrOemId, // [IN] 4-character OEM ID or NULL
  124. LPWSTR lpstrLocal24, // [IN] 24-character ordered set to use for decode base conversion or NULL for default set (gets U-Cased)
  125. LPBYTE lpbPublicKey, // [IN] pointer to optional public key or NULL
  126. DWORD dwcbPublicKey, // [IN] byte length of optional public key
  127. DWORD dwKeyIdx, // [IN] key pair index optional public key
  128. BOOL fOem, // [IN] is this an OEM install?
  129. LPWSTR lpstrPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
  130. LPBYTE lpbDigPid, // [IN/OUT] pointer to DigitalPID buffer. First DWORD is the length
  131. LPDWORD lpdwSeq, // [OUT] optional ptr to sequence number (can be NULL)
  132. LPBOOL pfCCP, // [OUT] optional ptr to Compliance Checking flag (can be NULL)
  133. LPBOOL pfPSS); // [OUT] optional ptr to 'PSS Assigned' flag (can be NULL)
  134. // Simplified interface to PidGen
  135. DWORD STDAPICALLTYPE PIDGenSimpW(
  136. LPWSTR lpstrSecureCdKey, // [IN] 25-character Secure CD-Key (gets U-Cased)
  137. LPCWSTR lpstrMpc, // [IN] 5-character Microsoft Product Code
  138. LPCWSTR lpstrSku, // [IN] Stock Keeping Unit (formatted like 123-12345)
  139. LPCWSTR lpstrOemId, // [IN] 4-character OEM ID or NULL
  140. BOOL fOem, // [IN] is this an OEM install?
  141. LPWSTR lpstrPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
  142. LPBYTE lpbDigPid, // [IN/OUT] pointer to DigitalPID buffer. First DWORD is the length
  143. LPDWORD lpdwSeq, // [OUT] optional ptr to sequence number or NULL
  144. LPBOOL pfCCP); // [OUT] ptr to Compliance Checking flag or NULL
  145. #endif // defined(WIN32) || defined(_WIN32)
  146. extern HINSTANCE g_hinst;
  147. #ifdef __cplusplus
  148. } /* End of extern "C" { */
  149. #endif /* __cplusplus */