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.

365 lines
12 KiB

  1. #ifndef _COMPLIANCE_H
  2. #define _COMPLIANCE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define EVAL_MPC TEXT("82503")
  7. #define SRV_NFR_MPC TEXT("51883")
  8. #define ASRV_NFR_MPC TEXT("51882")
  9. #define NT4SRV_NFR_MPC TEXT("51222")
  10. #ifdef KERNEL_MODE
  11. #define OEM_INSTALL_RPC L"OEM"
  12. #define SELECT_INSTALL_RPC L"270"
  13. #define MSDN_INSTALL_RPC L"335"
  14. #endif
  15. #define COMPLIANCE_INSTALLTYPE_UNKNOWN 0x00000000
  16. #define COMPLIANCE_INSTALLTYPE_WIN31 0x00000001
  17. #define COMPLIANCE_INSTALLTYPE_WIN9X 0x00000002
  18. #define COMPLIANCE_INSTALLTYPE_NTW 0x00000004
  19. #define COMPLIANCE_INSTALLTYPE_NTS 0x00000008
  20. #define COMPLIANCE_INSTALLTYPE_NTSE 0x00000010
  21. #define COMPLIANCE_INSTALLTYPE_NTSDTC 0x00000020
  22. //
  23. // this is for the downlevel terminal server edition product, which needs
  24. // to be treated as an install type, not just a product suite. this includes
  25. // nt4 terminal server edition as well as citrix winframe
  26. //
  27. #define COMPLIANCE_INSTALLTYPE_NTSTSE 0x00000040
  28. #define COMPLIANCE_INSTALLTYPE_NTWP 0x00000080
  29. #define COMPLIANCE_INSTALLTYPE_NTSB 0x00000100
  30. #define COMPLIANCE_INSTALLTYPE_NTSBS 0x00000200
  31. #define COMPLIANCE_INSTALLTYPE_ANY ( COMPLIANCE_INSTALLTYPE_WIN31 | \
  32. COMPLIANCE_INSTALLTYPE_WIN9X | \
  33. COMPLIANCE_INSTALLTYPE_NTW | \
  34. COMPLIANCE_INSTALLTYPE_NTWP | \
  35. COMPLIANCE_INSTALLTYPE_NTS | \
  36. COMPLIANCE_INSTALLTYPE_NTSB | \
  37. COMPLIANCE_INSTALLTYPE_NTSBS | \
  38. COMPLIANCE_INSTALLTYPE_NTSE | \
  39. COMPLIANCE_INSTALLTYPE_NTSDTC | \
  40. COMPLIANCE_INSTALLTYPE_NTSTSE )
  41. #define COMPLIANCE_INSTALLTYPE_NTANY ( COMPLIANCE_INSTALLTYPE_NTW | \
  42. COMPLIANCE_INSTALLTYPE_NTWP | \
  43. COMPLIANCE_INSTALLTYPE_NTS | \
  44. COMPLIANCE_INSTALLTYPE_NTSB | \
  45. COMPLIANCE_INSTALLTYPE_NTSBS | \
  46. COMPLIANCE_INSTALLTYPE_NTSE | \
  47. COMPLIANCE_INSTALLTYPE_NTSDTC | \
  48. COMPLIANCE_INSTALLTYPE_NTSTSE )
  49. #define COMPLIANCE_INSTALLVAR_UNKNOWN 0x00000000
  50. #define COMPLIANCE_INSTALLVAR_SELECT 0x00000001
  51. #define COMPLIANCE_INSTALLVAR_MSDN 0x00000002
  52. #define COMPLIANCE_INSTALLVAR_OEM 0x00000004
  53. #define COMPLIANCE_INSTALLVAR_CDRETAIL 0x00000008
  54. #define COMPLIANCE_INSTALLVAR_FLOPPYRETAIL 0x00000010 // win95 only!
  55. #define COMPLIANCE_INSTALLVAR_EVAL 0x00000020
  56. #define COMPLIANCE_INSTALLVAR_NFR 0x00000040
  57. #define COMPLIANCE_INSTALLVAR_ANY ( COMPLIANCE_INSTALLVAR_SELECT | \
  58. COMPLIANCE_INSTALLVAR_MSDN | \
  59. COMPLIANCE_INSTALLVAR_OEM | \
  60. COMPLIANCE_INSTALLVAR_CDRETAIL | \
  61. COMPLIANCE_INSTALLVAR_EVAL | \
  62. COMPLIANCE_INSTALLVAR_NFR | \
  63. COMPLIANCE_INSTALLVAR_FLOPPYRETAIL )
  64. #define COMPLIANCE_INSTALLSUITE_UNKNOWN 0x00000000
  65. #define COMPLIANCE_INSTALLSUITE_NONE 0x00000001
  66. #define COMPLIANCE_INSTALLSUITE_SBS 0x00000002
  67. #define COMPLIANCE_INSTALLSUITE_SBSR 0x00000004
  68. #define COMPLIANCE_INSTALLSUITE_ENT 0x00000008
  69. #define COMPLIANCE_INSTALLSUITE_COMM 0x00000010
  70. #define COMPLIANCE_INSTALLSUITE_HYDRA 0x00000020
  71. #define COMPLIANCE_INSTALLSUITE_TERMINAL COMPLIANCE_INSTALLSUITE_HYDRA
  72. #define COMPLIANCE_INSTALLSUITE_BACK 0x00000040
  73. #define COMPLIANCE_INSTALLSUITE_EMBED 0x00000080
  74. #define COMPLIANCE_INSTALLSUITE_DTC 0x00000100
  75. #define COMPLIANCE_INSTALLSUITE_PER 0x00000200
  76. #define COMPLIANCE_INSTALLSUITE_BLADE 0x00000400
  77. #define COMPLIANCE_INSTALLSUITE_ANY ( COMPLIANCE_INSTALLSUITE_SBS | \
  78. COMPLIANCE_INSTALLSUITE_SBSR | \
  79. COMPLIANCE_INSTALLSUITE_ENT | \
  80. COMPLIANCE_INSTALLSUITE_COMM | \
  81. COMPLIANCE_INSTALLSUITE_HYDRA | \
  82. COMPLIANCE_INSTALLSUITE_BACK | \
  83. COMPLIANCE_INSTALLSUITE_EMBED | \
  84. COMPLIANCE_INSTALLSUITE_DTC | \
  85. COMPLIANCE_INSTALLSUITE_BLADE | \
  86. COMPLIANCE_INSTALLSUITE_PER )
  87. #define COMPLIANCEERR_NONE 0x00000000
  88. #define COMPLIANCEERR_VERSION 0x00000001
  89. #define COMPLIANCEERR_SUITE 0x00000002
  90. #define COMPLIANCEERR_TYPE 0x00000003
  91. #define COMPLIANCEERR_VARIATION 0x00000004
  92. #define COMPLIANCEERR_UNKNOWNTARGET 0x00000005
  93. #define COMPLIANCEERR_UNKNOWNSOURCE 0x00000006
  94. #define COMPLIANCEERR_SERVICEPACK5 0x00000007
  95. #define COMPLIANCEERR_UNKNOWN COMPLIANCEERR_UNKNOWNSOURCE
  96. #define COMPLIANCE_SKU_NONE 0x00000000
  97. #define COMPLIANCE_SKU_NTWFULL 0x00000001
  98. #define COMPLIANCE_SKU_NTW32U 0x00000002
  99. //#define COMPLIANCE_SKU_NTWU 0x00000003
  100. #define COMPLIANCE_SKU_NTSEFULL 0x00000004
  101. #define COMPLIANCE_SKU_NTSFULL 0x00000005
  102. #define COMPLIANCE_SKU_NTSEU 0x00000006
  103. //#define COMPLIANCE_SKU_NTSSEU 0x00000007
  104. #define COMPLIANCE_SKU_NTSU 0x00000008
  105. #define COMPLIANCE_SKU_NTSDTC 0x00000009
  106. //#define COMPLIANCE_SKU_NTSDTCU 0x0000000a
  107. #define COMPLIANCE_SKU_NTWPFULL 0x0000000b
  108. #define COMPLIANCE_SKU_NTWPU 0x0000000c
  109. #define COMPLIANCE_SKU_NTSB 0x0000000d
  110. #define COMPLIANCE_SKU_NTSBU 0x0000000e
  111. #define COMPLIANCE_SKU_NTSBS 0x00000010
  112. #define COMPLIANCE_SKU_NTSBSU 0x00000011
  113. #define COMPLIANCE_SKU_STEPUP 0x00010000
  114. #define COMPLIANCE_SKU_STEPUP_WIN9X 0x00020000
  115. typedef struct _COMPLIANCE_DATA {
  116. DWORD InstallType; // mask describing install type
  117. DWORD InstallVariation; // mask describing install variation
  118. DWORD InstallSuite; // mask describing install suite
  119. BOOL RequiresValidation; // do we need to do validation for this SKU?
  120. DWORD MinimumVersion; // expressed as (majorversion.minorversion * 100), i.e., 3.51 == 351, 5.0 == 500, etc...
  121. DWORD MaximumKnownVersionNt; // expressed as (majorversion.minorversion * 100), i.e., 3.51 == 351, 5.0 == 500, etc...
  122. DWORD BuildNumberNt; //
  123. DWORD BuildNumberWin9x; //
  124. DWORD InstallServicePack; // Service Pack number
  125. } COMPLIANCE_DATA, *PCOMPLIANCE_DATA;
  126. typedef struct _COMPLIANCE_SRC {
  127. DWORD InstallType; // mask describing install type
  128. DWORD InstallVariation; // mask describing install variation
  129. DWORD InstallSuite; // mask describing install suite
  130. DWORD Version; // expressed as (majorversion.minorversion * 100), i.e., 3.51 == 351, 5.0 == 500, etc...
  131. } COMPLIANCE_SRC, *PCOMPLIANCE_SRC;
  132. //
  133. // The install media object abstraction
  134. //
  135. //
  136. // media object this pointer
  137. //
  138. typedef struct _st_CCMEDIA *PCCMEDIA;
  139. //
  140. // Compliance checking method of media object
  141. //
  142. typedef BOOLEAN (* PCC_CHECK_FUNCTION)(
  143. IN PCCMEDIA This,
  144. IN PCOMPLIANCE_DATA CompData,
  145. OUT PUINT FailureReason,
  146. OUT PBOOL NoUpgradeAllowed );
  147. //
  148. // install media object
  149. //
  150. typedef struct _st_CCMEDIA {
  151. DWORD SourceType;
  152. DWORD SourceVariation;
  153. DWORD Version; // major * 100 + minor
  154. DWORD BuildNumber;
  155. BOOLEAN StepUpMedia;
  156. PCC_CHECK_FUNCTION CheckInstall; // compliance check method
  157. } CCMEDIA;
  158. //
  159. // common prototypes
  160. //
  161. PCCMEDIA
  162. CCMediaCreate(
  163. IN DWORD SourceSKU,
  164. IN DWORD SourceVariation,
  165. IN OPTIONAL DWORD Version,
  166. IN OPTIONAL DWORD BuildNumber );
  167. BOOLEAN
  168. CCMediaInitialize(
  169. OUT PCCMEDIA DestMedia,
  170. IN DWORD Type,
  171. IN DWORD Variation,
  172. IN BOOLEAN StepupMedia,
  173. IN OPTIONAL DWORD Version,
  174. IN OPTIONAL DWORD BuildNumber);
  175. BOOLEAN
  176. CheckCompliance(
  177. IN DWORD SourceSku,
  178. IN DWORD SourceVariation,
  179. IN DWORD SourceVersion,
  180. IN DWORD SourceBuildNum,
  181. IN PCOMPLIANCE_DATA Destination,
  182. OUT PUINT Reason,
  183. OUT PBOOL NoUpgradeAllowed
  184. );
  185. DWORD
  186. DetermineSourceProduct(
  187. OUT DWORD *SourceSkuVariation,
  188. IN PCOMPLIANCE_DATA pcd
  189. );
  190. BOOL
  191. GetSourceComplianceData(
  192. OUT PCOMPLIANCE_DATA pcd,
  193. IN PCOMPLIANCE_DATA Target
  194. );
  195. DWORD
  196. CRC_32(
  197. LPBYTE pb,
  198. DWORD cb
  199. );
  200. BOOL
  201. IsValidStepUpMode(
  202. CHAR *StepUpArray,
  203. ULONG *StepUpMode
  204. );
  205. //
  206. // kernel mode prototypes
  207. //
  208. #ifdef KERNEL_MODE
  209. BOOLEAN
  210. pSpIsCompliant(
  211. IN DWORD SourceVersion,
  212. IN DWORD SourceBuildNum,
  213. IN PDISK_REGION OsPartRegion,
  214. IN PWSTR SystemRoot,
  215. OUT PBOOLEAN UpgradeOnlyCompliant
  216. );
  217. BOOLEAN
  218. pSpDetermineCurrentInstallation(
  219. IN PDISK_REGION OsPartRegion,
  220. IN PWSTR SystemRoot,
  221. OUT PCOMPLIANCE_DATA pcd
  222. );
  223. BOOLEAN
  224. pSpGetCurrentInstallVariation(
  225. IN PWSTR szPid20,
  226. OUT LPDWORD CurrentInstallVariation
  227. );
  228. BOOL
  229. pSpDetermineSourceProduct(
  230. OUT PCOMPLIANCE_DATA pcd
  231. );
  232. BOOLEAN
  233. SpGetStepUpMode(
  234. PWSTR PidExtraData,
  235. BOOLEAN *StepUpMode
  236. );
  237. BOOLEAN
  238. DetermineSourceVersionInfo(
  239. OUT PDWORD Version,
  240. OUT PDWORD BuildNumber
  241. );
  242. #define CCMemAlloc SpMemAlloc
  243. #define CCMemFree SpMemFree
  244. #else
  245. //
  246. // user mode prototypes
  247. //
  248. VOID
  249. CCDisableBuildCheck(
  250. VOID
  251. );
  252. BOOL
  253. IsCompliant(
  254. PBOOL UpgradeOnly,
  255. PBOOL NoUpgradeAllowed,
  256. PUINT SrcSku,
  257. PUINT CurrentInstallType,
  258. PUINT CurrentInstallBuild,
  259. PUINT Reason
  260. );
  261. BOOLEAN
  262. DetermineSourceVersionInfo(
  263. IN TCHAR *InfPath,
  264. OUT PDWORD Version,
  265. OUT PDWORD BuildNumber
  266. );
  267. BOOL
  268. DetermineCurrentInstallation(
  269. LPDWORD CurrentInstallType,
  270. LPDWORD CurrentInstallVariation,
  271. LPDWORD CurrentInstallVersion,
  272. LPDWORD CurrentInstallBuildNT,
  273. LPDWORD CurrentInstallBuildWin9x,
  274. LPDWORD CurrentInstallSuite,
  275. LPDWORD CurrentInstallServicePack
  276. );
  277. BOOL
  278. GetCurrentInstallVariation(
  279. LPDWORD CurrentInstallVariation,
  280. IN DWORD CurrentInstallType,
  281. IN DWORD CurrentInstallBuildNT,
  282. IN DWORD InstallVersion
  283. );
  284. BOOL
  285. GetCurrentNtVersion(
  286. LPDWORD CurrentInstallType,
  287. LPDWORD CurrentInstallSuite
  288. );
  289. BOOL
  290. GetCdSourceInstallType(
  291. LPDWORD SourceInstallType
  292. );
  293. BOOL
  294. GetSourceInstallVariation(
  295. LPDWORD SourceInstallVariation
  296. );
  297. BOOL
  298. IsWinPEMode(
  299. VOID
  300. );
  301. #define CCMemAlloc malloc
  302. #define CCMemFree free
  303. #endif
  304. #ifdef __cplusplus
  305. } /* End of extern "C" { */
  306. #endif /* __cplusplus */
  307. #endif // _COMPLIANCE_H