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.

246 lines
6.2 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. { c_szInfId_MS_ALG,
  34. &GUID_DEVCLASS_NETSERVICE,
  35. EDC_DEFAULT | EDC_MANDATORY,
  36. 0,
  37. 0,
  38. FALSE },
  39. { c_szInfId_MS_GPC,
  40. &GUID_DEVCLASS_NETSERVICE,
  41. EDC_DEFAULT | EDC_MANDATORY,
  42. 0,
  43. 0,
  44. FALSE },
  45. { c_szInfId_MS_TCPIP,
  46. &GUID_DEVCLASS_NETTRANS,
  47. EDC_DEFAULT | EDC_MANDATORY,
  48. 0,
  49. 0,
  50. FALSE },
  51. { c_szInfId_MS_PSched,
  52. &GUID_DEVCLASS_NETSERVICE,
  53. EDC_DEFAULT,
  54. 0,
  55. VER_NT_WORKSTATION,
  56. FALSE },
  57. { c_szInfId_MS_WebClient,
  58. &GUID_DEVCLASS_NETCLIENT,
  59. EDC_DEFAULT | EDC_MANDATORY,
  60. 0,
  61. 0,
  62. FALSE },
  63. { c_szInfId_MS_MSClient,
  64. &GUID_DEVCLASS_NETCLIENT,
  65. EDC_DEFAULT,
  66. 0,
  67. 0,
  68. FALSE },
  69. { c_szInfId_MS_Server,
  70. &GUID_DEVCLASS_NETSERVICE,
  71. EDC_DEFAULT,
  72. 0,
  73. 0,
  74. FALSE },
  75. { c_szInfId_MS_RasCli,
  76. &GUID_DEVCLASS_NETSERVICE,
  77. EDC_DEFAULT | EDC_MANDATORY,
  78. 0,
  79. 0,
  80. FALSE },
  81. { c_szInfId_MS_RasSrv,
  82. &GUID_DEVCLASS_NETSERVICE,
  83. EDC_DEFAULT | EDC_MANDATORY,
  84. 0,
  85. 0,
  86. FALSE },
  87. { c_szInfId_MS_WLBS,
  88. &GUID_DEVCLASS_NETSERVICE,
  89. EDC_DEFAULT,
  90. 0,
  91. VER_NT_SERVER,
  92. FALSE },
  93. { c_szInfId_MS_NDISUIO,
  94. &GUID_DEVCLASS_NETTRANS,
  95. EDC_DEFAULT | EDC_MANDATORY,
  96. 0,
  97. 0,
  98. FALSE },
  99. { c_szInfId_MS_WZCSVC,
  100. &GUID_DEVCLASS_NETSERVICE,
  101. EDC_DEFAULT | EDC_MANDATORY,
  102. 0,
  103. 0,
  104. FALSE },
  105. };
  106. BOOL FCheckSuite(WORD wSuiteMask)
  107. {
  108. // Succeed if they are not asking us to verify anything
  109. if(!wSuiteMask)
  110. {
  111. return true;
  112. }
  113. OSVERSIONINFOEX osiv;
  114. ULONGLONG ConditionMask;
  115. ZeroMemory (&osiv, sizeof(osiv));
  116. osiv.dwOSVersionInfoSize = sizeof(osiv);
  117. osiv.wSuiteMask = wSuiteMask;
  118. ConditionMask = 0;
  119. // Succeed if any of the requested suites are present
  120. // on this machine
  121. VER_SET_CONDITION(ConditionMask, VER_SUITENAME, VER_OR);
  122. return STATUS_SUCCESS == RtlVerifyVersionInfo(
  123. &osiv, VER_SUITENAME, ConditionMask);
  124. }
  125. BOOL FCheckProductType(WORD wProductType)
  126. {
  127. // Succeed if they are not asking us to verify anything
  128. if(!wProductType)
  129. {
  130. return true;
  131. }
  132. OSVERSIONINFOEX osiv;
  133. ULONGLONG ConditionMask;
  134. ZeroMemory (&osiv, sizeof(osiv));
  135. osiv.dwOSVersionInfoSize = sizeof(osiv);
  136. osiv.wProductType = (UCHAR)wProductType;
  137. ConditionMask = 0;
  138. VER_SET_CONDITION(ConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);
  139. return STATUS_SUCCESS == RtlVerifyVersionInfo(
  140. &osiv, VER_PRODUCT_TYPE, ConditionMask);
  141. }
  142. VOID
  143. EnumDefaultComponents (
  144. IN DWORD dwEntryType,
  145. IN PFN_EDC_CALLBACK pfnCallback,
  146. IN PVOID pvCallerData OPTIONAL
  147. )
  148. {
  149. TraceFileFunc(ttidGuiModeSetup);
  150. Assert (dwEntryType);
  151. Assert (pfnCallback);
  152. // An array of flags. If a flag at index 'i' is TRUE, it means
  153. // we will enumerate c_aDefault[i].
  154. //
  155. BYTE afEnumEntry [celems(c_aDefault)];
  156. UINT cEntries = 0;
  157. // Figure out which components we will be enumerating based on
  158. // the caller's requested entry type. For each that we will enumerate,
  159. // set the flag at the index in afEnumEntry.
  160. //
  161. for (UINT i = 0; i < celems(c_aDefault); i++)
  162. {
  163. BOOL fShouldInstall;
  164. afEnumEntry[i] = FALSE;
  165. // If no match on the entry type, continue to the next entry.
  166. //
  167. if (!(dwEntryType & c_aDefault[i].dwEntryType))
  168. {
  169. continue;
  170. }
  171. // Check for product suite or type.
  172. //
  173. fShouldInstall = FCheckSuite(c_aDefault[i].wSuiteMask) &&
  174. FCheckProductType(c_aDefault[i].wProductType);
  175. // Some components express the conditions under which they
  176. // should be installed with a NOT
  177. //
  178. if( c_aDefault[i].fInvertInstallCheck )
  179. {
  180. fShouldInstall = !fShouldInstall;
  181. }
  182. if(! fShouldInstall)
  183. {
  184. continue;
  185. }
  186. // If we got to this point, it means this entry is valid to be
  187. // enumerated to the caller. Add it (by setting the flag in
  188. // the local BYTE array at the same index as the entry).
  189. //
  190. afEnumEntry[i] = TRUE;
  191. cEntries++;
  192. }
  193. // Call the callback and indicate the count of times we will be
  194. // calling it with entries. This allows the callback to know, ahead
  195. // of time, how much work needs to be done.
  196. //
  197. pfnCallback (EDC_INDICATE_COUNT, cEntries, pvCallerData);
  198. // Call the callback for each entry to be enumerated.
  199. //
  200. for (i = 0; i < celems(c_aDefault); i++)
  201. {
  202. if (!afEnumEntry[i])
  203. {
  204. continue;
  205. }
  206. pfnCallback (EDC_INDICATE_ENTRY, (ULONG_PTR)&c_aDefault[i],
  207. pvCallerData);
  208. }
  209. }