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.

279 lines
8.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: E C O M P . H
  7. //
  8. // Contents: Implements the interface to a component's external data.
  9. // External data is that data controlled (or placed) by
  10. // PnP or the network class installer. Everything under a
  11. // component's instance key is considered external data.
  12. // (Internal data is that data we store in the persisted binary
  13. // for the network configuration. See persist.cpp for
  14. // code that deals with internal data.)
  15. //
  16. // Notes:
  17. //
  18. // Author: shaunco 15 Jan 1999
  19. //
  20. //----------------------------------------------------------------------------
  21. #pragma once
  22. #include "ncmisc.h"
  23. #define ECD_OFFSET(_p) (UINT)FIELD_OFFSET(CExternalComponentData, _p)
  24. class CExternalComponentData : CNetCfgDebug<CExternalComponentData>
  25. {
  26. friend class CImplINetCfgComponent;
  27. private:
  28. // The data buffer into which subsequent member pointers will point.
  29. // Always freed.
  30. //
  31. PVOID m_pvBuffer;
  32. // For enumerated components, this is the 'DriverDesc' value from PnP.
  33. // For non-enumerated components, this is read from the instance key.
  34. // In both cases, this is the localizable string value that comes from
  35. // the component's INF. It is displayed as the component's
  36. // display name in any UI. Note that this is the only member which
  37. // can be changed. Therefore, it does not point into the same buffer
  38. // which all the others point. Freed if it does not point into
  39. // m_pvBuffer.
  40. //
  41. PCWSTR m_pszDescription;
  42. // The CLSID of the component's notify object. Will be NULL in
  43. // the case the component does not have a notify object. Never freed.
  44. //
  45. const GUID* m_pNotifyObjectClsid;
  46. // The component's primary service. Will be NULL if the component does
  47. // not have a service. Never freed.
  48. //
  49. PCWSTR m_pszService;
  50. // The component's list of co-services as a multi-sz. Will be NULL
  51. // if the component does not have any co-services. Never freed.
  52. //
  53. PCWSTR m_pmszCoServices;
  54. // The component's bind form. Will be NULL if the component takes the
  55. // default bindform. Never freed.
  56. //
  57. PCWSTR m_pszBindForm;
  58. // The component's help text. Will be NULL if the component does not
  59. // have any help text. (Not recommened for visible component's)
  60. // Never freed.
  61. //
  62. PCWSTR m_pszHelpText;
  63. // Comma-separated list of sub-strings that are the
  64. // lower-edge binding interfaces. Never freed.
  65. //
  66. PCWSTR m_pszLowerRange;
  67. // Comma-separated list of sub-strings that are the
  68. // upper-edge binding interfaces.
  69. //
  70. PCWSTR m_pszUpperRange;
  71. // Comma-separated list of sub-strings that are the excluded
  72. // binding interfaces.
  73. //
  74. PCWSTR m_pszLowerExclude;
  75. // Comma-separated list of sub-strings that are the media types supported
  76. // by this filter component. (Only valid for filters.)
  77. //
  78. PCWSTR m_pszFilterMediaTypes;
  79. // This pointer is just so that we have an upper bound on the pointers
  80. // that point into m_pvBuffer. We use this knowledge to know
  81. // whether or not to free m_pszDescription as it may not be
  82. // pointing somewhere in this buffer for the case when it has been
  83. // changed and hence uses its own allocation.
  84. //
  85. PVOID m_pvBufferLast;
  86. // The bindname for the component. This is built from BindForm,
  87. // Class, Character, ServiceName, InfId, and InstanceGuid.
  88. // It is a seaparate allocation made with LocalAlloc (because
  89. // FormatMessage is used to build it.) Freed with LocalFree.
  90. //
  91. PCWSTR m_pszBindName;
  92. // The result of HrEnsureExternalDataLoaded. It is saved, so that on
  93. // subsequent calls, we return the same result we did the first time.
  94. //
  95. HRESULT m_hrLoadResult;
  96. // FALSE until HrEnsureExternalDataLoaded is called. TRUE thereafter
  97. // which prevents HrEnsureExternalDataLoaded from hitting the registry
  98. // again. Indicates all of the other members are cached and valid.
  99. //
  100. BOOLEAN m_fInitialized;
  101. private:
  102. HRESULT
  103. HrLoadData (
  104. IN HKEY hkeyInstance,
  105. OUT BYTE* pbBuf OPTIONAL,
  106. IN OUT ULONG* pcbBuf);
  107. VOID
  108. FreeDescription ();
  109. VOID
  110. FreeExternalData ();
  111. public:
  112. ~CExternalComponentData ()
  113. {
  114. FreeExternalData ();
  115. }
  116. HRESULT
  117. HrEnsureExternalDataLoaded ();
  118. HRESULT
  119. HrReloadExternalData ();
  120. HRESULT
  121. HrSetDescription (
  122. PCWSTR pszNewDescription);
  123. BOOL
  124. FHasNotifyObject () const
  125. {
  126. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  127. return (NULL != m_pNotifyObjectClsid);
  128. }
  129. BOOL
  130. FLoadedOkayIfLoadedAtAll () const;
  131. const CLSID*
  132. PNotifyObjectClsid () const
  133. {
  134. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  135. AssertH (m_pNotifyObjectClsid);
  136. return m_pNotifyObjectClsid;
  137. }
  138. PCWSTR
  139. PszAtOffset (
  140. IN UINT unOffset) const
  141. {
  142. AssertH (
  143. (ECD_OFFSET(m_pszDescription) == unOffset) ||
  144. (ECD_OFFSET(m_pszService) == unOffset) ||
  145. (ECD_OFFSET(m_pszBindForm) == unOffset) ||
  146. (ECD_OFFSET(m_pszHelpText) == unOffset) ||
  147. (ECD_OFFSET(m_pszLowerRange) == unOffset) ||
  148. (ECD_OFFSET(m_pszUpperRange) == unOffset) ||
  149. (ECD_OFFSET(m_pszBindName) == unOffset));
  150. PCWSTR psz;
  151. psz = *(PCWSTR*)((BYTE*)this + unOffset);
  152. AssertH (
  153. (m_pszDescription == psz) ||
  154. (m_pszService == psz) ||
  155. (m_pszBindForm == psz) ||
  156. (m_pszHelpText == psz) ||
  157. (m_pszLowerRange == psz) ||
  158. (m_pszLowerRange == psz) ||
  159. (m_pszBindName == psz));
  160. return psz;
  161. }
  162. PCWSTR
  163. PszBindForm () const
  164. {
  165. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  166. return m_pszBindForm;
  167. }
  168. PCWSTR
  169. PszBindName () const
  170. {
  171. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  172. AssertH (m_pszBindName && *m_pszBindName);
  173. return m_pszBindName;
  174. }
  175. PCWSTR
  176. PszDescription () const
  177. {
  178. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  179. return m_pszDescription;
  180. }
  181. PCWSTR
  182. PszHelpText () const
  183. {
  184. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  185. return m_pszHelpText;
  186. }
  187. PCWSTR
  188. PszService () const
  189. {
  190. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  191. return m_pszService;
  192. }
  193. PCWSTR
  194. PszCoServices () const
  195. {
  196. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  197. return m_pmszCoServices;
  198. }
  199. PCWSTR
  200. PszFilterMediaTypes () const
  201. {
  202. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  203. return m_pszFilterMediaTypes;
  204. }
  205. PCWSTR
  206. PszLowerRange () const
  207. {
  208. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  209. return (m_pszLowerRange) ? m_pszLowerRange : L"";
  210. }
  211. PCWSTR
  212. PszLowerExclude () const
  213. {
  214. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  215. return m_pszLowerExclude;
  216. }
  217. PCWSTR
  218. PszUpperRange () const
  219. {
  220. AssertH (m_fInitialized && (S_OK == m_hrLoadResult));
  221. return (m_pszUpperRange) ? m_pszUpperRange : L"";
  222. }
  223. #if DBG
  224. BOOL DbgIsExternalDataLoaded () const
  225. {
  226. return m_fInitialized && (S_OK == m_hrLoadResult);
  227. }
  228. VOID DbgVerifyExternalDataLoaded () const
  229. {
  230. AssertH (DbgIsExternalDataLoaded());
  231. }
  232. #else
  233. BOOL DbgIsExternalDataLoaded () const { return TRUE; }
  234. VOID DbgVerifyExternalDataLoaded () const {}
  235. #endif
  236. };