Leaked source code of windows server 2003
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.

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