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.

249 lines
6.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: E D C . C P P
  7. //
  8. // Contents: Routines to enumerate (via a callback) the set of "default"
  9. // components that are installed under various conditions.
  10. //
  11. // Notes: (See edc.h for notes on the interface to this module.)
  12. //
  13. // Author: shaunco 18 May 1999
  14. //
  15. //----------------------------------------------------------------------------
  16. #include "pch.h"
  17. #pragma hdrstop
  18. #include "edc.h"
  19. extern const WCHAR c_szInfId_MS_ALG[];
  20. extern const WCHAR c_szInfId_MS_GPC[];
  21. extern const WCHAR c_szInfId_MS_MSClient[];
  22. extern const WCHAR c_szInfId_MS_RasCli[];
  23. extern const WCHAR c_szInfId_MS_RasSrv[];
  24. extern const WCHAR c_szInfId_MS_Server[];
  25. extern const WCHAR c_szInfId_MS_TCPIP[];
  26. extern const WCHAR c_szInfId_MS_WLBS[];
  27. extern const WCHAR c_szInfId_MS_PSched[];
  28. extern const WCHAR c_szInfId_MS_WZCSVC[];
  29. extern const WCHAR c_szInfId_MS_NDISUIO[];
  30. extern const WCHAR c_szInfId_MS_WebClient[];
  31. static const EDC_ENTRY c_aDefault [] =
  32. {
  33. // On IA64, all homenet technologies are unavailable.
  34. #ifndef _WIN64
  35. { c_szInfId_MS_ALG,
  36. &GUID_DEVCLASS_NETSERVICE,
  37. EDC_DEFAULT | EDC_MANDATORY,
  38. VER_SUITE_ENTERPRISE | VER_SUITE_DATACENTER,
  39. 0,
  40. TRUE }, // Install everywhere *except* DTC and ADS
  41. #endif
  42. { c_szInfId_MS_GPC,
  43. &GUID_DEVCLASS_NETSERVICE,
  44. EDC_DEFAULT | EDC_MANDATORY,
  45. 0,
  46. 0,
  47. FALSE },
  48. { c_szInfId_MS_TCPIP,
  49. &GUID_DEVCLASS_NETTRANS,
  50. EDC_DEFAULT | EDC_MANDATORY,
  51. 0,
  52. 0,
  53. FALSE },
  54. { c_szInfId_MS_PSched,
  55. &GUID_DEVCLASS_NETSERVICE,
  56. EDC_DEFAULT,
  57. 0,
  58. VER_NT_WORKSTATION,
  59. FALSE },
  60. { c_szInfId_MS_WebClient,
  61. &GUID_DEVCLASS_NETCLIENT,
  62. EDC_DEFAULT | EDC_MANDATORY,
  63. 0,
  64. 0,
  65. FALSE },
  66. { c_szInfId_MS_MSClient,
  67. &GUID_DEVCLASS_NETCLIENT,
  68. EDC_DEFAULT,
  69. 0,
  70. 0,
  71. FALSE },
  72. { c_szInfId_MS_Server,
  73. &GUID_DEVCLASS_NETSERVICE,
  74. EDC_DEFAULT,
  75. 0,
  76. 0,
  77. FALSE },
  78. { c_szInfId_MS_RasCli,
  79. &GUID_DEVCLASS_NETSERVICE,
  80. EDC_DEFAULT | EDC_MANDATORY,
  81. 0,
  82. 0,
  83. FALSE },
  84. { c_szInfId_MS_RasSrv,
  85. &GUID_DEVCLASS_NETSERVICE,
  86. EDC_DEFAULT | EDC_MANDATORY,
  87. 0,
  88. 0,
  89. FALSE },
  90. { c_szInfId_MS_WLBS,
  91. &GUID_DEVCLASS_NETSERVICE,
  92. EDC_DEFAULT,
  93. 0,
  94. VER_NT_SERVER,
  95. FALSE },
  96. { c_szInfId_MS_NDISUIO,
  97. &GUID_DEVCLASS_NETTRANS,
  98. EDC_DEFAULT | EDC_MANDATORY,
  99. 0,
  100. 0,
  101. FALSE },
  102. { c_szInfId_MS_WZCSVC,
  103. &GUID_DEVCLASS_NETSERVICE,
  104. EDC_DEFAULT | EDC_MANDATORY,
  105. 0,
  106. 0,
  107. FALSE },
  108. };
  109. BOOL FCheckSuite(WORD wSuiteMask)
  110. {
  111. // Succeed if they are not asking us to verify anything
  112. if(!wSuiteMask)
  113. {
  114. return true;
  115. }
  116. OSVERSIONINFOEX osiv;
  117. ULONGLONG ConditionMask;
  118. ZeroMemory (&osiv, sizeof(osiv));
  119. osiv.dwOSVersionInfoSize = sizeof(osiv);
  120. osiv.wSuiteMask = wSuiteMask;
  121. ConditionMask = 0;
  122. // Succeed if any of the requested suites are present
  123. // on this machine
  124. VER_SET_CONDITION(ConditionMask, VER_SUITENAME, VER_OR);
  125. return STATUS_SUCCESS == RtlVerifyVersionInfo(
  126. &osiv, VER_SUITENAME, ConditionMask);
  127. }
  128. BOOL FCheckProductType(WORD wProductType)
  129. {
  130. // Succeed if they are not asking us to verify anything
  131. if(!wProductType)
  132. {
  133. return true;
  134. }
  135. OSVERSIONINFOEX osiv;
  136. ULONGLONG ConditionMask;
  137. ZeroMemory (&osiv, sizeof(osiv));
  138. osiv.dwOSVersionInfoSize = sizeof(osiv);
  139. osiv.wProductType = wProductType;
  140. ConditionMask = 0;
  141. VER_SET_CONDITION(ConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);
  142. return STATUS_SUCCESS == RtlVerifyVersionInfo(
  143. &osiv, VER_PRODUCT_TYPE, ConditionMask);
  144. }
  145. VOID
  146. EnumDefaultComponents (
  147. IN DWORD dwEntryType,
  148. IN PFN_EDC_CALLBACK pfnCallback,
  149. IN PVOID pvCallerData OPTIONAL
  150. )
  151. {
  152. TraceFileFunc(ttidGuiModeSetup);
  153. Assert (dwEntryType);
  154. Assert (pfnCallback);
  155. // An array of flags. If a flag at index 'i' is TRUE, it means
  156. // we will enumerate c_aDefault[i].
  157. //
  158. BYTE afEnumEntry [celems(c_aDefault)];
  159. UINT cEntries = 0;
  160. // Figure out which components we will be enumerating based on
  161. // the caller's requested entry type. For each that we will enumerate,
  162. // set the flag at the index in afEnumEntry.
  163. //
  164. for (UINT i = 0; i < celems(c_aDefault); i++)
  165. {
  166. BOOL fShouldInstall;
  167. afEnumEntry[i] = FALSE;
  168. // If no match on the entry type, continue to the next entry.
  169. //
  170. if (!(dwEntryType & c_aDefault[i].dwEntryType))
  171. {
  172. continue;
  173. }
  174. // Check for product suite or type.
  175. //
  176. fShouldInstall = FCheckSuite(c_aDefault[i].wSuiteMask) &&
  177. FCheckProductType(c_aDefault[i].wProductType);
  178. // Some components express the conditions under which they
  179. // should be installed with a NOT
  180. //
  181. if( c_aDefault[i].fInvertInstallCheck )
  182. {
  183. fShouldInstall = !fShouldInstall;
  184. }
  185. if(! fShouldInstall)
  186. {
  187. continue;
  188. }
  189. // If we got to this point, it means this entry is valid to be
  190. // enumerated to the caller. Add it (by setting the flag in
  191. // the local BYTE array at the same index as the entry).
  192. //
  193. afEnumEntry[i] = TRUE;
  194. cEntries++;
  195. }
  196. // Call the callback and indicate the count of times we will be
  197. // calling it with entries. This allows the callback to know, ahead
  198. // of time, how much work needs to be done.
  199. //
  200. pfnCallback (EDC_INDICATE_COUNT, cEntries, pvCallerData);
  201. // Call the callback for each entry to be enumerated.
  202. //
  203. for (i = 0; i < celems(c_aDefault); i++)
  204. {
  205. if (!afEnumEntry[i])
  206. {
  207. continue;
  208. }
  209. pfnCallback (EDC_INDICATE_ENTRY, (ULONG_PTR)&c_aDefault[i],
  210. pvCallerData);
  211. }
  212. }