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.

404 lines
10 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. ASSOCQE.H
  5. Abstract:
  6. WinMgmt Association Query Engine
  7. History:
  8. raymcc 04-Jul-99 Created
  9. --*/
  10. #ifndef _ASSOCQE_H_
  11. #define _ASSOCQE_H_
  12. class CAssocQE_Sink;
  13. class CAssocQuery;
  14. class CObjectSink;
  15. typedef HRESULT (CAssocQuery::*PF_FilterForwarder)(IWbemClassObject *);
  16. #define ROLETEST_MODE_PATH_VALUE 1
  17. #define ROLETEST_MODE_CIMREF_TYPE 2
  18. #define ASSOCQ_FLAG_QUERY_ENDPOINT 1
  19. #define ASSOCQ_FLAG_OTHER_ENDPOINT 2
  20. class CAssocQuery : public IUnknown
  21. {
  22. friend class CAssocQE_Sink;
  23. LONG m_lRef; // COM ref count
  24. CAssocQueryParser m_Parser; // Parsed query access
  25. CBasicObjectSink * m_pDestSink; // Final destination sink
  26. IWbemClassObject *m_pEndpoint; // Endpoint in query
  27. BSTR m_bstrEndpointClass; // Class name of endpoint
  28. BSTR m_bstrEndpointPath; // Full path of endpoint
  29. BSTR m_bstrEndpointRelPath; // Rel path of endpoint
  30. bool m_bEndpointIsClass; // True if endpoint a class
  31. CWStringArray m_aEndpointHierarchy; // Query endpoint class hiearchy
  32. DWORD m_dwQueryStartTime; // When query started
  33. DWORD m_dwLastResultTime; // Updated during indications
  34. LONG m_lActiveSinks; // How many sinks are still running
  35. HANDLE m_hSinkDoneEvent; // Signaled as sinks complete
  36. CFlexArray m_aMaster; // Assoc class list
  37. BOOL m_bLimitNeedsDecrement;
  38. // Helpers for 'associators of' queries.
  39. // =====================================
  40. CFlexArray m_aEpCandidates; // List of paths to EP candidates for associators queries
  41. CCritSec m_csCandidateEpAccess; // Critsec to protect access to Ep candidate array
  42. // Dynamic class cache.
  43. // ====================
  44. CFlexArray m_aDynClasses; // Contains all dynamic classes available as of this query
  45. // Helpers for references of + CLASSDEFSONLY
  46. // =========================================
  47. CWStringArray m_aDeliveredClasses; // List of class names already in the below list
  48. CCritSec m_csDeliveredAccess;
  49. // From the original call.
  50. // =======================
  51. IWbemContext *m_pContext;
  52. CWbemNamespace *m_pNs;
  53. bool m_bCancel;
  54. // Various Internal methods.
  55. // =========================
  56. CAssocQuery();
  57. ~CAssocQuery();
  58. // Class list manipulation.
  59. // ========================
  60. HRESULT BuildMasterAssocClassList(
  61. IN OUT CFlexArray &aResultSet
  62. );
  63. HRESULT MergeInClassRefList(
  64. IN OUT CFlexArray &aResultSet
  65. );
  66. HRESULT RemoveNonDynClasses(
  67. IN OUT CFlexArray &aMaster
  68. );
  69. HRESULT ReduceToRealClasses(
  70. IN OUT CFlexArray & aResultSet
  71. );
  72. // Endpoint analysis.
  73. // ==================
  74. HRESULT CanPropRefQueryEp(
  75. IN BOOL bStrict,
  76. IN LPWSTR pszPropName,
  77. IN IWbemClassObject *pObj,
  78. OUT BSTR *strRefType
  79. );
  80. HRESULT CanClassRefQueryEp(
  81. IN BOOL bStrict,
  82. IN IWbemClassObject *pCls,
  83. OUT CWStringArray *paNames
  84. );
  85. HRESULT CanClassRefReachQueryEp(
  86. IWbemQualifierSet *pQSet,
  87. BOOL bStrict
  88. );
  89. HRESULT DoesAssocInstRefQueryEp(
  90. IN IWbemClassObject *pObj,
  91. OUT BSTR *pszRole
  92. );
  93. HRESULT EpClassTest(
  94. LPCWSTR pszResultClass,
  95. LPCWSTR strClassName,
  96. IWbemClassObject *pTestClass
  97. );
  98. HRESULT GetUnknownEpRoleAndPath(
  99. IN IWbemClassObject *pAssoc,
  100. IN BOOL *pFoundQueryEp,
  101. OUT BSTR *pszRole,
  102. OUT BSTR *pszUnkEpPath
  103. );
  104. // Flow-of-control methods.
  105. // ========================
  106. void BranchToQueryType();
  107. // Schema-query flow-of-control.
  108. // =============================
  109. void ExecSchemaQuery();
  110. HRESULT SchemaQ_RefsQuery(
  111. IN OUT CFlexArray &aResultSet
  112. );
  113. HRESULT SchemaQ_AssocsQuery(
  114. IN CFlexArray &aAssocSet
  115. );
  116. HRESULT SchemaQ_Terminate(
  117. IN CFlexArray &aResultSet
  118. );
  119. HRESULT SchemaQ_RefsFilter(
  120. IN OUT CFlexArray &aSrc
  121. );
  122. HRESULT SchemaQ_AssocsFilter(
  123. IN OUT CFlexArray &aSrc
  124. );
  125. HRESULT SchemaQ_GetAndFilterOtherEndpoints(
  126. IN CFlexArray &aAssocs,
  127. OUT CFlexArray &aEndpoints
  128. );
  129. HRESULT SchemaQ_GetOtherEpClassName(
  130. IN IWbemClassObject *pAssoc,
  131. OUT BSTR *strOtherEpName
  132. );
  133. // Normal (instances, classrefs queries)
  134. // =====================================
  135. HRESULT ExecNormalQuery();
  136. HRESULT NormalQ_PreQueryClassFilter(
  137. CFlexArray &aMaster
  138. );
  139. HRESULT NormalQ_ReferencesOf();
  140. HRESULT NormalQ_AssociatorsOf();
  141. HRESULT NormalQ_GetRefsOfEndpoint(
  142. IN IWbemClassObject *pClass,
  143. IN IWbemObjectSink *pSink
  144. );
  145. HRESULT ConvertEpListToClassDefsOnly();
  146. HRESULT NormalQ_LoadCheck();
  147. HRESULT PerformFinalEpTests(
  148. IWbemClassObject *pEp
  149. );
  150. HRESULT NormalQ_ConstructRefsQuery(
  151. IN IWbemClassObject *pClass,
  152. IN OUT IWbemContext *pContextCopy,
  153. OUT BSTR *strQuery
  154. );
  155. HRESULT GetCimTypeForRef(
  156. IN IWbemClassObject *pCandidate,
  157. IN BSTR pszRole,
  158. OUT BSTR *strCimType
  159. );
  160. HRESULT AssocClassHasOnlyKeys(
  161. IN IWbemClassObject *pObj
  162. );
  163. HRESULT Normal_ExecRefs(
  164. IN CFlexArray &aMasterClassList
  165. );
  166. // Filter auxiliaries for various query types.
  167. // ===========================================
  168. HRESULT FilterForwarder_NormalRefs(
  169. IN IWbemClassObject *pCandidate
  170. );
  171. HRESULT FilterForwarder_NormalAssocs(
  172. IN IWbemClassObject *pAssocInst
  173. );
  174. HRESULT NormalQ_AssocInstTest(
  175. IN IWbemClassObject *pAssoc,
  176. OUT LPWSTR *pszOtherEp
  177. );
  178. HRESULT CanAssocClassRefUnkEp(
  179. IN IWbemClassObject *pClass,
  180. IN CWStringArray &aUnkEpHierarchy
  181. );
  182. // DB Access abstraction for Quasar ease of porting.
  183. // =================================================
  184. HRESULT Db_GetClass(
  185. IN LPCWSTR pszName,
  186. OUT IWbemClassObject **pObj
  187. );
  188. HRESULT Db_GetRefClasses(
  189. IN LPCWSTR pszClass,
  190. OUT CWStringArray &aRefClasses
  191. );
  192. HRESULT Db_GetInstRefs(
  193. IN LPCWSTR pszTarget,
  194. IN IWbemObjectSink *pDest
  195. );
  196. HRESULT Db_GetClassRefClasses(
  197. IN CFlexArray &aDest
  198. );
  199. HRESULT GetClassDynasty(
  200. IN LPCWSTR pszClass,
  201. OUT CFlexArray &aDynasty
  202. );
  203. // Various static auxiliaries for tests.
  204. // ======================================
  205. static HRESULT St_HasClassRefs(
  206. IN IWbemClassObject *pCandidate
  207. );
  208. HRESULT AccessCheck(IWbemClassObject* pObj);
  209. static HRESULT St_GetObjectInfo(
  210. IN IWbemClassObject *pObj,
  211. OUT BSTR *pClass,
  212. OUT BSTR *pRelpath,
  213. OUT BSTR *pPath,
  214. OUT CWStringArray &aHierarchy
  215. );
  216. static HRESULT St_ObjPathInfo(
  217. IN LPCWSTR pszPath,
  218. OUT BSTR *pszClass,
  219. OUT BOOL *pbIsClass
  220. );
  221. static HRESULT St_ReleaseArray(
  222. IN CFlexArray &aObjects
  223. );
  224. static HRESULT St_ObjHasQualifier(
  225. IN LPCWSTR pszQualName,
  226. IN IWbemClassObject *pObj
  227. );
  228. static HRESULT St_ObjIsOfClass(
  229. IN LPCWSTR pszRequiredClass,
  230. IN IWbemClassObject *pObj
  231. );
  232. HRESULT GetClassDefsOnlyClass(
  233. IN IWbemClassObject *pExample,
  234. OUT IWbemClassObject **pClass
  235. );
  236. HRESULT FindParentmostClass(
  237. IN IWbemClassObject *pAssocInst,
  238. OUT IWbemClassObject **pClassDef
  239. );
  240. HRESULT TagProp(
  241. IN IWbemClassObject *pObjToTag,
  242. IN LPCWSTR pszPropName,
  243. IN LPCWSTR pszInOutTag
  244. );
  245. // Other.
  246. // ======
  247. void UpdateTime() { m_dwLastResultTime = GetCurrentTime(); }
  248. void SignalSinkDone() { SetEvent(m_hSinkDoneEvent);}
  249. HRESULT GetDynClasses();
  250. HRESULT GetDynClass(
  251. IN LPCWSTR pszClassName,
  252. OUT IWbemClassObject **pCls
  253. );
  254. void SortDynClasses();
  255. HRESULT ResolveEpPathsToObjects(int nMaxToProcess);
  256. HRESULT ComputeInOutTags(
  257. IN IWbemClassObject *pAssocInst,
  258. IN IWbemClassObject *pClass
  259. );
  260. static HRESULT PathPointsToObj(
  261. IN LPCWSTR pszPath,
  262. IN IWbemClassObject *pObj,
  263. IN CWbemNamespace *pNs
  264. );
  265. HRESULT GetClassFromAnywhere(
  266. IN LPCWSTR pszEpClassName,
  267. IN LPCWSTR pszFullClassPath,
  268. OUT IWbemClassObject **pCls
  269. );
  270. HRESULT AddEpCandidatePath(
  271. IN BSTR strOtherEp
  272. );
  273. void EmptyCandidateEpArray();
  274. CObjectSink * CreateSink(PF_FilterForwarder pfnFilter, BSTR strTrackingQuery);
  275. public:
  276. static CAssocQuery *CreateInst();
  277. // IUnknown.
  278. // =========
  279. ULONG STDMETHODCALLTYPE AddRef();
  280. ULONG STDMETHODCALLTYPE Release();
  281. STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
  282. HRESULT Execute(
  283. IN CWbemNamespace *pNs,
  284. IN LPWSTR wszQuery,
  285. IN IWbemContext* pContext,
  286. IN CBasicObjectSink* pSink
  287. );
  288. HRESULT Cancel();
  289. static HRESULT RoleTest(
  290. IN IWbemClassObject *pEndpoint,
  291. IN IWbemClassObject *pCandidate,
  292. IN CWbemNamespace *pNs,
  293. IN LPCWSTR pszRole,
  294. IN DWORD dwMode
  295. );
  296. };
  297. #endif
  298.