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.

8449 lines
184 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. ProvFact.cpp
  5. Abstract:
  6. History:
  7. --*/
  8. #include "PreComp.h"
  9. #include <typeinfo.h>
  10. #include <stdio.h>
  11. #include <sddl.h>
  12. #include <wbemint.h>
  13. #include <genlex.h>
  14. #include <sql_1.h>
  15. #include <HelperFuncs.h>
  16. #include <Logging.h>
  17. #include <HelperFuncs.h>
  18. #include "CGlobals.h"
  19. #include "ProvDnf.h"
  20. #include "ProvRegInfo.h"
  21. #include "DateTime.h"
  22. #include "ssdlhelper.h"
  23. /******************************************************************************
  24. *
  25. * Name:
  26. *
  27. *
  28. * Description:
  29. *
  30. *
  31. *****************************************************************************/
  32. GENERIC_MAPPING g_ProviderBindingMapping = {
  33. 0 ,
  34. 0 ,
  35. STANDARD_RIGHTS_REQUIRED | MASK_PROVIDER_BINDING_BIND ,
  36. STANDARD_RIGHTS_REQUIRED | MASK_PROVIDER_BINDING_BIND
  37. } ;
  38. /******************************************************************************
  39. *
  40. * Name:
  41. *
  42. *
  43. * Description:
  44. *
  45. *
  46. *****************************************************************************/
  47. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi_Class = L"__CLASS" ;
  48. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi___ObjectProviderCacheControl = L"__ObjectProviderCacheControl" ;
  49. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi___EventProviderCacheControl = L"__EventProviderCacheControl" ;
  50. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi_ClearAfter = L"ClearAfter" ;
  51. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi_s_Strings_Query_Object = L"Select * from __ObjectProviderCacheControl" ;
  52. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi_s_Strings_Path_Object = L"__ObjectProviderCacheControl=@" ;
  53. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi_s_Strings_Query_Event = L"Select * from __EventProviderCacheControl" ;
  54. LPCWSTR CServerObject_GlobalRegistration :: s_Strings_Wmi_s_Strings_Path_Event = L"__EventProviderCacheControl=@" ;
  55. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_HostQuotas_Query = L"Select * from __ProviderHostQuotaConfiguration" ;
  56. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_HostQuotas_Path = L"__ProviderHostQuotaConfiguration=@" ;
  57. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_MemoryPerHost = L"MemoryPerHost" ;
  58. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_MemoryAllHosts = L"MemoryAllHosts" ;
  59. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_ThreadsPerHost = L"ThreadsPerHost" ;
  60. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_HandlesPerHost = L"HandlesPerHost" ;
  61. LPCWSTR CServerObject_HostQuotaRegistration :: s_Strings_Wmi_ProcessLimitAllHosts = L"ProcessLimitAllHosts" ;
  62. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_ClsidKeyStr = L"CLSID\\" ;
  63. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Null = NULL ;
  64. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_ThreadingModel = L"ThreadingModel" ;
  65. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_InProcServer32 = L"InProcServer32" ;
  66. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_LocalServer32 = L"LocalServer32" ;
  67. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Synchronization = L"Synchronization" ;
  68. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_AppId = L"AppId" ;
  69. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Apartment_Apartment = L"apartment" ;
  70. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Apartment_Both = L"both";
  71. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Apartment_Free = L"free";
  72. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Apartment_Neutral = L"neutral";
  73. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Synchronization_Ignored = L"ignored" ;
  74. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Synchronization_None = L"none" ;
  75. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Synchronization_Supported = L"supported" ;
  76. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Synchronization_Required = L"required" ;
  77. LPCWSTR CServerObject_ComRegistration :: s_Strings_Reg_Synchronization_RequiresNew = L"requiresnew" ;
  78. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Clsid = L"CLSID" ;
  79. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_ClientClsid = L"ClientLoadableCLSID" ;
  80. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Name = L"Name" ;
  81. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultMachineName = L"DefaultMachineName" ;
  82. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_UnloadTimeout = L"UnloadTimeout" ;
  83. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_ImpersonationLevel = L"ImpersonationLevel" ;
  84. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_InitializationReentrancy = L"InitializationReentrancy" ;
  85. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_InitializeAsAdminFirst = L"InitializeAsAdminFirst" ;
  86. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_PerUserInitialization = L"PerUserInitialization" ;
  87. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_PerLocaleInitialization = L"PerLocaleInitialization" ;
  88. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Pure = L"Pure" ;
  89. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Hosting = L"HostingModel" ;
  90. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_HostingGroup = L"HostingGroup" ;
  91. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SupportsThrottling = L"SupportsThrottling" ;
  92. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SupportsShutdown = L"SupportsShutdown" ;
  93. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_ConcurrentIndependantRequests = L"ConcurrentIndependantRequests";
  94. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SupportsSendStatus = L"SupportsSendStatus" ;
  95. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_OperationTimeoutInterval = L"OperationTimeoutInterval" ;
  96. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_InitializationTimeoutInterval = L"InitializationTimeoutInterval" ;
  97. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SupportsQuotas = L"SupportsQuotas" ;
  98. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Enabled = L"Enabled" ;
  99. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Version = L"Version" ;
  100. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SecurityDescriptor = L"SecurityDescriptor" ;
  101. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_WmiCore [] = L"WmiCore" ;
  102. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_WmiCoreOrSelfHost [] = L"WmiCoreOrSelfHost" ;
  103. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SelfHost [] = L"SelfHost" ;
  104. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_Decoupled [] = L"Decoupled:Com" ;
  105. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DecoupledColon [] = L"Decoupled:Com:" ;
  106. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SharedLocalSystemHost [] = L"LocalSystemHost" ;
  107. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SharedLocalSystemHostOrSelfHost [] = L"LocalSystemHostOrSelfHost" ;
  108. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SharedNetworkServiceHost [] = L"NetworkServiceHost" ;
  109. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SharedLocalServiceHost [] = L"LocalServiceHost" ;
  110. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_SharedUserHost [] = L"UserHost" ;
  111. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_NonCom [] = L"Decoupled:NonCom" ;
  112. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultSharedLocalSystemHost [] = L"DefaultLocalSystemHost" ;
  113. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultSharedLocalSystemHostOrSelfHost [] = L"DefaultLocalSystemHost" ;
  114. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultSharedNetworkServiceHost [] = L"DefaultNetworkServiceHost" ;
  115. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultSharedLocalServiceHost [] = L"DefaultLocalServiceHost" ;
  116. WCHAR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultSharedUserHost [] = L"DefaultUserHost" ;
  117. LPCWSTR CServerObject_ComProviderRegistrationV1 :: s_Strings_Wmi_DefaultHostingRegistryKey = L"Software\\Microsoft\\WBEM\\Providers\\Configuration\\" ;
  118. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  119. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_InstanceProviderRegistration = L"__InstanceProviderRegistration" ;
  120. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_SupportsPut = L"SupportsPut" ;
  121. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_SupportsGet = L"SupportsGet" ;
  122. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_SupportsDelete = L"SupportsDelete" ;
  123. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_SupportsEnumeration = L"SupportsEnumeration" ;
  124. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_QuerySupportLevels = L"QuerySupportLevels" ;
  125. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_InteractionType = L"InteractionType" ;
  126. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_SupportsBatching = L"SupportsBatching" ;;
  127. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_SupportsTransactions = L"SupportsTransactions" ;;
  128. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_QuerySupportLevels_UnarySelect = L"WQL:UnarySelect" ;
  129. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_QuerySupportLevels_References = L"WQL:References" ;
  130. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_QuerySupportLevels_Associators = L"WQL:Associators" ;
  131. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_QuerySupportLevels_V1ProviderDefined = L"WQL:V1ProviderDefined" ;
  132. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_InteractionType_Pull = L"Pull" ;
  133. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_InteractionType_Push = L"Push" ;
  134. LPCWSTR CServerObject_InstanceProviderRegistrationV1 :: s_Strings_InteractionType_PushVerify = L"PushVerify" ;
  135. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  136. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_ClassProviderRegistration = L"__ClassProviderRegistration" ;
  137. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_SupportsPut = L"SupportsPut" ;
  138. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_SupportsGet = L"SupportsGet" ;
  139. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_SupportsDelete = L"SupportsDelete" ;
  140. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_SupportsEnumeration = L"SupportsEnumeration" ;
  141. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_QuerySupportLevels = L"QuerySupportLevels" ;
  142. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_InteractionType = L"InteractionType" ;
  143. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_SupportsBatching = L"SupportsBatching" ;
  144. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_SupportsTransactions = L"SupportsTransactions" ;
  145. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_CacheRefreshInterval = L"CacheRefreshInterval" ;
  146. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_PerUserSchema = L"PerUserSchema" ;
  147. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_ReSynchroniseOnNamespaceOpen = L"ReSynchroniseOnNamespaceOpen" ;
  148. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_Version = L"Version" ;
  149. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_QuerySupportLevels_UnarySelect = L"WQL:UnarySelect" ;
  150. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_QuerySupportLevels_References = L"WQL:References" ;
  151. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_QuerySupportLevels_Associators = L"WQL:Associators" ;
  152. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_QuerySupportLevels_V1ProviderDefined = L"WQL:V1ProviderDefined" ;
  153. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_InteractionType_Pull = L"Pull" ;
  154. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_InteractionType_Push = L"Push" ;
  155. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_InteractionType_PushVerify = L"PushVerify" ;
  156. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_ResultSetQueries = L"ResultSetQueries" ;
  157. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_UnSupportedQueries = L"UnSupportedQueries" ;
  158. LPCWSTR CServerObject_ClassProviderRegistrationV1 :: s_Strings_ReferencedSetQueries = L"ReferencedSetQueries" ;
  159. LPCWSTR CServerObject_MethodProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  160. LPCWSTR CServerObject_MethodProviderRegistrationV1 :: s_Strings_MethodProviderRegistration = L"__MethodProviderRegistration" ;
  161. LPCWSTR CServerObject_EventProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  162. LPCWSTR CServerObject_EventProviderRegistrationV1 :: s_Strings_EventProviderRegistration = L"__EventProviderRegistration" ;
  163. LPCWSTR CServerObject_EventConsumerProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  164. LPCWSTR CServerObject_EventConsumerProviderRegistrationV1 :: s_Strings_EventConsumerProviderRegistration = L"__EventConsumerProviderRegistration" ;
  165. LPCWSTR CServerObject_DynamicPropertyProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  166. LPCWSTR CServerObject_DynamicPropertyProviderRegistrationV1 :: s_Strings_PropertyProviderRegistration = L"__PropertyProviderRegistration" ;
  167. LPCWSTR CServerObject_DynamicPropertyProviderRegistrationV1 :: s_Strings_SupportsPut = L"SupportsPut" ;
  168. LPCWSTR CServerObject_DynamicPropertyProviderRegistrationV1 :: s_Strings_SupportsGet = L"SupportsGet" ;
  169. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_Class = L"__CLASS" ;
  170. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_ClassProviderRegistration = L"__ClassProviderRegistration" ;
  171. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_InstanceProviderRegistration = L"__InstanceProviderRegistration" ;
  172. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_MethodProviderRegistration = L"__MethodProviderRegistration" ;
  173. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_PropertyProviderRegistration = L"__PropertyProviderRegistration" ;
  174. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_EventProviderRegistration = L"__EventProviderRegistration" ;
  175. LPCWSTR CServerObject_ProviderRegistrationV1 :: s_Strings_EventConsumerProviderRegistration = L"__EventConsumerProviderRegistration" ;
  176. /******************************************************************************
  177. *
  178. * Name:
  179. *
  180. *
  181. * Description:
  182. *
  183. *
  184. *****************************************************************************/
  185. CServerObject_GlobalRegistration :: CServerObject_GlobalRegistration () :
  186. m_Context ( NULL ) ,
  187. m_Namespace ( NULL ) ,
  188. m_Repository ( NULL ) ,
  189. m_Object_UnloadTimeout ( NULL ) ,
  190. m_Event_UnloadTimeout ( NULL ) ,
  191. m_Object_UnloadTimeoutMilliSeconds ( DEFAULT_PROVIDER_TIMEOUT ) ,
  192. m_Event_UnloadTimeoutMilliSeconds ( DEFAULT_PROVIDER_TIMEOUT ) ,
  193. m_Result ( S_OK )
  194. {
  195. }
  196. /******************************************************************************
  197. *
  198. * Name:
  199. *
  200. *
  201. * Description:
  202. *
  203. *
  204. *****************************************************************************/
  205. CServerObject_GlobalRegistration :: ~CServerObject_GlobalRegistration ()
  206. {
  207. if ( m_Context )
  208. {
  209. m_Context->Release () ;
  210. }
  211. if ( m_Namespace )
  212. {
  213. m_Namespace->Release () ;
  214. }
  215. if ( m_Repository )
  216. {
  217. m_Repository->Release () ;
  218. }
  219. if ( m_Object_UnloadTimeout )
  220. {
  221. SysFreeString ( m_Object_UnloadTimeout ) ;
  222. }
  223. if ( m_Event_UnloadTimeout )
  224. {
  225. SysFreeString ( m_Event_UnloadTimeout ) ;
  226. }
  227. }
  228. /******************************************************************************
  229. *
  230. * Name:
  231. *
  232. *
  233. * Description:
  234. *
  235. *
  236. *****************************************************************************/
  237. ULONG CServerObject_GlobalRegistration :: AddRef ()
  238. {
  239. return InterlockedIncrement ( & m_ReferenceCount ) ;
  240. }
  241. /******************************************************************************
  242. *
  243. * Name:
  244. *
  245. *
  246. * Description:
  247. *
  248. *
  249. *****************************************************************************/
  250. ULONG CServerObject_GlobalRegistration :: Release ()
  251. {
  252. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  253. if ( t_ReferenceCount == 0 )
  254. {
  255. delete this ;
  256. }
  257. return t_ReferenceCount ;
  258. }
  259. /******************************************************************************
  260. *
  261. * Name:
  262. *
  263. *
  264. * Description:
  265. *
  266. *
  267. *****************************************************************************/
  268. HRESULT CServerObject_GlobalRegistration :: SetContext (
  269. IWbemContext *a_Context ,
  270. IWbemPath *a_Namespace ,
  271. IWbemServices *a_Repository
  272. )
  273. {
  274. HRESULT t_Result = S_OK ;
  275. m_Context = a_Context ;
  276. m_Namespace = a_Namespace ;
  277. m_Repository = a_Repository ;
  278. if ( m_Context )
  279. {
  280. m_Context->AddRef () ;
  281. }
  282. if ( m_Namespace )
  283. {
  284. m_Namespace->AddRef () ;
  285. }
  286. if ( m_Repository )
  287. {
  288. m_Repository->AddRef () ;
  289. }
  290. return t_Result ;
  291. }
  292. /******************************************************************************
  293. *
  294. * Name:
  295. *
  296. *
  297. * Description:
  298. *
  299. *
  300. *****************************************************************************/
  301. HRESULT CServerObject_GlobalRegistration :: QueryProperties (
  302. Enum_PropertyMask a_Mask ,
  303. IWbemClassObject *a_Object ,
  304. LPWSTR &a_UnloadTimeout ,
  305. ULONG &a_UnloadTimeoutMilliSeconds
  306. )
  307. {
  308. HRESULT t_Result = S_OK ;
  309. if ( a_Mask & e_ClearAfter )
  310. {
  311. VARIANT t_Variant ;
  312. VariantInit ( & t_Variant ) ;
  313. LONG t_VarType = 0 ;
  314. LONG t_Flavour = 0 ;
  315. t_Result = a_Object->Get ( s_Strings_Wmi_ClearAfter , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  316. if ( SUCCEEDED ( t_Result ) )
  317. {
  318. if ( t_Variant.vt == VT_BSTR )
  319. {
  320. if ( a_UnloadTimeout )
  321. {
  322. SysFreeString ( a_UnloadTimeout ) ;
  323. }
  324. a_UnloadTimeout = SysAllocString ( t_Variant.bstrVal ) ;
  325. if ( a_UnloadTimeout )
  326. {
  327. CWbemDateTime t_Interval ;
  328. t_Result = t_Interval.PutValue ( a_UnloadTimeout ) ;
  329. if ( SUCCEEDED ( t_Result ) )
  330. {
  331. VARIANT_BOOL t_Bool = VARIANT_FALSE ;
  332. t_Result = t_Interval.GetIsInterval ( & t_Bool ) ;
  333. if ( t_Bool == VARIANT_TRUE )
  334. {
  335. LONG t_MicroSeconds = 0 ;
  336. LONG t_Seconds = 0 ;
  337. LONG t_Minutes = 0 ;
  338. LONG t_Hours = 0 ;
  339. LONG t_Days = 0 ;
  340. t_Interval.GetMicroseconds ( & t_MicroSeconds ) ;
  341. t_Interval.GetSeconds ( & t_Seconds ) ;
  342. t_Interval.GetMinutes ( & t_Minutes ) ;
  343. t_Interval.GetHours ( & t_Hours ) ;
  344. t_Interval.GetDay ( & t_Days ) ;
  345. a_UnloadTimeoutMilliSeconds = ( t_Days * 24 * 60 * 60 * 1000 ) +
  346. ( t_Hours * 60 * 60 * 1000 ) +
  347. ( t_Minutes * 60 * 1000 ) +
  348. ( t_Seconds * 1000 ) +
  349. ( t_MicroSeconds / 1000 ) ;
  350. }
  351. else
  352. {
  353. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  354. }
  355. }
  356. else
  357. {
  358. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  359. }
  360. }
  361. else
  362. {
  363. t_Result = WBEM_E_OUT_OF_MEMORY ;
  364. }
  365. }
  366. else if ( t_Variant.vt == VT_NULL )
  367. {
  368. if ( a_UnloadTimeout )
  369. {
  370. SysFreeString ( a_UnloadTimeout ) ;
  371. a_UnloadTimeout = NULL ;
  372. }
  373. }
  374. else
  375. {
  376. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  377. }
  378. }
  379. VariantClear ( & t_Variant ) ;
  380. }
  381. return t_Result ;
  382. }
  383. /******************************************************************************
  384. *
  385. * Name:
  386. *
  387. *
  388. * Description:
  389. *
  390. *
  391. *****************************************************************************/
  392. HRESULT CServerObject_GlobalRegistration :: QueryRepository (
  393. Enum_PropertyMask a_Mask
  394. )
  395. {
  396. HRESULT t_Result = S_OK ;
  397. BSTR t_ObjectPath = SysAllocString ( s_Strings_Wmi_s_Strings_Path_Object ) ;
  398. if ( t_ObjectPath )
  399. {
  400. IWbemClassObject *t_ClassObject = NULL ;
  401. t_Result = m_Repository->GetObject (
  402. t_ObjectPath ,
  403. 0 ,
  404. m_Context ,
  405. & t_ClassObject ,
  406. NULL
  407. ) ;
  408. if ( SUCCEEDED ( t_Result ) )
  409. {
  410. t_Result = QueryProperties (
  411. a_Mask ,
  412. t_ClassObject ,
  413. m_Object_UnloadTimeout ,
  414. m_Object_UnloadTimeoutMilliSeconds
  415. ) ;
  416. t_ClassObject->Release () ;
  417. }
  418. SysFreeString ( t_ObjectPath ) ;
  419. }
  420. else
  421. {
  422. t_Result = WBEM_E_OUT_OF_MEMORY ;
  423. }
  424. if ( SUCCEEDED ( t_Result ) )
  425. {
  426. BSTR t_ObjectPath = SysAllocString ( s_Strings_Wmi_s_Strings_Path_Event ) ;
  427. if ( t_ObjectPath )
  428. {
  429. IWbemClassObject *t_ClassObject = NULL ;
  430. t_Result = m_Repository->GetObject (
  431. t_ObjectPath ,
  432. 0 ,
  433. m_Context ,
  434. & t_ClassObject ,
  435. NULL
  436. ) ;
  437. if ( SUCCEEDED ( t_Result ) )
  438. {
  439. t_Result = QueryProperties (
  440. a_Mask ,
  441. t_ClassObject ,
  442. m_Event_UnloadTimeout ,
  443. m_Event_UnloadTimeoutMilliSeconds
  444. ) ;
  445. t_ClassObject->Release () ;
  446. }
  447. SysFreeString ( t_ObjectPath ) ;
  448. }
  449. else
  450. {
  451. t_Result = WBEM_E_OUT_OF_MEMORY ;
  452. }
  453. }
  454. return t_Result ;
  455. }
  456. /******************************************************************************
  457. *
  458. * Name:
  459. *
  460. *
  461. * Description:
  462. *
  463. *
  464. *****************************************************************************/
  465. HRESULT CServerObject_GlobalRegistration :: Load (
  466. Enum_PropertyMask a_Mask
  467. )
  468. {
  469. HRESULT t_Result = S_OK ;
  470. t_Result = QueryRepository (
  471. a_Mask
  472. ) ;
  473. return t_Result ;
  474. }
  475. /******************************************************************************
  476. *
  477. * Name:
  478. *
  479. *
  480. * Description:
  481. *
  482. *
  483. *****************************************************************************/
  484. CServerObject_HostQuotaRegistration :: CServerObject_HostQuotaRegistration () :
  485. m_Context ( NULL ) ,
  486. m_Namespace ( NULL ) ,
  487. m_Repository ( NULL ) ,
  488. m_MemoryPerHost ( 0 ) ,
  489. m_MemoryAllHosts ( 0 ) ,
  490. m_ThreadsPerHost ( 0 ) ,
  491. m_HandlesPerHost ( 0 ) ,
  492. m_ProcessLimitAllHosts ( 0 ) ,
  493. m_Result ( S_OK )
  494. {
  495. }
  496. /******************************************************************************
  497. *
  498. * Name:
  499. *
  500. *
  501. * Description:
  502. *
  503. *
  504. *****************************************************************************/
  505. CServerObject_HostQuotaRegistration :: ~CServerObject_HostQuotaRegistration ()
  506. {
  507. if ( m_Context )
  508. {
  509. m_Context->Release () ;
  510. }
  511. if ( m_Namespace )
  512. {
  513. m_Namespace->Release () ;
  514. }
  515. if ( m_Repository )
  516. {
  517. m_Repository->Release () ;
  518. }
  519. }
  520. /******************************************************************************
  521. *
  522. * Name:
  523. *
  524. *
  525. * Description:
  526. *
  527. *
  528. *****************************************************************************/
  529. ULONG CServerObject_HostQuotaRegistration :: AddRef ()
  530. {
  531. return InterlockedIncrement ( & m_ReferenceCount ) ;
  532. }
  533. /******************************************************************************
  534. *
  535. * Name:
  536. *
  537. *
  538. * Description:
  539. *
  540. *
  541. *****************************************************************************/
  542. ULONG CServerObject_HostQuotaRegistration :: Release ()
  543. {
  544. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  545. if ( t_ReferenceCount == 0 )
  546. {
  547. delete this ;
  548. }
  549. return t_ReferenceCount ;
  550. }
  551. /******************************************************************************
  552. *
  553. * Name:
  554. *
  555. *
  556. * Description:
  557. *
  558. *
  559. *****************************************************************************/
  560. HRESULT CServerObject_HostQuotaRegistration :: SetContext (
  561. IWbemContext *a_Context ,
  562. IWbemPath *a_Namespace ,
  563. IWbemServices *a_Repository
  564. )
  565. {
  566. HRESULT t_Result = S_OK ;
  567. m_Context = a_Context ;
  568. m_Namespace = a_Namespace ;
  569. m_Repository = a_Repository ;
  570. if ( m_Context )
  571. {
  572. m_Context->AddRef () ;
  573. }
  574. if ( m_Namespace )
  575. {
  576. m_Namespace->AddRef () ;
  577. }
  578. if ( m_Repository )
  579. {
  580. m_Repository->AddRef () ;
  581. }
  582. return t_Result ;
  583. }
  584. /******************************************************************************
  585. *
  586. * Name:
  587. *
  588. *
  589. * Description:
  590. *
  591. *
  592. *****************************************************************************/
  593. HRESULT CServerObject_HostQuotaRegistration :: QueryProperties (
  594. Enum_PropertyMask a_Mask ,
  595. IWbemClassObject *a_Object
  596. )
  597. {
  598. HRESULT t_Result = S_OK ;
  599. _IWmiObject *t_FastObject = NULL ;
  600. t_Result = a_Object->QueryInterface ( IID__IWmiObject , ( void ** ) & t_FastObject ) ;
  601. if ( SUCCEEDED ( t_Result ) )
  602. {
  603. if ( a_Mask & e_MemoryAllHosts )
  604. {
  605. UINT64 t_Value = 0 ;
  606. BOOL t_IsNull = FALSE ;
  607. CIMTYPE t_VarType = CIM_EMPTY ;
  608. LONG t_Flavour = 0 ;
  609. ULONG t_Used = 0 ;
  610. t_Result = t_FastObject->ReadProp (
  611. s_Strings_Wmi_MemoryAllHosts ,
  612. 0 ,
  613. sizeof ( UINT64 ) ,
  614. & t_VarType ,
  615. & t_Flavour ,
  616. & t_IsNull ,
  617. & t_Used ,
  618. & t_Value
  619. ) ;
  620. if ( SUCCEEDED ( t_Result ) )
  621. {
  622. if ( t_IsNull )
  623. {
  624. m_MemoryAllHosts = 0 ;
  625. }
  626. else
  627. {
  628. if ( t_VarType == CIM_UINT64 )
  629. {
  630. m_MemoryAllHosts = t_Value ;
  631. }
  632. else
  633. {
  634. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  635. }
  636. }
  637. }
  638. }
  639. if ( SUCCEEDED(t_Result) && (a_Mask & e_MemoryPerHost) )
  640. {
  641. UINT64 t_Value = 0 ;
  642. BOOL t_IsNull = FALSE ;
  643. CIMTYPE t_VarType = CIM_EMPTY ;
  644. LONG t_Flavour = 0 ;
  645. ULONG t_Used = 0 ;
  646. t_Result = t_FastObject->ReadProp (
  647. s_Strings_Wmi_MemoryPerHost ,
  648. 0 ,
  649. sizeof ( UINT64 ) ,
  650. & t_VarType ,
  651. & t_Flavour ,
  652. & t_IsNull ,
  653. & t_Used ,
  654. & t_Value
  655. ) ;
  656. if ( SUCCEEDED ( t_Result ) )
  657. {
  658. if ( t_IsNull )
  659. {
  660. m_MemoryPerHost = 0 ;
  661. }
  662. else
  663. {
  664. if ( t_VarType == CIM_UINT64 )
  665. {
  666. m_MemoryPerHost = t_Value ;
  667. }
  668. else
  669. {
  670. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  671. }
  672. }
  673. }
  674. }
  675. t_FastObject->Release () ;
  676. }
  677. if ( SUCCEEDED(t_Result) && (a_Mask & e_ThreadsPerHost) )
  678. {
  679. VARIANT t_Variant ;
  680. VariantInit ( & t_Variant ) ;
  681. LONG t_VarType = 0 ;
  682. LONG t_Flavour = 0 ;
  683. t_Result = a_Object->Get ( s_Strings_Wmi_ThreadsPerHost , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  684. if ( SUCCEEDED ( t_Result ) )
  685. {
  686. if ( t_Variant.vt == VT_I4 )
  687. {
  688. m_ThreadsPerHost = t_Variant.lVal ;
  689. }
  690. else if ( t_Variant.vt == VT_NULL )
  691. {
  692. m_ThreadsPerHost = 0 ;
  693. }
  694. else
  695. {
  696. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  697. }
  698. }
  699. VariantClear ( & t_Variant ) ;
  700. }
  701. if ( SUCCEEDED(t_Result) && (a_Mask & e_HandlesPerHost) )
  702. {
  703. VARIANT t_Variant ;
  704. VariantInit ( & t_Variant ) ;
  705. LONG t_VarType = 0 ;
  706. LONG t_Flavour = 0 ;
  707. t_Result = a_Object->Get ( s_Strings_Wmi_HandlesPerHost , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  708. if ( SUCCEEDED ( t_Result ) )
  709. {
  710. if ( t_Variant.vt == VT_I4 )
  711. {
  712. m_HandlesPerHost = t_Variant.lVal ;
  713. }
  714. else if ( t_Variant.vt == VT_NULL )
  715. {
  716. m_HandlesPerHost = 0 ;
  717. }
  718. else
  719. {
  720. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  721. }
  722. }
  723. VariantClear ( & t_Variant ) ;
  724. }
  725. if ( SUCCEEDED(t_Result) && (a_Mask & e_ProcessLimitAllHosts) )
  726. {
  727. VARIANT t_Variant ;
  728. VariantInit ( & t_Variant ) ;
  729. LONG t_VarType = 0 ;
  730. LONG t_Flavour = 0 ;
  731. t_Result = a_Object->Get ( s_Strings_Wmi_ProcessLimitAllHosts , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  732. if ( SUCCEEDED ( t_Result ) )
  733. {
  734. if ( t_Variant.vt == VT_I4 )
  735. {
  736. m_ProcessLimitAllHosts = t_Variant.lVal ;
  737. }
  738. else if ( t_Variant.vt == VT_NULL )
  739. {
  740. m_ProcessLimitAllHosts = 0 ;
  741. }
  742. else
  743. {
  744. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  745. }
  746. }
  747. VariantClear ( & t_Variant ) ;
  748. }
  749. return t_Result ;
  750. }
  751. /******************************************************************************
  752. *
  753. * Name:
  754. *
  755. *
  756. * Description:
  757. *
  758. *
  759. *****************************************************************************/
  760. HRESULT CServerObject_HostQuotaRegistration :: QueryRepository (
  761. Enum_PropertyMask a_Mask
  762. )
  763. {
  764. HRESULT t_Result = S_OK ;
  765. BSTR t_ObjectPath = SysAllocString ( s_Strings_Wmi_HostQuotas_Path ) ;
  766. if ( t_ObjectPath )
  767. {
  768. IWbemClassObject *t_ClassObject = NULL ;
  769. t_Result = m_Repository->GetObject (
  770. t_ObjectPath ,
  771. 0 ,
  772. m_Context ,
  773. & t_ClassObject ,
  774. NULL
  775. ) ;
  776. if ( SUCCEEDED ( t_Result ) )
  777. {
  778. t_Result = QueryProperties (
  779. a_Mask ,
  780. t_ClassObject
  781. ) ;
  782. t_ClassObject->Release () ;
  783. }
  784. SysFreeString ( t_ObjectPath ) ;
  785. }
  786. else
  787. {
  788. t_Result = WBEM_E_OUT_OF_MEMORY ;
  789. }
  790. return t_Result ;
  791. }
  792. /******************************************************************************
  793. *
  794. * Name:
  795. *
  796. *
  797. * Description:
  798. *
  799. *
  800. *****************************************************************************/
  801. HRESULT CServerObject_HostQuotaRegistration :: Load (
  802. Enum_PropertyMask a_Mask
  803. )
  804. {
  805. HRESULT t_Result = S_OK ;
  806. t_Result = QueryRepository (
  807. a_Mask
  808. ) ;
  809. return t_Result ;
  810. }
  811. /******************************************************************************
  812. *
  813. * Name:
  814. *
  815. *
  816. * Description:
  817. *
  818. *
  819. *****************************************************************************/
  820. CServerObject_ComRegistration :: CServerObject_ComRegistration ()
  821. : m_ThreadingModel ( e_ThreadingModel_Unknown ) ,
  822. m_Synchronization ( e_Ignored ) ,
  823. m_InProcServer32 ( e_Boolean_Unknown ) ,
  824. m_LocalServer32 ( e_Boolean_Unknown ) ,
  825. m_Service ( e_Boolean_Unknown ) ,
  826. m_Loaded ( e_False ) ,
  827. m_Clsid ( NULL ) ,
  828. m_AppId ( NULL ) ,
  829. m_ProviderName ( NULL ) ,
  830. m_Result ( S_OK )
  831. {
  832. m_InProcServer32_Path [ 0 ] = 0 ;
  833. m_LocalServer32_Path [ 0 ] = 0 ;
  834. m_Server_Name [ 0 ] = 0 ;
  835. }
  836. /******************************************************************************
  837. *
  838. * Name:
  839. *
  840. *
  841. * Description:
  842. *
  843. *
  844. *****************************************************************************/
  845. CServerObject_ComRegistration :: ~CServerObject_ComRegistration ()
  846. {
  847. if ( m_AppId )
  848. {
  849. SysFreeString ( m_AppId ) ;
  850. }
  851. if ( m_Clsid )
  852. {
  853. SysFreeString ( m_Clsid ) ;
  854. }
  855. if ( m_ProviderName )
  856. {
  857. SysFreeString ( m_ProviderName ) ;
  858. }
  859. }
  860. /******************************************************************************
  861. *
  862. * Name:
  863. *
  864. *
  865. * Description:
  866. *
  867. *
  868. *****************************************************************************/
  869. ULONG CServerObject_ComRegistration :: AddRef ()
  870. {
  871. return InterlockedIncrement ( & m_ReferenceCount ) ;
  872. }
  873. /******************************************************************************
  874. *
  875. * Name:
  876. *
  877. *
  878. * Description:
  879. *
  880. *
  881. *****************************************************************************/
  882. ULONG CServerObject_ComRegistration :: Release ()
  883. {
  884. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  885. if ( t_ReferenceCount == 0 )
  886. {
  887. delete this ;
  888. }
  889. return t_ReferenceCount ;
  890. }
  891. /******************************************************************************
  892. *
  893. * Name:
  894. *
  895. *
  896. * Description:
  897. *
  898. *
  899. *****************************************************************************/
  900. HRESULT CServerObject_ComRegistration :: Load_ThreadingModel ( HKEY a_ClsidKey )
  901. {
  902. HRESULT t_Result = S_OK ;
  903. DWORD t_ValueType = REG_SZ ;
  904. wchar_t t_Data [ MAX_PATH ] ;
  905. DWORD t_DataSize = sizeof ( t_Data ) ;
  906. LONG t_RegResult = RegQueryValueEx (
  907. a_ClsidKey ,
  908. s_Strings_Reg_ThreadingModel ,
  909. 0 ,
  910. & t_ValueType ,
  911. LPBYTE ( & t_Data ) ,
  912. & t_DataSize
  913. );
  914. if ( t_RegResult == ERROR_SUCCESS )
  915. {
  916. if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Apartment_Apartment ) == 0 )
  917. {
  918. m_ThreadingModel = e_Apartment ;
  919. }
  920. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Apartment_Both ) == 0 )
  921. {
  922. m_ThreadingModel = e_Both ;
  923. }
  924. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Apartment_Free ) == 0 )
  925. {
  926. m_ThreadingModel = e_Free ;
  927. }
  928. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Apartment_Neutral ) == 0 )
  929. {
  930. m_ThreadingModel = e_Neutral ;
  931. }
  932. else
  933. {
  934. m_ThreadingModel = e_ThreadingModel_Unknown ;
  935. }
  936. }
  937. else
  938. {
  939. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  940. }
  941. return t_Result ;
  942. }
  943. /******************************************************************************
  944. *
  945. * Name:
  946. *
  947. *
  948. * Description:
  949. *
  950. *
  951. *****************************************************************************/
  952. HRESULT CServerObject_ComRegistration :: Load_Synchronization ( HKEY a_ClsidKey )
  953. {
  954. HRESULT t_Result = S_OK ;
  955. DWORD t_ValueType = REG_SZ ;
  956. wchar_t t_Data [ MAX_PATH ] ;
  957. DWORD t_DataSize = sizeof ( t_Data ) ;
  958. LONG t_RegResult = RegQueryValueEx (
  959. a_ClsidKey ,
  960. s_Strings_Reg_Synchronization ,
  961. 0 ,
  962. & t_ValueType ,
  963. LPBYTE ( & t_Data ) ,
  964. & t_DataSize
  965. );
  966. if ( t_RegResult == ERROR_SUCCESS )
  967. {
  968. if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Synchronization_Ignored ) == 0 )
  969. {
  970. m_Synchronization = e_Ignored ;
  971. }
  972. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Synchronization_None ) == 0 )
  973. {
  974. m_Synchronization = e_None ;
  975. }
  976. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Synchronization_Supported ) == 0 )
  977. {
  978. m_Synchronization = e_Supported ;
  979. }
  980. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Synchronization_Required ) == 0 )
  981. {
  982. m_Synchronization = e_Required ;
  983. }
  984. else if ( wbem_wcsicmp ( t_Data , s_Strings_Reg_Synchronization_RequiresNew ) == 0 )
  985. {
  986. m_Synchronization = e_RequiresNew ;
  987. }
  988. else
  989. {
  990. m_Synchronization = e_Synchronization_Unknown ;
  991. }
  992. }
  993. return t_Result ;
  994. }
  995. /******************************************************************************
  996. *
  997. * Name:
  998. *
  999. *
  1000. * Description:
  1001. *
  1002. *
  1003. *****************************************************************************/
  1004. HRESULT CServerObject_ComRegistration :: Load_InProcServer32 ( LPCWSTR a_ClsidStringKey )
  1005. {
  1006. HRESULT t_Result = S_OK ;
  1007. LPWSTR t_Clsid_String_Key_InProcServer32 = NULL ;
  1008. t_Result = WmiHelper :: ConcatenateStrings (
  1009. 2,
  1010. & t_Clsid_String_Key_InProcServer32 ,
  1011. a_ClsidStringKey ,
  1012. s_Strings_Reg_InProcServer32
  1013. ) ;
  1014. if ( SUCCEEDED ( t_Result ) )
  1015. {
  1016. HKEY t_Clsid_Key_InProcServer32 ;
  1017. LONG t_RegResult = RegOpenKeyEx (
  1018. HKEY_CLASSES_ROOT ,
  1019. t_Clsid_String_Key_InProcServer32 ,
  1020. 0 ,
  1021. KEY_READ ,
  1022. & t_Clsid_Key_InProcServer32
  1023. ) ;
  1024. if ( t_RegResult == ERROR_SUCCESS )
  1025. {
  1026. m_InProcServer32 = e_True ;
  1027. t_Result = Load_ThreadingModel ( t_Clsid_Key_InProcServer32 ) ;
  1028. if ( SUCCEEDED ( t_Result ) )
  1029. {
  1030. t_Result = Load_Synchronization ( t_Clsid_Key_InProcServer32 ) ;
  1031. }
  1032. DWORD t_ValueType = REG_SZ ;
  1033. DWORD t_DataSize = sizeof ( m_InProcServer32_Path ) ;
  1034. t_RegResult = RegQueryValueEx (
  1035. t_Clsid_Key_InProcServer32 ,
  1036. s_Strings_Reg_Null ,
  1037. 0 ,
  1038. & t_ValueType ,
  1039. LPBYTE ( & m_InProcServer32_Path ) ,
  1040. & t_DataSize
  1041. );
  1042. if ( t_RegResult == ERROR_SUCCESS )
  1043. {
  1044. }
  1045. RegCloseKey ( t_Clsid_Key_InProcServer32 ) ;
  1046. }
  1047. SysFreeString ( t_Clsid_String_Key_InProcServer32 ) ;
  1048. }
  1049. return t_Result ;
  1050. }
  1051. /******************************************************************************
  1052. *
  1053. * Name:
  1054. *
  1055. *
  1056. * Description:
  1057. *
  1058. *
  1059. *****************************************************************************/
  1060. HRESULT CServerObject_ComRegistration :: Load_LocalServer32 ( LPCWSTR a_ClsidStringKey )
  1061. {
  1062. HRESULT t_Result = S_OK ;
  1063. LPWSTR t_Clsid_String_Key_LocalServer32 = NULL ;
  1064. t_Result = WmiHelper :: ConcatenateStrings (
  1065. 2,
  1066. & t_Clsid_String_Key_LocalServer32 ,
  1067. a_ClsidStringKey ,
  1068. s_Strings_Reg_LocalServer32
  1069. ) ;
  1070. if ( SUCCEEDED ( t_Result ) )
  1071. {
  1072. HKEY t_Clsid_Key_LocalServer32 ;
  1073. LONG t_RegResult = RegOpenKeyEx (
  1074. HKEY_CLASSES_ROOT ,
  1075. t_Clsid_String_Key_LocalServer32 ,
  1076. 0 ,
  1077. KEY_READ ,
  1078. & t_Clsid_Key_LocalServer32
  1079. ) ;
  1080. if ( t_RegResult == ERROR_SUCCESS )
  1081. {
  1082. m_LocalServer32 = e_True ;
  1083. m_ThreadingModel = e_Free ;
  1084. m_Synchronization = e_Ignored ;
  1085. DWORD t_ValueType = REG_SZ ;
  1086. DWORD t_DataSize = sizeof ( m_LocalServer32_Path ) ;
  1087. t_RegResult = RegQueryValueEx (
  1088. t_Clsid_Key_LocalServer32 ,
  1089. s_Strings_Reg_Null ,
  1090. 0 ,
  1091. & t_ValueType ,
  1092. LPBYTE ( & m_LocalServer32_Path ) ,
  1093. & t_DataSize
  1094. );
  1095. if ( t_RegResult == ERROR_SUCCESS )
  1096. {
  1097. }
  1098. RegCloseKey ( t_Clsid_Key_LocalServer32 ) ;
  1099. }
  1100. SysFreeString ( t_Clsid_String_Key_LocalServer32 ) ;
  1101. }
  1102. return t_Result ;
  1103. }
  1104. /******************************************************************************
  1105. *
  1106. * Name:
  1107. *
  1108. *
  1109. * Description:
  1110. *
  1111. *
  1112. *****************************************************************************/
  1113. HRESULT CServerObject_ComRegistration :: Load_ServerTypes ( LPCWSTR a_ClsidString )
  1114. {
  1115. HRESULT t_Result = S_OK ;
  1116. LPWSTR t_Clsid_String_Key = NULL ;
  1117. t_Result = WmiHelper :: ConcatenateStrings (
  1118. 2,
  1119. & t_Clsid_String_Key ,
  1120. a_ClsidString ,
  1121. L"\\"
  1122. ) ;
  1123. if ( SUCCEEDED ( t_Result ) )
  1124. {
  1125. t_Result = Load_InProcServer32 ( t_Clsid_String_Key ) ;
  1126. if ( SUCCEEDED ( t_Result ) )
  1127. {
  1128. t_Result = Load_LocalServer32 ( t_Clsid_String_Key ) ;
  1129. if ( SUCCEEDED ( t_Result ) )
  1130. {
  1131. }
  1132. }
  1133. SysFreeString ( t_Clsid_String_Key ) ;
  1134. }
  1135. return t_Result ;
  1136. }
  1137. /******************************************************************************
  1138. *
  1139. * Name:
  1140. *
  1141. *
  1142. * Description:
  1143. *
  1144. *
  1145. *****************************************************************************/
  1146. HRESULT CServerObject_ComRegistration :: Load_AppId ( HKEY a_Clsid_Key )
  1147. {
  1148. HRESULT t_Result = S_OK ;
  1149. DWORD t_ValueType = REG_SZ ;
  1150. wchar_t t_Data [ MAX_PATH ] ;
  1151. DWORD t_DataSize = sizeof ( t_Data ) ;
  1152. LONG t_RegResult = RegQueryValueEx (
  1153. a_Clsid_Key ,
  1154. s_Strings_Reg_AppId ,
  1155. 0 ,
  1156. & t_ValueType ,
  1157. LPBYTE ( & t_Data ) ,
  1158. & t_DataSize
  1159. );
  1160. if ( t_RegResult == ERROR_SUCCESS )
  1161. {
  1162. if ( m_AppId )
  1163. {
  1164. SysFreeString ( m_AppId ) ;
  1165. }
  1166. m_AppId = SysAllocString ( t_Data ) ;
  1167. if ( m_AppId )
  1168. {
  1169. }
  1170. else
  1171. {
  1172. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1173. }
  1174. }
  1175. return t_Result ;
  1176. }
  1177. /******************************************************************************
  1178. *
  1179. * Name:
  1180. *
  1181. *
  1182. * Description:
  1183. *
  1184. *
  1185. *****************************************************************************/
  1186. HRESULT CServerObject_ComRegistration :: Load ( LPCWSTR a_Clsid , LPCWSTR a_ProviderName )
  1187. {
  1188. HRESULT t_Result = S_OK ;
  1189. if ( m_Clsid )
  1190. {
  1191. SysFreeString ( m_Clsid ) ;
  1192. m_Clsid = 0;
  1193. }
  1194. if (0 != a_Clsid)
  1195. {
  1196. m_Clsid = SysAllocString ( a_Clsid ) ;
  1197. if (0 == m_Clsid ) return WBEM_E_OUT_OF_MEMORY;
  1198. }
  1199. if ( m_ProviderName )
  1200. {
  1201. SysFreeString ( m_ProviderName ) ;
  1202. m_ProviderName = 0;
  1203. }
  1204. if (0!=a_ProviderName )
  1205. {
  1206. m_ProviderName = SysAllocString ( a_ProviderName ) ;
  1207. if (0 == m_ProviderName) return WBEM_E_OUT_OF_MEMORY;
  1208. }
  1209. LPWSTR t_Clsid_String = NULL ;
  1210. t_Result = WmiHelper :: ConcatenateStrings (
  1211. 2,
  1212. & t_Clsid_String ,
  1213. s_Strings_Reg_ClsidKeyStr ,
  1214. a_Clsid
  1215. ) ;
  1216. if ( SUCCEEDED ( t_Result ) )
  1217. {
  1218. t_Result = Load_ServerTypes ( t_Clsid_String ) ;
  1219. HKEY t_Clsid_Key ;
  1220. LONG t_RegResult = RegOpenKeyEx (
  1221. HKEY_CLASSES_ROOT ,
  1222. t_Clsid_String ,
  1223. 0 ,
  1224. KEY_READ ,
  1225. & t_Clsid_Key
  1226. ) ;
  1227. if ( t_RegResult == ERROR_SUCCESS )
  1228. {
  1229. DWORD t_ValueType = REG_SZ ;
  1230. DWORD t_DataSize = sizeof ( m_Server_Name ) ;
  1231. t_RegResult = RegQueryValueEx (
  1232. t_Clsid_Key ,
  1233. s_Strings_Reg_Null ,
  1234. 0 ,
  1235. & t_ValueType ,
  1236. LPBYTE ( & m_Server_Name ) ,
  1237. & t_DataSize
  1238. );
  1239. if ( t_RegResult == ERROR_SUCCESS )
  1240. {
  1241. }
  1242. else
  1243. {
  1244. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  1245. }
  1246. if ( SUCCEEDED ( t_Result ) )
  1247. {
  1248. t_Result = Load_AppId ( t_Clsid_Key ) ;
  1249. if ( SUCCEEDED ( t_Result ) )
  1250. {
  1251. if ( m_InProcServer32 != e_True && m_LocalServer32 != e_True )
  1252. {
  1253. m_Service = e_True ;
  1254. m_ThreadingModel = e_Free ;
  1255. m_Synchronization = e_Ignored ;
  1256. }
  1257. }
  1258. }
  1259. RegCloseKey ( t_Clsid_Key ) ;
  1260. }
  1261. SysFreeString ( t_Clsid_String ) ;
  1262. }
  1263. if ( SUCCEEDED ( t_Result ) )
  1264. {
  1265. m_Loaded = e_True ;
  1266. }
  1267. return t_Result ;
  1268. }
  1269. /******************************************************************************
  1270. *
  1271. * Name:
  1272. *
  1273. *
  1274. * Description:
  1275. *
  1276. *
  1277. *****************************************************************************/
  1278. CServerObject_ComProviderRegistrationV1 :: CServerObject_ComProviderRegistrationV1 () :
  1279. m_Context ( NULL ) ,
  1280. m_Namespace ( NULL ) ,
  1281. m_Repository ( NULL ) ,
  1282. m_Identity ( NULL ) ,
  1283. m_DefaultMachineName ( NULL ) ,
  1284. m_UnloadTimeout ( NULL ) ,
  1285. m_UnloadTimeoutMilliSeconds ( DEFAULT_PROVIDER_TIMEOUT ) ,
  1286. m_OperationTimeout ( NULL ) ,
  1287. m_OperationTimeoutMilliSeconds ( INFINITE ) ,
  1288. m_InitializationTimeout ( NULL ) ,
  1289. m_InitializationTimeoutMilliSeconds ( DEFAULT_PROVIDER_LOAD_TIMEOUT ) ,
  1290. m_Enabled ( TRUE ) ,
  1291. m_SupportsQuotas ( FALSE ) ,
  1292. m_SupportsThrottling ( FALSE ) ,
  1293. m_SupportsSendStatus ( FALSE ) ,
  1294. m_SupportsShutdown ( FALSE ) ,
  1295. m_ConcurrentIndependantRequests ( 0 ) ,
  1296. m_ImpersonationLevel ( e_ImpersonationLevel_Unknown ) ,
  1297. m_InitializationReentrancy ( e_InitializationReentrancy_Namespace ) ,
  1298. m_InitializeAsAdminFirst ( FALSE ) ,
  1299. m_PerUserInitialization ( FALSE ) ,
  1300. m_PerLocaleInitialization ( FALSE ) ,
  1301. m_Pure ( FALSE ) ,
  1302. m_Version ( 1 ) ,
  1303. m_ProviderName ( NULL ) ,
  1304. m_Hosting ( e_Hosting_Undefined ) , // e_Hosting_SharedLocalSystemHost e_Hosting_WmiCore
  1305. m_HostingGroup ( NULL ) ,
  1306. m_Result ( S_OK ) ,
  1307. m_SecurityDescriptor ( NULL ) ,
  1308. m_DecoupledImpersonationRestriction ( TRUE )
  1309. {
  1310. ZeroMemory ( & m_CLSID , sizeof ( GUID ) ) ;
  1311. ZeroMemory ( & m_ClientCLSID , sizeof ( GUID ) ) ;
  1312. }
  1313. /******************************************************************************
  1314. *
  1315. * Name:
  1316. *
  1317. *
  1318. * Description:
  1319. *
  1320. *
  1321. *****************************************************************************/
  1322. CServerObject_ComProviderRegistrationV1 :: ~CServerObject_ComProviderRegistrationV1 ()
  1323. {
  1324. if ( m_SecurityDescriptor )
  1325. {
  1326. LocalFree ( m_SecurityDescriptor ) ;
  1327. }
  1328. if ( m_Context )
  1329. {
  1330. m_Context->Release () ;
  1331. }
  1332. if ( m_Namespace )
  1333. {
  1334. m_Namespace->Release () ;
  1335. }
  1336. if ( m_Repository )
  1337. {
  1338. m_Repository->Release () ;
  1339. }
  1340. if ( m_Identity )
  1341. {
  1342. m_Identity->Release () ;
  1343. }
  1344. if ( m_DefaultMachineName )
  1345. {
  1346. SysFreeString ( m_DefaultMachineName ) ;
  1347. }
  1348. if ( m_UnloadTimeout )
  1349. {
  1350. SysFreeString ( m_UnloadTimeout ) ;
  1351. }
  1352. if ( m_HostingGroup )
  1353. {
  1354. SysFreeString ( m_HostingGroup ) ;
  1355. }
  1356. if ( m_InitializationTimeout )
  1357. {
  1358. SysFreeString ( m_InitializationTimeout ) ;
  1359. }
  1360. if ( m_ProviderName )
  1361. {
  1362. SysFreeString ( m_ProviderName ) ;
  1363. }
  1364. }
  1365. /******************************************************************************
  1366. *
  1367. * Name:
  1368. *
  1369. *
  1370. * Description:
  1371. *
  1372. *
  1373. *****************************************************************************/
  1374. ULONG CServerObject_ComProviderRegistrationV1 :: AddRef ()
  1375. {
  1376. return InterlockedIncrement ( & m_ReferenceCount ) ;
  1377. }
  1378. /******************************************************************************
  1379. *
  1380. * Name:
  1381. *
  1382. *
  1383. * Description:
  1384. *
  1385. *
  1386. *****************************************************************************/
  1387. ULONG CServerObject_ComProviderRegistrationV1 :: Release ()
  1388. {
  1389. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  1390. if ( t_ReferenceCount == 0 )
  1391. {
  1392. delete this ;
  1393. }
  1394. return t_ReferenceCount ;
  1395. }
  1396. /******************************************************************************
  1397. *
  1398. * Name:
  1399. *
  1400. *
  1401. * Description:
  1402. *
  1403. *
  1404. *****************************************************************************/
  1405. HRESULT CServerObject_ComProviderRegistrationV1 :: SetContext (
  1406. IWbemContext *a_Context ,
  1407. IWbemPath *a_Namespace ,
  1408. IWbemServices *a_Repository
  1409. )
  1410. {
  1411. HRESULT t_Result = S_OK ;
  1412. m_Context = a_Context ;
  1413. m_Namespace = a_Namespace ;
  1414. m_Repository = a_Repository ;
  1415. if ( m_Context )
  1416. {
  1417. m_Context->AddRef () ;
  1418. }
  1419. if ( m_Namespace )
  1420. {
  1421. m_Namespace->AddRef () ;
  1422. }
  1423. if ( m_Repository )
  1424. {
  1425. m_Repository->AddRef () ;
  1426. }
  1427. return t_Result ;
  1428. }
  1429. /******************************************************************************
  1430. *
  1431. * Name:
  1432. *
  1433. *
  1434. * Description:
  1435. *
  1436. *
  1437. *****************************************************************************/
  1438. HRESULT CServerObject_ComProviderRegistrationV1 :: GetDefaultHostingGroup (
  1439. Enum_Hosting a_HostingValue ,
  1440. BSTR & a_HostingGroup
  1441. )
  1442. {
  1443. HRESULT t_Result = S_OK ;
  1444. switch ( a_HostingValue )
  1445. {
  1446. case e_Hosting_SharedLocalSystemHost:
  1447. case e_Hosting_SharedLocalSystemHostOrSelfHost:
  1448. {
  1449. a_HostingGroup = SysAllocString ( s_Strings_Wmi_DefaultSharedLocalSystemHost ) ;
  1450. }
  1451. break ;
  1452. case e_Hosting_SharedNetworkServiceHost:
  1453. {
  1454. a_HostingGroup = SysAllocString ( s_Strings_Wmi_DefaultSharedNetworkServiceHost ) ;
  1455. }
  1456. break ;
  1457. case e_Hosting_SharedLocalServiceHost:
  1458. {
  1459. a_HostingGroup = SysAllocString ( s_Strings_Wmi_DefaultSharedLocalServiceHost ) ;
  1460. }
  1461. break ;
  1462. default:
  1463. {
  1464. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  1465. }
  1466. break ;
  1467. }
  1468. if ( SUCCEEDED(t_Result) && (0 == a_HostingGroup) ) t_Result = WBEM_E_OUT_OF_MEMORY;
  1469. return t_Result ;
  1470. }
  1471. /******************************************************************************
  1472. *
  1473. * Name:
  1474. *
  1475. *
  1476. * Description:
  1477. *
  1478. *
  1479. *****************************************************************************/
  1480. HRESULT CServerObject_ComProviderRegistrationV1 :: GetHostingGroup (
  1481. LPCWSTR a_Hosting ,
  1482. size_t a_Prefix ,
  1483. Enum_Hosting a_ExpectedHostingValue ,
  1484. Enum_Hosting & a_HostingValue ,
  1485. BSTR & a_HostingGroup
  1486. )
  1487. {
  1488. HRESULT t_Result = S_OK ;
  1489. size_t t_Length = wcslen ( a_Hosting ) ;
  1490. if ( t_Length > a_Prefix )
  1491. {
  1492. if ( a_Hosting [ a_Prefix ] == L':' )
  1493. {
  1494. if ( t_Length > a_Prefix + 1 )
  1495. {
  1496. a_HostingGroup = SysAllocString ( & a_Hosting [ a_Prefix + 1 ] ) ;
  1497. if ( a_HostingGroup )
  1498. {
  1499. }
  1500. else
  1501. {
  1502. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1503. }
  1504. a_HostingValue = a_ExpectedHostingValue ;
  1505. }
  1506. else
  1507. {
  1508. t_Result = GetDefaultHostingGroup ( a_ExpectedHostingValue , a_HostingGroup ) ;
  1509. }
  1510. }
  1511. else
  1512. {
  1513. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  1514. }
  1515. }
  1516. else
  1517. {
  1518. t_Result = GetDefaultHostingGroup ( a_ExpectedHostingValue , a_HostingGroup ) ;
  1519. a_HostingValue = a_ExpectedHostingValue ;
  1520. }
  1521. return t_Result ;
  1522. }
  1523. /******************************************************************************
  1524. *
  1525. * Name:
  1526. *
  1527. *
  1528. * Description:
  1529. *
  1530. *
  1531. *****************************************************************************/
  1532. #define StateAction_Accept 1 // Add the char to the token
  1533. #define StateAction_Consume 2 // Consume the char without adding to token
  1534. #define StateAction_Pushback 4 // Place the char back in the source buffer for next token
  1535. #define StateAction_Not 8 // A match occurs if the char is NOT the one specified
  1536. #define StateAction_Linefeed 16 // Increase the source linecount
  1537. #define StateAction_Return 32 // Return the indicated token to caller
  1538. #define StateAction_Any 64 // wchar_t(0xFFFF) Any character
  1539. #define StateAction_Empty 128 // wchar_t(0xFFFE) When subrange is not specified
  1540. /******************************************************************************
  1541. *
  1542. * Name:
  1543. *
  1544. *
  1545. * Description:
  1546. *
  1547. *
  1548. *****************************************************************************/
  1549. struct StateTableEntry
  1550. {
  1551. wchar_t m_LowerRange ;
  1552. wchar_t m_UpperRange ;
  1553. ULONG m_Token ;
  1554. ULONG m_GotoState ;
  1555. ULONG m_Action ;
  1556. } ;
  1557. /******************************************************************************
  1558. *
  1559. * Name:
  1560. *
  1561. *
  1562. * Description:
  1563. *
  1564. *
  1565. *****************************************************************************/
  1566. enum LexicalStatus
  1567. {
  1568. Success ,
  1569. Syntax_Error ,
  1570. Lexical_Error ,
  1571. Failed ,
  1572. Buffer_Too_Small ,
  1573. ImpossibleState ,
  1574. UnexpectedEof ,
  1575. OutOfMemory
  1576. } ;
  1577. /******************************************************************************
  1578. *
  1579. * Name:
  1580. *
  1581. *
  1582. * Description:
  1583. *
  1584. *
  1585. *****************************************************************************/
  1586. #define TOKEN_IDENTITY 1
  1587. #define TOKEN_LEFTPARENTHESIS 2
  1588. #define TOKEN_RIGHTPARENTHESIS 3
  1589. #define TOKEN_TRUE 4
  1590. #define TOKEN_FALSE 5
  1591. #define TOKEN_EOF 6
  1592. #define TOKEN_ERROR 7
  1593. /******************************************************************************
  1594. *
  1595. * Name:
  1596. *
  1597. *
  1598. * Description:
  1599. *
  1600. *
  1601. *****************************************************************************/
  1602. struct StateTableEntry g_StateTable [] = {
  1603. ' ', 65534 , 0 , 0 , StateAction_Consume , // 0
  1604. '\t', 65534 , 0 , 0 , StateAction_Consume , // 1
  1605. 'a', 'z', 0 , 8 , StateAction_Accept , // 2
  1606. 'A', 'Z', 0 , 8 , StateAction_Accept , // 3
  1607. '(', 65534 , TOKEN_LEFTPARENTHESIS , 0 , StateAction_Return , // 4
  1608. ')', 65534 , TOKEN_RIGHTPARENTHESIS , 0 , StateAction_Return , // 5
  1609. 0, 65534 , TOKEN_EOF , 0 , StateAction_Return , // 6
  1610. 65535, 65534 , TOKEN_ERROR , 0 , StateAction_Return , // 7
  1611. 'a', 'z', 0 , 8 , StateAction_Accept , // 8
  1612. 'A', 'Z', 0 , 8 , StateAction_Accept , // 9
  1613. 65535, 65534 , TOKEN_IDENTITY , 0 , StateAction_Pushback | StateAction_Return // 10
  1614. } ;
  1615. /******************************************************************************
  1616. *
  1617. * Name:
  1618. *
  1619. *
  1620. * Description:
  1621. *
  1622. *
  1623. *****************************************************************************/
  1624. LexicalStatus LexicalAnalyser_NextToken (
  1625. StateTableEntry *a_Dfa ,
  1626. ULONG a_DfaSize ,
  1627. const wchar_t *a_Stream ,
  1628. ULONG a_Position ,
  1629. ULONG &a_Token ,
  1630. ULONG &a_NextPosition ,
  1631. wchar_t *&a_TokenText
  1632. )
  1633. {
  1634. LexicalStatus t_Status = Success ;
  1635. a_Token = 0 ;
  1636. a_TokenText = NULL ;
  1637. a_NextPosition = a_Position ;
  1638. ULONG t_State = 0 ;
  1639. BOOL t_Read = TRUE ;
  1640. BOOL t_EndOfFile = FALSE ;
  1641. wchar_t t_Current = 0 ;
  1642. ULONG CurrentLine = 0 ;
  1643. wchar_t *t_TokenText = NULL ;
  1644. ULONG t_TokenTextActualSize = 0 ;
  1645. ULONG t_TokenTextBufferSize = 0 ;
  1646. while ( 1 )
  1647. {
  1648. wchar_t t_First = a_Dfa [ t_State ].m_LowerRange ;
  1649. wchar_t t_Last = a_Dfa [ t_State ].m_UpperRange ;
  1650. ULONG t_GotoState = a_Dfa [ t_State ].m_GotoState ;
  1651. ULONG t_ReturnToken = a_Dfa [ t_State ].m_Token ;
  1652. ULONG t_Action = a_Dfa [ t_State ].m_Action ;
  1653. if ( t_Read )
  1654. {
  1655. if ( t_EndOfFile )
  1656. {
  1657. t_Status = UnexpectedEof ;
  1658. delete [] t_TokenText ;
  1659. return t_Status ;
  1660. }
  1661. if ( a_NextPosition > wcslen ( a_Stream ) )
  1662. {
  1663. t_Current = 0 ;
  1664. t_EndOfFile = TRUE ;
  1665. }
  1666. else
  1667. {
  1668. t_Current = a_Stream [ a_NextPosition ] ;
  1669. }
  1670. }
  1671. BOOL t_Match = FALSE ;
  1672. if ( t_First == 65535 )
  1673. {
  1674. t_Match = TRUE ;
  1675. }
  1676. else
  1677. {
  1678. if ( t_Last == 65534 )
  1679. {
  1680. if ( t_Current == t_First )
  1681. {
  1682. t_Match = TRUE ;
  1683. }
  1684. else
  1685. {
  1686. if ( ( t_Action & StateAction_Not ) && ( t_Current != t_First ) )
  1687. {
  1688. t_Match = TRUE ;
  1689. }
  1690. }
  1691. }
  1692. else
  1693. {
  1694. if ( ( t_Action & StateAction_Not ) && ( ! ( ( t_Current >= t_First ) && ( t_Current <= t_Last ) ) ) )
  1695. {
  1696. t_Match = TRUE ;
  1697. }
  1698. else
  1699. {
  1700. if ( ( t_Current >= t_First ) && ( t_Current <= t_Last ) )
  1701. {
  1702. t_Match = TRUE ;
  1703. }
  1704. }
  1705. }
  1706. }
  1707. t_Read = FALSE ;
  1708. if ( t_Match )
  1709. {
  1710. if ( t_Action & StateAction_Accept )
  1711. {
  1712. if ( t_TokenText )
  1713. {
  1714. if ( t_TokenTextActualSize < t_TokenTextBufferSize - 1 )
  1715. {
  1716. }
  1717. else
  1718. {
  1719. t_TokenTextBufferSize = t_TokenTextBufferSize + 32 ;
  1720. wchar_t *t_TempTokenText = new wchar_t [ t_TokenTextBufferSize ] ;
  1721. if ( t_TempTokenText )
  1722. {
  1723. CopyMemory ( t_TempTokenText , t_TokenText , ( t_TokenTextActualSize ) * sizeof ( wchar_t ) ) ;
  1724. delete [] t_TokenText ;
  1725. t_TokenText = t_TempTokenText ;
  1726. }
  1727. else
  1728. {
  1729. delete [] t_TokenText ;
  1730. return OutOfMemory ;
  1731. }
  1732. }
  1733. t_TokenText [ t_TokenTextActualSize ] = t_Current ;
  1734. t_TokenText [ t_TokenTextActualSize + 1 ] = 0 ;
  1735. t_TokenTextActualSize ++ ;
  1736. }
  1737. else
  1738. {
  1739. t_TokenTextActualSize = 1 ;
  1740. t_TokenTextBufferSize = 32 ;
  1741. t_TokenText = new wchar_t [ t_TokenTextBufferSize ] ;
  1742. if ( t_TokenText )
  1743. {
  1744. t_TokenText [ 0 ] = t_Current ;
  1745. t_TokenText [ 1 ] = 0 ;
  1746. }
  1747. else
  1748. {
  1749. return OutOfMemory ;
  1750. }
  1751. }
  1752. t_Read = TRUE ;
  1753. }
  1754. if ( t_Action & StateAction_Consume )
  1755. {
  1756. t_Read = TRUE ;
  1757. }
  1758. if ( t_Action & StateAction_Pushback )
  1759. {
  1760. t_Read = TRUE ;
  1761. a_NextPosition = a_NextPosition - 1 ;
  1762. }
  1763. if ( t_Action & StateAction_Linefeed )
  1764. {
  1765. CurrentLine = CurrentLine + 1 ;
  1766. }
  1767. a_NextPosition = a_NextPosition + 1 ;
  1768. if ( t_Action & StateAction_Return )
  1769. {
  1770. a_Token = t_ReturnToken ;
  1771. a_TokenText = t_TokenText ;
  1772. return t_Status ;
  1773. }
  1774. t_State = t_GotoState ;
  1775. }
  1776. else
  1777. {
  1778. t_State = t_State + 1 ;
  1779. }
  1780. }
  1781. delete [] t_TokenText ;
  1782. return ImpossibleState ;
  1783. }
  1784. /******************************************************************************
  1785. *
  1786. * Name:
  1787. *
  1788. *
  1789. * Description:
  1790. *
  1791. *
  1792. *****************************************************************************/
  1793. HRESULT CServerObject_ComProviderRegistrationV1 :: GetDecoupledImpersonationRestriction (
  1794. LPCWSTR a_Hosting ,
  1795. BOOL &a_ImpersonationRestriction
  1796. )
  1797. {
  1798. HRESULT t_Result = S_OK ;
  1799. if ( wbem_wcsicmp ( a_Hosting , s_Strings_Wmi_Decoupled ) != 0 )
  1800. {
  1801. if ( wbem_wcsnicmp ( a_Hosting , s_Strings_Wmi_DecoupledColon , ( sizeof ( s_Strings_Wmi_DecoupledColon ) / sizeof ( WCHAR ) - 1 ) ) == 0 )
  1802. {
  1803. const wchar_t *t_Scan = & a_Hosting [ ( sizeof ( s_Strings_Wmi_DecoupledColon ) / sizeof ( WCHAR ) - 1 ) ] ;
  1804. ULONG t_Position = 0 ;
  1805. ULONG t_Token = 0 ;
  1806. ULONG t_NextPosition = 0 ;
  1807. wchar_t *t_FoldText = NULL ;
  1808. LexicalStatus t_Status = LexicalAnalyser_NextToken (
  1809. g_StateTable ,
  1810. sizeof ( g_StateTable ) / sizeof ( StateTableEntry ) ,
  1811. t_Scan ,
  1812. t_Position ,
  1813. t_Token ,
  1814. t_NextPosition ,
  1815. t_FoldText
  1816. ) ;
  1817. if ( ( t_Status == Success ) && ( t_Token == TOKEN_IDENTITY ) && (t_FoldText!=0) && ( wbem_wcsicmp ( t_FoldText , L"FoldIdentity" ) == 0 ) )
  1818. {
  1819. wchar_t *t_IgnoreText = NULL ;
  1820. t_Position = t_NextPosition ;
  1821. t_Status = LexicalAnalyser_NextToken (
  1822. g_StateTable ,
  1823. sizeof ( g_StateTable ) / sizeof ( StateTableEntry ) ,
  1824. t_Scan ,
  1825. t_Position ,
  1826. t_Token ,
  1827. t_NextPosition ,
  1828. t_IgnoreText
  1829. ) ;
  1830. delete [] t_IgnoreText ;
  1831. if ( ( t_Status == Success ) && ( t_Token == TOKEN_LEFTPARENTHESIS ) )
  1832. {
  1833. wchar_t *t_ValueText = NULL ;
  1834. t_Position = t_NextPosition ;
  1835. t_Status = LexicalAnalyser_NextToken (
  1836. g_StateTable ,
  1837. sizeof ( g_StateTable ) / sizeof ( StateTableEntry ) ,
  1838. t_Scan ,
  1839. t_Position ,
  1840. t_Token ,
  1841. t_NextPosition ,
  1842. t_ValueText
  1843. ) ;
  1844. if ( ( t_Status == Success ) && ( t_Token == TOKEN_IDENTITY ) && ( wbem_wcsicmp ( t_ValueText , L"TRUE" ) == 0 ) )
  1845. {
  1846. a_ImpersonationRestriction = TRUE ;
  1847. }
  1848. else if ( ( t_Status == Success ) && ( t_Token == TOKEN_IDENTITY ) && ( wbem_wcsicmp ( t_ValueText , L"FALSE" ) == 0 ) )
  1849. {
  1850. a_ImpersonationRestriction = FALSE ;
  1851. }
  1852. else
  1853. {
  1854. t_Status = Syntax_Error ;
  1855. }
  1856. delete [] t_ValueText ;
  1857. }
  1858. else
  1859. {
  1860. t_Status = Syntax_Error ;
  1861. }
  1862. if ( t_Status == Success )
  1863. {
  1864. wchar_t *t_IgnoreText = NULL ;
  1865. t_Position = t_NextPosition ;
  1866. t_Status = LexicalAnalyser_NextToken (
  1867. g_StateTable ,
  1868. sizeof ( g_StateTable ) / sizeof ( StateTableEntry ) ,
  1869. t_Scan ,
  1870. t_Position ,
  1871. t_Token ,
  1872. t_NextPosition ,
  1873. t_IgnoreText
  1874. ) ;
  1875. if ( ( t_Status == Success ) && ( t_Token == TOKEN_RIGHTPARENTHESIS ) )
  1876. {
  1877. }
  1878. else
  1879. {
  1880. t_Status = Syntax_Error ;
  1881. }
  1882. delete [] t_IgnoreText ;
  1883. }
  1884. if ( t_Status == Success )
  1885. {
  1886. wchar_t *t_IgnoreText = NULL ;
  1887. t_Position = t_NextPosition ;
  1888. t_Status = LexicalAnalyser_NextToken (
  1889. g_StateTable ,
  1890. sizeof ( g_StateTable ) / sizeof ( StateTableEntry ) ,
  1891. t_Scan ,
  1892. t_Position ,
  1893. t_Token ,
  1894. t_NextPosition ,
  1895. t_IgnoreText
  1896. ) ;
  1897. if ( ( t_Status == Success ) && ( t_Token == TOKEN_EOF ) )
  1898. {
  1899. }
  1900. else
  1901. {
  1902. t_Status = Syntax_Error ;
  1903. }
  1904. delete [] t_IgnoreText ;
  1905. }
  1906. }
  1907. else
  1908. {
  1909. t_Status = Syntax_Error ;
  1910. }
  1911. delete [] t_FoldText ;
  1912. if ( t_Status != Success )
  1913. {
  1914. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  1915. }
  1916. }
  1917. else
  1918. {
  1919. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  1920. }
  1921. }
  1922. return t_Result ;
  1923. }
  1924. /******************************************************************************
  1925. *
  1926. * Name:
  1927. *
  1928. *
  1929. * Description:
  1930. *
  1931. *
  1932. *****************************************************************************/
  1933. HRESULT CServerObject_ComProviderRegistrationV1 :: GetHosting (
  1934. LPCWSTR a_Hosting ,
  1935. Enum_Hosting & a_HostingValue ,
  1936. LPWSTR &a_HostingGroup ,
  1937. BOOL & a_ImpersonationRestriction
  1938. )
  1939. {
  1940. HRESULT t_Result = S_OK ;
  1941. if ( wbem_wcsicmp ( a_Hosting , s_Strings_Wmi_WmiCore ) == 0 )
  1942. {
  1943. a_HostingValue = e_Hosting_WmiCore ;
  1944. }
  1945. else if ( wbem_wcsicmp ( a_Hosting , s_Strings_Wmi_WmiCoreOrSelfHost ) == 0 )
  1946. {
  1947. a_HostingValue = e_Hosting_WmiCoreOrSelfHost ;
  1948. }
  1949. else if ( wbem_wcsicmp ( a_Hosting , s_Strings_Wmi_SelfHost ) == 0 )
  1950. {
  1951. a_HostingValue = e_Hosting_SelfHost ;
  1952. }
  1953. else if ( wbem_wcsnicmp ( a_Hosting , s_Strings_Wmi_Decoupled , ( sizeof ( s_Strings_Wmi_Decoupled ) / sizeof ( WCHAR ) -1 ) ) == 0 )
  1954. {
  1955. a_HostingValue = e_Hosting_Decoupled ;
  1956. t_Result = GetDecoupledImpersonationRestriction (
  1957. a_Hosting ,
  1958. a_ImpersonationRestriction
  1959. ) ;
  1960. }
  1961. else if ( wbem_wcsicmp ( a_Hosting , s_Strings_Wmi_NonCom ) == 0 )
  1962. {
  1963. a_HostingValue = e_Hosting_NonCom ;
  1964. }
  1965. else if ( wbem_wcsnicmp ( a_Hosting , s_Strings_Wmi_SharedLocalSystemHostOrSelfHost , ( sizeof ( s_Strings_Wmi_SharedLocalSystemHostOrSelfHost ) / sizeof ( WCHAR ) - 1 ) ) == 0 )
  1966. {
  1967. t_Result = GetHostingGroup (
  1968. a_Hosting ,
  1969. ( sizeof ( s_Strings_Wmi_SharedLocalSystemHostOrSelfHost ) / sizeof ( WCHAR ) - 1 ) ,
  1970. e_Hosting_SharedLocalSystemHostOrSelfHost ,
  1971. a_HostingValue ,
  1972. a_HostingGroup
  1973. ) ;
  1974. }
  1975. else if ( wbem_wcsnicmp ( a_Hosting , s_Strings_Wmi_SharedLocalSystemHost , ( sizeof ( s_Strings_Wmi_SharedLocalSystemHost ) / sizeof ( WCHAR ) - 1 ) ) == 0 )
  1976. {
  1977. t_Result = GetHostingGroup (
  1978. a_Hosting ,
  1979. ( sizeof ( s_Strings_Wmi_SharedLocalSystemHost ) / sizeof ( WCHAR ) - 1 ) ,
  1980. e_Hosting_SharedLocalSystemHost ,
  1981. a_HostingValue ,
  1982. a_HostingGroup
  1983. ) ;
  1984. }
  1985. else if ( wbem_wcsnicmp ( a_Hosting , s_Strings_Wmi_SharedNetworkServiceHost , ( sizeof ( s_Strings_Wmi_SharedNetworkServiceHost ) / sizeof ( WCHAR ) - 1 ) ) == 0 )
  1986. {
  1987. t_Result = GetHostingGroup (
  1988. a_Hosting ,
  1989. ( sizeof ( s_Strings_Wmi_SharedNetworkServiceHost ) / sizeof ( WCHAR ) - 1 ) ,
  1990. e_Hosting_SharedNetworkServiceHost ,
  1991. a_HostingValue ,
  1992. a_HostingGroup
  1993. ) ;
  1994. }
  1995. else if ( wbem_wcsnicmp ( a_Hosting , s_Strings_Wmi_SharedLocalServiceHost , ( sizeof ( s_Strings_Wmi_SharedLocalServiceHost ) / sizeof ( WCHAR ) - 1 ) ) == 0 )
  1996. {
  1997. t_Result = GetHostingGroup (
  1998. a_Hosting ,
  1999. ( sizeof ( s_Strings_Wmi_SharedLocalServiceHost ) / sizeof ( WCHAR ) - 1 ) ,
  2000. e_Hosting_SharedLocalServiceHost ,
  2001. a_HostingValue ,
  2002. a_HostingGroup
  2003. ) ;
  2004. }
  2005. else
  2006. {
  2007. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2008. }
  2009. return t_Result ;
  2010. }
  2011. /******************************************************************************
  2012. *
  2013. * Name:
  2014. *
  2015. *
  2016. * Description:
  2017. *
  2018. *
  2019. *****************************************************************************/
  2020. HRESULT CServerObject_ComProviderRegistrationV1 :: QueryProperties (
  2021. Enum_PropertyMask a_Mask ,
  2022. IWbemClassObject *a_Object ,
  2023. LPCWSTR a_ProviderName
  2024. )
  2025. {
  2026. HRESULT t_Result = S_OK ;
  2027. if ( a_Mask & e_Version )
  2028. {
  2029. VARIANT t_Variant ;
  2030. VariantInit ( & t_Variant ) ;
  2031. LONG t_VarType = 0 ;
  2032. LONG t_Flavour = 0 ;
  2033. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_Version , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2034. if ( SUCCEEDED ( t_TempResult ) )
  2035. {
  2036. if ( t_Variant.vt == VT_I4 )
  2037. {
  2038. m_Version = t_Variant.lVal ;
  2039. }
  2040. else if ( t_Variant.vt == VT_NULL )
  2041. {
  2042. m_Version = 1 ;
  2043. }
  2044. else
  2045. {
  2046. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2047. }
  2048. }
  2049. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2050. {
  2051. t_Result = t_TempResult;
  2052. }
  2053. VariantClear ( & t_Variant ) ;
  2054. }
  2055. if ( SUCCEEDED ( t_Result ) )
  2056. {
  2057. if ( a_Mask & e_Name )
  2058. {
  2059. VARIANT t_Variant ;
  2060. VariantInit ( & t_Variant ) ;
  2061. LONG t_VarType = 0 ;
  2062. LONG t_Flavour = 0 ;
  2063. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_Name , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2064. if ( SUCCEEDED ( t_TempResult ) )
  2065. {
  2066. if ( t_Variant.vt == VT_BSTR )
  2067. {
  2068. if ( m_ProviderName )
  2069. {
  2070. SysFreeString ( m_ProviderName ) ;
  2071. }
  2072. m_ProviderName = SysAllocString ( t_Variant.bstrVal ) ;
  2073. if ( m_ProviderName == NULL )
  2074. {
  2075. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2076. }
  2077. }
  2078. else
  2079. {
  2080. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2081. }
  2082. }
  2083. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2084. {
  2085. t_Result = t_TempResult;
  2086. }
  2087. VariantClear ( & t_Variant ) ;
  2088. }
  2089. }
  2090. if ( SUCCEEDED ( t_Result ) )
  2091. {
  2092. if ( a_Mask & e_Enabled )
  2093. {
  2094. VARIANT t_Variant ;
  2095. VariantInit ( & t_Variant ) ;
  2096. LONG t_VarType = 0 ;
  2097. LONG t_Flavour = 0 ;
  2098. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_Enabled , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2099. if ( SUCCEEDED ( t_TempResult ) )
  2100. {
  2101. if ( t_Variant.vt == VT_BOOL )
  2102. {
  2103. m_Enabled = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2104. }
  2105. else if ( t_Variant.vt == VT_NULL )
  2106. {
  2107. m_Enabled = TRUE ;
  2108. }
  2109. else
  2110. {
  2111. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2112. }
  2113. }
  2114. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2115. {
  2116. t_Result = t_TempResult;
  2117. }
  2118. VariantClear ( & t_Variant ) ;
  2119. }
  2120. }
  2121. if ( SUCCEEDED ( t_Result ) )
  2122. {
  2123. if ( a_Mask & e_Clsid )
  2124. {
  2125. VARIANT t_Variant ;
  2126. VariantInit ( & t_Variant ) ;
  2127. LONG t_VarType = 0 ;
  2128. LONG t_Flavour = 0 ;
  2129. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_Clsid , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2130. if ( SUCCEEDED ( t_TempResult ) )
  2131. {
  2132. if ( t_Variant.vt == VT_BSTR )
  2133. {
  2134. t_Result = CLSIDFromString ( t_Variant.bstrVal , & m_CLSID ) ;
  2135. if ( SUCCEEDED ( t_Result ) )
  2136. {
  2137. t_Result = m_ClsidServer.Load ( (LPCWSTR) t_Variant.bstrVal , a_ProviderName ) ;
  2138. }
  2139. else
  2140. {
  2141. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2142. }
  2143. }
  2144. else if ( t_Variant.vt == VT_NULL )
  2145. {
  2146. m_CLSID = CLSID_NULL ;
  2147. }
  2148. else
  2149. {
  2150. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2151. }
  2152. }
  2153. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2154. {
  2155. t_Result = t_TempResult;
  2156. }
  2157. VariantClear ( & t_Variant ) ;
  2158. }
  2159. }
  2160. if ( SUCCEEDED ( t_Result ) )
  2161. {
  2162. if ( a_Mask & e_ClientClsid )
  2163. {
  2164. VARIANT t_Variant ;
  2165. VariantInit ( & t_Variant ) ;
  2166. LONG t_VarType = 0 ;
  2167. LONG t_Flavour = 0 ;
  2168. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_ClientClsid , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2169. if ( SUCCEEDED ( t_TempResult ) )
  2170. {
  2171. if ( t_Variant.vt == VT_BSTR )
  2172. {
  2173. t_Result = CLSIDFromString ( t_Variant.bstrVal , & m_ClientCLSID ) ;
  2174. if ( SUCCEEDED ( t_Result ) )
  2175. {
  2176. }
  2177. else
  2178. {
  2179. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2180. }
  2181. }
  2182. else if ( t_Variant.vt == VT_NULL )
  2183. {
  2184. m_ClientCLSID = CLSID_NULL ;
  2185. }
  2186. else
  2187. {
  2188. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2189. }
  2190. }
  2191. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2192. {
  2193. t_Result = t_TempResult;
  2194. }
  2195. VariantClear ( & t_Variant ) ;
  2196. }
  2197. }
  2198. if ( SUCCEEDED ( t_Result ) )
  2199. {
  2200. if ( a_Mask & e_DefaultMachineName )
  2201. {
  2202. VARIANT t_Variant ;
  2203. VariantInit ( & t_Variant ) ;
  2204. LONG t_VarType = 0 ;
  2205. LONG t_Flavour = 0 ;
  2206. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_DefaultMachineName , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2207. if ( SUCCEEDED ( t_TempResult ) )
  2208. {
  2209. if ( t_Variant.vt == VT_BSTR )
  2210. {
  2211. if ( m_DefaultMachineName )
  2212. {
  2213. SysFreeString ( m_DefaultMachineName ) ;
  2214. }
  2215. m_DefaultMachineName = SysAllocString ( t_Variant.bstrVal ) ;
  2216. if ( m_DefaultMachineName == NULL )
  2217. {
  2218. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2219. }
  2220. }
  2221. else if ( t_Variant.vt == VT_NULL )
  2222. {
  2223. if ( m_DefaultMachineName )
  2224. {
  2225. SysFreeString ( m_DefaultMachineName ) ;
  2226. m_DefaultMachineName = NULL ;
  2227. }
  2228. }
  2229. else
  2230. {
  2231. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2232. }
  2233. }
  2234. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2235. {
  2236. t_Result = t_TempResult;
  2237. }
  2238. VariantClear ( & t_Variant ) ;
  2239. }
  2240. }
  2241. if ( SUCCEEDED ( t_Result ) )
  2242. {
  2243. if ( a_Mask & e_UnloadTimeout )
  2244. {
  2245. VARIANT t_Variant ;
  2246. VariantInit ( & t_Variant ) ;
  2247. LONG t_VarType = 0 ;
  2248. LONG t_Flavour = 0 ;
  2249. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_UnloadTimeout , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2250. if ( SUCCEEDED ( t_TempResult ) )
  2251. {
  2252. if ( t_Variant.vt == VT_BSTR )
  2253. {
  2254. if ( m_UnloadTimeout )
  2255. {
  2256. SysFreeString ( m_UnloadTimeout ) ;
  2257. }
  2258. m_UnloadTimeout = SysAllocString ( t_Variant.bstrVal ) ;
  2259. if ( m_UnloadTimeout )
  2260. {
  2261. CWbemDateTime t_Interval ;
  2262. t_Result = t_Interval.PutValue ( m_UnloadTimeout ) ;
  2263. if ( SUCCEEDED ( t_Result ) )
  2264. {
  2265. VARIANT_BOOL t_Bool = VARIANT_FALSE ;
  2266. t_Result = t_Interval.GetIsInterval ( & t_Bool ) ;
  2267. if ( t_Bool == VARIANT_TRUE )
  2268. {
  2269. LONG t_MicroSeconds = 0 ;
  2270. LONG t_Seconds = 0 ;
  2271. LONG t_Minutes = 0 ;
  2272. LONG t_Hours = 0 ;
  2273. LONG t_Days = 0 ;
  2274. t_Interval.GetMicroseconds ( & t_MicroSeconds ) ;
  2275. t_Interval.GetSeconds ( & t_Seconds ) ;
  2276. t_Interval.GetMinutes ( & t_Minutes ) ;
  2277. t_Interval.GetHours ( & t_Hours ) ;
  2278. t_Interval.GetDay ( & t_Days ) ;
  2279. m_UnloadTimeoutMilliSeconds = ( t_Days * 24 * 60 * 60 * 1000 ) +
  2280. ( t_Hours * 60 * 60 * 1000 ) +
  2281. ( t_Minutes * 60 * 1000 ) +
  2282. ( t_Seconds * 1000 ) +
  2283. ( t_MicroSeconds / 1000 ) ;
  2284. }
  2285. else
  2286. {
  2287. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2288. }
  2289. }
  2290. else
  2291. {
  2292. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2293. }
  2294. }
  2295. else
  2296. {
  2297. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2298. }
  2299. }
  2300. else if ( t_Variant.vt == VT_NULL )
  2301. {
  2302. if ( m_UnloadTimeout )
  2303. {
  2304. SysFreeString ( m_UnloadTimeout ) ;
  2305. m_UnloadTimeout = NULL ;
  2306. }
  2307. }
  2308. else
  2309. {
  2310. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2311. }
  2312. }
  2313. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2314. {
  2315. t_Result = t_TempResult;
  2316. }
  2317. VariantClear ( & t_Variant ) ;
  2318. }
  2319. }
  2320. if ( SUCCEEDED ( t_Result ) )
  2321. {
  2322. if ( a_Mask & e_ImpersonationLevel )
  2323. {
  2324. VARIANT t_Variant ;
  2325. VariantInit ( & t_Variant ) ;
  2326. LONG t_VarType = 0 ;
  2327. LONG t_Flavour = 0 ;
  2328. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_ImpersonationLevel , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2329. if ( SUCCEEDED ( t_TempResult ) )
  2330. {
  2331. if ( t_Variant.vt == VT_I4 )
  2332. {
  2333. switch ( t_Variant.lVal )
  2334. {
  2335. case 0:
  2336. {
  2337. m_ImpersonationLevel = e_Impersonate_None ;
  2338. }
  2339. break ;
  2340. case 1:
  2341. {
  2342. m_ImpersonationLevel = e_Impersonate ;
  2343. }
  2344. break ;
  2345. default:
  2346. {
  2347. if ( m_Version > 1 )
  2348. {
  2349. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2350. }
  2351. else
  2352. {
  2353. m_ImpersonationLevel = e_Impersonate_None ;
  2354. }
  2355. }
  2356. break ;
  2357. }
  2358. }
  2359. else if ( t_Variant.vt == VT_NULL )
  2360. {
  2361. m_ImpersonationLevel = e_Impersonate_None ;
  2362. }
  2363. else
  2364. {
  2365. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2366. }
  2367. }
  2368. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2369. {
  2370. t_Result = t_TempResult;
  2371. }
  2372. VariantClear ( & t_Variant ) ;
  2373. }
  2374. }
  2375. if ( SUCCEEDED ( t_Result ) )
  2376. {
  2377. if ( a_Mask & e_SupportsSendStatus )
  2378. {
  2379. VARIANT t_Variant ;
  2380. VariantInit ( & t_Variant ) ;
  2381. LONG t_VarType = 0 ;
  2382. LONG t_Flavour = 0 ;
  2383. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_SupportsSendStatus , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2384. if ( SUCCEEDED ( t_TempResult ) )
  2385. {
  2386. if ( t_Variant.vt == VT_BOOL )
  2387. {
  2388. m_SupportsSendStatus = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2389. }
  2390. else if ( t_Variant.vt == VT_NULL )
  2391. {
  2392. m_SupportsSendStatus = TRUE ;
  2393. }
  2394. else
  2395. {
  2396. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2397. }
  2398. }
  2399. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2400. {
  2401. t_Result = t_TempResult;
  2402. }
  2403. VariantClear ( & t_Variant ) ;
  2404. }
  2405. }
  2406. if ( SUCCEEDED ( t_Result ) )
  2407. {
  2408. if ( a_Mask & e_SupportsShutdown )
  2409. {
  2410. VARIANT t_Variant ;
  2411. VariantInit ( & t_Variant ) ;
  2412. LONG t_VarType = 0 ;
  2413. LONG t_Flavour = 0 ;
  2414. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_SupportsShutdown , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2415. if ( SUCCEEDED ( t_TempResult ) )
  2416. {
  2417. if ( t_Variant.vt == VT_BOOL )
  2418. {
  2419. m_SupportsShutdown = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2420. }
  2421. else if ( t_Variant.vt == VT_NULL )
  2422. {
  2423. m_SupportsShutdown = FALSE ;
  2424. }
  2425. else
  2426. {
  2427. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2428. }
  2429. }
  2430. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2431. {
  2432. t_Result = t_TempResult;
  2433. }
  2434. VariantClear ( & t_Variant ) ;
  2435. }
  2436. }
  2437. if ( SUCCEEDED ( t_Result ) )
  2438. {
  2439. if ( a_Mask & e_SupportsQuotas )
  2440. {
  2441. VARIANT t_Variant ;
  2442. VariantInit ( & t_Variant ) ;
  2443. LONG t_VarType = 0 ;
  2444. LONG t_Flavour = 0 ;
  2445. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_SupportsQuotas , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2446. if ( SUCCEEDED ( t_TempResult ) )
  2447. {
  2448. if ( t_Variant.vt == VT_BOOL )
  2449. {
  2450. m_SupportsQuotas = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2451. }
  2452. else if ( t_Variant.vt == VT_NULL )
  2453. {
  2454. m_SupportsQuotas = FALSE ;
  2455. }
  2456. else
  2457. {
  2458. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2459. }
  2460. }
  2461. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2462. {
  2463. t_Result = t_TempResult;
  2464. }
  2465. VariantClear ( & t_Variant ) ;
  2466. }
  2467. }
  2468. if ( SUCCEEDED ( t_Result ) )
  2469. {
  2470. if ( a_Mask & e_OperationTimeoutInterval )
  2471. {
  2472. VARIANT t_Variant ;
  2473. VariantInit ( & t_Variant ) ;
  2474. LONG t_VarType = 0 ;
  2475. LONG t_Flavour = 0 ;
  2476. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_OperationTimeoutInterval , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2477. if ( SUCCEEDED ( t_TempResult ) )
  2478. {
  2479. if ( t_Variant.vt == VT_BSTR )
  2480. {
  2481. if ( m_OperationTimeout )
  2482. {
  2483. SysFreeString ( m_OperationTimeout ) ;
  2484. }
  2485. m_OperationTimeout = SysAllocString ( t_Variant.bstrVal ) ;
  2486. if ( m_OperationTimeout )
  2487. {
  2488. CWbemDateTime t_Interval ;
  2489. t_Result = t_Interval.PutValue ( m_OperationTimeout ) ;
  2490. if ( SUCCEEDED ( t_Result ) )
  2491. {
  2492. VARIANT_BOOL t_Bool = VARIANT_FALSE ;
  2493. t_Result = t_Interval.GetIsInterval ( & t_Bool ) ;
  2494. if ( t_Bool == VARIANT_TRUE )
  2495. {
  2496. LONG t_MicroSeconds = 0 ;
  2497. LONG t_Seconds = 0 ;
  2498. LONG t_Minutes = 0 ;
  2499. LONG t_Hours = 0 ;
  2500. LONG t_Days = 0 ;
  2501. t_Interval.GetMicroseconds ( & t_MicroSeconds ) ;
  2502. t_Interval.GetSeconds ( & t_Seconds ) ;
  2503. t_Interval.GetMinutes ( & t_Minutes ) ;
  2504. t_Interval.GetHours ( & t_Hours ) ;
  2505. t_Interval.GetDay ( & t_Days ) ;
  2506. m_OperationTimeoutMilliSeconds = ( t_Days * 24 * 60 * 60 * 1000 ) +
  2507. ( t_Hours * 60 * 60 * 1000 ) +
  2508. ( t_Minutes * 60 * 1000 ) +
  2509. ( t_Seconds * 1000 ) +
  2510. ( t_MicroSeconds / 1000 ) ;
  2511. }
  2512. else
  2513. {
  2514. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2515. }
  2516. }
  2517. else
  2518. {
  2519. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2520. }
  2521. }
  2522. else
  2523. {
  2524. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2525. }
  2526. }
  2527. else if ( t_Variant.vt == VT_NULL )
  2528. {
  2529. if ( m_OperationTimeout )
  2530. {
  2531. SysFreeString ( m_OperationTimeout ) ;
  2532. m_UnloadTimeout = NULL ;
  2533. }
  2534. }
  2535. else
  2536. {
  2537. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2538. }
  2539. }
  2540. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2541. {
  2542. t_Result = t_TempResult;
  2543. }
  2544. VariantClear ( & t_Variant ) ;
  2545. }
  2546. }
  2547. if ( SUCCEEDED ( t_Result ) )
  2548. {
  2549. if ( a_Mask & e_InitializationTimeoutInterval )
  2550. {
  2551. VARIANT t_Variant ;
  2552. VariantInit ( & t_Variant ) ;
  2553. LONG t_VarType = 0 ;
  2554. LONG t_Flavour = 0 ;
  2555. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_InitializationTimeoutInterval , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2556. if ( SUCCEEDED ( t_TempResult ) )
  2557. {
  2558. if ( t_Variant.vt == VT_BSTR )
  2559. {
  2560. if ( m_InitializationTimeout )
  2561. {
  2562. SysFreeString ( m_InitializationTimeout ) ;
  2563. }
  2564. m_InitializationTimeout = SysAllocString ( t_Variant.bstrVal ) ;
  2565. if ( m_InitializationTimeout )
  2566. {
  2567. CWbemDateTime t_Interval ;
  2568. t_Result = t_Interval.PutValue ( m_InitializationTimeout ) ;
  2569. if ( SUCCEEDED ( t_Result ) )
  2570. {
  2571. VARIANT_BOOL t_Bool = VARIANT_FALSE ;
  2572. t_Result = t_Interval.GetIsInterval ( & t_Bool ) ;
  2573. if ( t_Bool == VARIANT_TRUE )
  2574. {
  2575. LONG t_MicroSeconds = 0 ;
  2576. LONG t_Seconds = 0 ;
  2577. LONG t_Minutes = 0 ;
  2578. LONG t_Hours = 0 ;
  2579. LONG t_Days = 0 ;
  2580. t_Interval.GetMicroseconds ( & t_MicroSeconds ) ;
  2581. t_Interval.GetSeconds ( & t_Seconds ) ;
  2582. t_Interval.GetMinutes ( & t_Minutes ) ;
  2583. t_Interval.GetHours ( & t_Hours ) ;
  2584. t_Interval.GetDay ( & t_Days ) ;
  2585. m_InitializationTimeoutMilliSeconds = ( t_Days * 24 * 60 * 60 * 1000 ) +
  2586. ( t_Hours * 60 * 60 * 1000 ) +
  2587. ( t_Minutes * 60 * 1000 ) +
  2588. ( t_Seconds * 1000 ) +
  2589. ( t_MicroSeconds / 1000 ) ;
  2590. }
  2591. else
  2592. {
  2593. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2594. }
  2595. }
  2596. else
  2597. {
  2598. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2599. }
  2600. }
  2601. else
  2602. {
  2603. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2604. }
  2605. }
  2606. else if ( t_Variant.vt == VT_NULL )
  2607. {
  2608. if ( m_InitializationTimeout )
  2609. {
  2610. SysFreeString ( m_InitializationTimeout ) ;
  2611. m_UnloadTimeout = NULL ;
  2612. }
  2613. }
  2614. else
  2615. {
  2616. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2617. }
  2618. }
  2619. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2620. {
  2621. t_Result = t_TempResult;
  2622. }
  2623. VariantClear ( & t_Variant ) ;
  2624. }
  2625. }
  2626. if ( SUCCEEDED ( t_Result ) )
  2627. {
  2628. if ( a_Mask & e_SupportsThrottling )
  2629. {
  2630. VARIANT t_Variant ;
  2631. VariantInit ( & t_Variant ) ;
  2632. LONG t_VarType = 0 ;
  2633. LONG t_Flavour = 0 ;
  2634. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_SupportsThrottling , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2635. if ( SUCCEEDED ( t_TempResult ) )
  2636. {
  2637. if ( t_Variant.vt == VT_BOOL )
  2638. {
  2639. m_SupportsThrottling = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2640. }
  2641. else if ( t_Variant.vt == VT_NULL )
  2642. {
  2643. m_SupportsThrottling = FALSE ;
  2644. }
  2645. else
  2646. {
  2647. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2648. }
  2649. }
  2650. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2651. {
  2652. t_Result = t_TempResult;
  2653. }
  2654. VariantClear ( & t_Variant ) ;
  2655. }
  2656. }
  2657. if ( SUCCEEDED ( t_Result ) )
  2658. {
  2659. if ( a_Mask & e_ConcurrentIndependantRequests )
  2660. {
  2661. VARIANT t_Variant ;
  2662. VariantInit ( & t_Variant ) ;
  2663. LONG t_VarType = 0 ;
  2664. LONG t_Flavour = 0 ;
  2665. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_ConcurrentIndependantRequests , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2666. if ( SUCCEEDED ( t_TempResult ) )
  2667. {
  2668. if ( t_Variant.vt == VT_I4 )
  2669. {
  2670. m_ConcurrentIndependantRequests = t_Variant.lVal ;
  2671. }
  2672. else if ( t_Variant.vt == VT_NULL )
  2673. {
  2674. m_ConcurrentIndependantRequests = 0 ;
  2675. }
  2676. else
  2677. {
  2678. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2679. }
  2680. }
  2681. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2682. {
  2683. t_Result = t_TempResult;
  2684. }
  2685. VariantClear ( & t_Variant ) ;
  2686. }
  2687. }
  2688. if ( SUCCEEDED ( t_Result ) )
  2689. {
  2690. if ( a_Mask & e_InitializationReentrancy )
  2691. {
  2692. VARIANT t_Variant ;
  2693. VariantInit ( & t_Variant ) ;
  2694. LONG t_VarType = 0 ;
  2695. LONG t_Flavour = 0 ;
  2696. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_InitializationReentrancy , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2697. if ( SUCCEEDED ( t_TempResult ) )
  2698. {
  2699. if ( t_Variant.vt == VT_I4 )
  2700. {
  2701. switch ( t_Variant.lVal )
  2702. {
  2703. case 0:
  2704. {
  2705. m_InitializationReentrancy = e_InitializationReentrancy_Clsid ;
  2706. }
  2707. break ;
  2708. case 1:
  2709. {
  2710. m_InitializationReentrancy = e_InitializationReentrancy_Namespace ;
  2711. }
  2712. break ;
  2713. case 2:
  2714. {
  2715. m_InitializationReentrancy = e_InitializationReentrancy_None ;
  2716. }
  2717. break ;
  2718. default:
  2719. {
  2720. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2721. }
  2722. break ;
  2723. }
  2724. }
  2725. else if ( t_Variant.vt == VT_NULL )
  2726. {
  2727. m_InitializationReentrancy = e_InitializationReentrancy_Namespace;
  2728. }
  2729. else
  2730. {
  2731. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2732. }
  2733. }
  2734. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2735. {
  2736. t_Result = t_TempResult;
  2737. }
  2738. VariantClear ( & t_Variant ) ;
  2739. }
  2740. }
  2741. if ( SUCCEEDED ( t_Result ) )
  2742. {
  2743. if ( a_Mask & e_InitializeAsAdminFirst )
  2744. {
  2745. VARIANT t_Variant ;
  2746. VariantInit ( & t_Variant ) ;
  2747. LONG t_VarType = 0 ;
  2748. LONG t_Flavour = 0 ;
  2749. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_InitializeAsAdminFirst , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2750. if ( SUCCEEDED ( t_TempResult ) )
  2751. {
  2752. if ( t_Variant.vt == VT_BOOL )
  2753. {
  2754. m_InitializeAsAdminFirst = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2755. }
  2756. else if ( t_Variant.vt == VT_NULL )
  2757. {
  2758. m_InitializeAsAdminFirst = FALSE ;
  2759. }
  2760. else
  2761. {
  2762. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2763. }
  2764. }
  2765. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2766. {
  2767. t_Result = t_TempResult;
  2768. }
  2769. VariantClear ( & t_Variant ) ;
  2770. }
  2771. }
  2772. if ( SUCCEEDED ( t_Result ) )
  2773. {
  2774. if ( a_Mask & e_PerUserInitialization )
  2775. {
  2776. VARIANT t_Variant ;
  2777. VariantInit ( & t_Variant ) ;
  2778. LONG t_VarType = 0 ;
  2779. LONG t_Flavour = 0 ;
  2780. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_PerUserInitialization , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2781. if ( SUCCEEDED ( t_TempResult ) )
  2782. {
  2783. if ( t_Variant.vt == VT_BOOL )
  2784. {
  2785. m_PerUserInitialization = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2786. }
  2787. else if ( t_Variant.vt == VT_NULL )
  2788. {
  2789. m_PerUserInitialization = FALSE ;
  2790. }
  2791. else
  2792. {
  2793. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2794. }
  2795. }
  2796. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2797. {
  2798. t_Result = t_TempResult;
  2799. }
  2800. VariantClear ( & t_Variant ) ;
  2801. }
  2802. }
  2803. if ( SUCCEEDED ( t_Result ) )
  2804. {
  2805. if ( a_Mask & e_PerLocaleInitialization )
  2806. {
  2807. VARIANT t_Variant ;
  2808. VariantInit ( & t_Variant ) ;
  2809. LONG t_VarType = 0 ;
  2810. LONG t_Flavour = 0 ;
  2811. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_PerLocaleInitialization , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2812. if ( SUCCEEDED ( t_TempResult ) )
  2813. {
  2814. if ( t_Variant.vt == VT_BOOL )
  2815. {
  2816. m_PerLocaleInitialization = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2817. }
  2818. else if ( t_Variant.vt == VT_NULL )
  2819. {
  2820. m_PerLocaleInitialization = FALSE ;
  2821. }
  2822. else
  2823. {
  2824. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2825. }
  2826. }
  2827. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2828. {
  2829. t_Result = t_TempResult;
  2830. }
  2831. VariantClear ( & t_Variant ) ;
  2832. }
  2833. }
  2834. if ( SUCCEEDED ( t_Result ) )
  2835. {
  2836. if ( a_Mask & e_Pure )
  2837. {
  2838. VARIANT t_Variant ;
  2839. VariantInit ( & t_Variant ) ;
  2840. LONG t_VarType = 0 ;
  2841. LONG t_Flavour = 0 ;
  2842. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_Pure , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2843. if ( SUCCEEDED ( t_TempResult ) )
  2844. {
  2845. if ( t_Variant.vt == VT_BOOL )
  2846. {
  2847. m_Pure = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  2848. }
  2849. else if ( t_Variant.vt == VT_NULL )
  2850. {
  2851. m_Pure = TRUE ;
  2852. }
  2853. else
  2854. {
  2855. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2856. }
  2857. }
  2858. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2859. {
  2860. t_Result = t_TempResult;
  2861. }
  2862. VariantClear ( & t_Variant ) ;
  2863. }
  2864. }
  2865. if ( SUCCEEDED ( t_Result ) )
  2866. {
  2867. if ( a_Mask & e_Hosting )
  2868. {
  2869. VARIANT t_Variant ;
  2870. VariantInit ( & t_Variant ) ;
  2871. LONG t_VarType = 0 ;
  2872. LONG t_Flavour = 0 ;
  2873. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_Hosting , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2874. if ( SUCCEEDED ( t_TempResult ) )
  2875. {
  2876. if ( t_Variant.vt == VT_BSTR )
  2877. {
  2878. t_Result = GetHosting ( t_Variant.bstrVal , m_Hosting , m_HostingGroup , m_DecoupledImpersonationRestriction ) ;
  2879. if ( SUCCEEDED ( t_Result ) )
  2880. {
  2881. #ifdef UNIQUE_HOST
  2882. if ( m_HostingGroup )
  2883. {
  2884. SysFreeString ( m_HostingGroup ) ;
  2885. }
  2886. m_HostingGroup = SysAllocString ( GetProviderName () ) ;
  2887. if ( m_HostingGroup == NULL )
  2888. {
  2889. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2890. }
  2891. #else
  2892. #endif
  2893. }
  2894. else
  2895. {
  2896. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2897. }
  2898. }
  2899. else if ( t_Variant.vt == VT_NULL )
  2900. {
  2901. m_Hosting = e_Hosting_SharedLocalSystemHostOrSelfHost ;
  2902. #ifdef UNIQUE_HOST
  2903. m_HostingGroup = SysAllocString ( GetProviderName () ) ;
  2904. #else
  2905. m_HostingGroup = SysAllocString ( s_Strings_Wmi_DefaultSharedLocalSystemHostOrSelfHost ) ;
  2906. #endif
  2907. if ( m_HostingGroup == NULL )
  2908. {
  2909. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2910. }
  2911. }
  2912. else
  2913. {
  2914. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2915. }
  2916. }
  2917. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2918. {
  2919. t_Result = t_TempResult;
  2920. }
  2921. VariantClear ( & t_Variant ) ;
  2922. }
  2923. }
  2924. if ( SUCCEEDED ( t_Result ) )
  2925. {
  2926. switch ( GetHosting () )
  2927. {
  2928. case e_Hosting_NonCom:
  2929. case e_Hosting_Decoupled:
  2930. {
  2931. }
  2932. break ;
  2933. default:
  2934. {
  2935. if ( GetClsidServer ().GetProviderClsid () == NULL )
  2936. {
  2937. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2938. }
  2939. }
  2940. break ;
  2941. }
  2942. }
  2943. if ( SUCCEEDED ( t_Result ) )
  2944. {
  2945. if ( a_Mask & e_SecurityDescriptor )
  2946. {
  2947. VARIANT t_Variant ;
  2948. VariantInit ( & t_Variant ) ;
  2949. LONG t_VarType = 0 ;
  2950. LONG t_Flavour = 0 ;
  2951. HRESULT t_TempResult = a_Object->Get ( s_Strings_Wmi_SecurityDescriptor , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  2952. if ( SUCCEEDED ( t_TempResult ) )
  2953. {
  2954. if ( t_Variant.vt == VT_BSTR )
  2955. {
  2956. BOOL t_Status = SDDL::ConvertStringSecurityDescriptorToSecurityDescriptor (
  2957. t_Variant.bstrVal ,
  2958. SDDL_REVISION_1 ,
  2959. ( PSECURITY_DESCRIPTOR * ) & m_SecurityDescriptor,
  2960. NULL
  2961. ) ;
  2962. if ( t_Status )
  2963. {
  2964. }
  2965. else
  2966. {
  2967. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2968. }
  2969. }
  2970. else if ( t_Variant.vt == VT_NULL )
  2971. {
  2972. m_SecurityDescriptor = NULL ;
  2973. }
  2974. else
  2975. {
  2976. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  2977. }
  2978. }
  2979. else if (t_TempResult != WBEM_E_NOT_FOUND)
  2980. {
  2981. t_Result = t_TempResult;
  2982. }
  2983. VariantClear ( & t_Variant ) ;
  2984. }
  2985. }
  2986. return t_Result ;
  2987. }
  2988. /******************************************************************************
  2989. *
  2990. * Name:
  2991. *
  2992. *
  2993. * Description:
  2994. *
  2995. *
  2996. *****************************************************************************/
  2997. HRESULT CServerObject_ComProviderRegistrationV1 :: QueryRepository (
  2998. Enum_PropertyMask a_Mask ,
  2999. IWbemPath *a_Scope,
  3000. LPCWSTR a_ProviderName
  3001. )
  3002. {
  3003. BSTR t_ObjectPath = NULL ;
  3004. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  3005. 3 ,
  3006. & t_ObjectPath ,
  3007. L"__Win32Provider.Name=\"" ,
  3008. a_ProviderName ,
  3009. L"\""
  3010. ) ;
  3011. if ( SUCCEEDED ( t_Result ) )
  3012. {
  3013. if ( m_Identity )
  3014. {
  3015. m_Identity->Release () ;
  3016. }
  3017. t_Result = m_Repository->GetObject (
  3018. t_ObjectPath ,
  3019. 0 ,
  3020. m_Context ,
  3021. & m_Identity ,
  3022. NULL
  3023. ) ;
  3024. if ( SUCCEEDED ( t_Result ) )
  3025. {
  3026. t_Result = QueryProperties (
  3027. a_Mask ,
  3028. m_Identity ,
  3029. a_ProviderName
  3030. ) ;
  3031. }
  3032. SysFreeString ( t_ObjectPath ) ;
  3033. }
  3034. return t_Result ;
  3035. }
  3036. /******************************************************************************
  3037. *
  3038. * Name:
  3039. *
  3040. *
  3041. * Description:
  3042. *
  3043. *
  3044. *****************************************************************************/
  3045. HRESULT CServerObject_ComProviderRegistrationV1 :: QueryRepository (
  3046. Enum_PropertyMask a_Mask ,
  3047. IWbemPath *a_Scope,
  3048. IWbemPath *a_Provider
  3049. )
  3050. {
  3051. BSTR t_ObjectPath = NULL ;
  3052. ULONG t_ObjectPathLength = 0 ;
  3053. HRESULT t_Result = a_Provider->GetText (
  3054. WBEMPATH_GET_RELATIVE_ONLY ,
  3055. & t_ObjectPathLength ,
  3056. NULL
  3057. ) ;
  3058. if ( SUCCEEDED ( t_Result ) )
  3059. {
  3060. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  3061. if ( t_ObjectPath )
  3062. {
  3063. t_Result = a_Provider->GetText (
  3064. WBEMPATH_GET_RELATIVE_ONLY ,
  3065. & t_ObjectPathLength ,
  3066. t_ObjectPath
  3067. ) ;
  3068. if ( SUCCEEDED ( t_Result ) )
  3069. {
  3070. if ( m_Identity )
  3071. {
  3072. m_Identity->Release () ;
  3073. }
  3074. t_Result = m_Repository->GetObject (
  3075. t_ObjectPath ,
  3076. 0 ,
  3077. m_Context ,
  3078. & m_Identity ,
  3079. NULL
  3080. ) ;
  3081. if ( SUCCEEDED ( t_Result ) )
  3082. {
  3083. VARIANT t_Variant ;
  3084. VariantInit ( & t_Variant ) ;
  3085. LONG t_VarType = 0 ;
  3086. LONG t_Flavour = 0 ;
  3087. t_Result = m_Identity->Get ( L"Name" , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3088. if ( SUCCEEDED ( t_Result ) )
  3089. {
  3090. if ( t_Variant.vt == VT_BSTR )
  3091. {
  3092. t_Result = QueryProperties (
  3093. a_Mask ,
  3094. m_Identity ,
  3095. t_Variant.bstrVal
  3096. ) ;
  3097. }
  3098. VariantClear ( & t_Variant ) ;
  3099. }
  3100. }
  3101. }
  3102. SysFreeString ( t_ObjectPath ) ;
  3103. }
  3104. else
  3105. {
  3106. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3107. }
  3108. }
  3109. return t_Result ;
  3110. }
  3111. /******************************************************************************
  3112. *
  3113. * Name:
  3114. *
  3115. *
  3116. * Description:
  3117. *
  3118. *
  3119. *****************************************************************************/
  3120. HRESULT CServerObject_ComProviderRegistrationV1 :: Load (
  3121. Enum_PropertyMask a_Mask ,
  3122. IWbemPath *a_Scope,
  3123. IWbemClassObject *a_Class
  3124. )
  3125. {
  3126. HRESULT t_Result = S_OK ;
  3127. IWbemQualifierSet *t_QualifierObject = NULL ;
  3128. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  3129. if ( SUCCEEDED ( t_Result ) )
  3130. {
  3131. VARIANT t_Variant ;
  3132. VariantInit ( & t_Variant ) ;
  3133. LONG t_Flavour = 0 ;
  3134. t_Result = t_QualifierObject->Get (
  3135. ProviderSubSystem_Common_Globals :: s_Provider ,
  3136. 0 ,
  3137. & t_Variant ,
  3138. & t_Flavour
  3139. ) ;
  3140. if ( SUCCEEDED ( t_Result ) )
  3141. {
  3142. if ( t_Variant.vt == VT_BSTR )
  3143. {
  3144. t_Result = QueryRepository (
  3145. a_Mask ,
  3146. a_Scope ,
  3147. t_Variant.bstrVal
  3148. ) ;
  3149. if ( SUCCEEDED ( t_Result ) )
  3150. {
  3151. }
  3152. }
  3153. }
  3154. VariantClear ( & t_Variant ) ;
  3155. t_QualifierObject->Release () ;
  3156. }
  3157. return t_Result ;
  3158. }
  3159. /******************************************************************************
  3160. *
  3161. * Name:
  3162. *
  3163. *
  3164. * Description:
  3165. *
  3166. *
  3167. *****************************************************************************/
  3168. HRESULT CServerObject_ComProviderRegistrationV1 :: Load (
  3169. Enum_PropertyMask a_Mask ,
  3170. IWbemPath *a_Scope,
  3171. LPCWSTR a_Provider
  3172. )
  3173. {
  3174. HRESULT t_Result = S_OK ;
  3175. t_Result = QueryRepository (
  3176. a_Mask ,
  3177. a_Scope ,
  3178. a_Provider
  3179. ) ;
  3180. return t_Result ;
  3181. }
  3182. /******************************************************************************
  3183. *
  3184. * Name:
  3185. *
  3186. *
  3187. * Description:
  3188. *
  3189. *
  3190. *****************************************************************************/
  3191. HRESULT CServerObject_ComProviderRegistrationV1 :: Load (
  3192. Enum_PropertyMask a_Mask ,
  3193. IWbemPath *a_Scope,
  3194. IWbemPath *a_Provider
  3195. )
  3196. {
  3197. HRESULT t_Result = S_OK ;
  3198. t_Result = QueryRepository (
  3199. a_Mask ,
  3200. a_Scope ,
  3201. a_Provider
  3202. ) ;
  3203. return t_Result ;
  3204. }
  3205. /******************************************************************************
  3206. *
  3207. * Name:
  3208. *
  3209. *
  3210. * Description:
  3211. *
  3212. *
  3213. *****************************************************************************/
  3214. CServerObject_InstanceProviderRegistrationV1 :: CServerObject_InstanceProviderRegistrationV1 () :
  3215. m_Context ( NULL ) ,
  3216. m_Namespace ( NULL ) ,
  3217. m_Repository ( NULL ) ,
  3218. m_SupportsPut ( FALSE ) ,
  3219. m_SupportsGet ( FALSE ) ,
  3220. m_SupportsDelete ( FALSE ) ,
  3221. m_SupportsEnumeration ( FALSE ) ,
  3222. m_SupportsBatching ( FALSE ) ,
  3223. m_SupportsTransactions ( FALSE ) ,
  3224. m_Supported ( FALSE ) ,
  3225. m_QuerySupportLevels ( e_QuerySupportLevels_Unknown ) ,
  3226. m_InteractionType ( e_InteractionType_Unknown ) ,
  3227. m_Result ( S_OK )
  3228. {
  3229. }
  3230. /******************************************************************************
  3231. *
  3232. * Name:
  3233. *
  3234. *
  3235. * Description:
  3236. *
  3237. *
  3238. *****************************************************************************/
  3239. CServerObject_InstanceProviderRegistrationV1::~CServerObject_InstanceProviderRegistrationV1 ()
  3240. {
  3241. if ( m_Context )
  3242. {
  3243. m_Context->Release () ;
  3244. }
  3245. if ( m_Namespace )
  3246. {
  3247. m_Namespace->Release () ;
  3248. }
  3249. if ( m_Repository )
  3250. {
  3251. m_Repository->Release () ;
  3252. }
  3253. }
  3254. /******************************************************************************
  3255. *
  3256. * Name:
  3257. *
  3258. *
  3259. * Description:
  3260. *
  3261. *
  3262. *****************************************************************************/
  3263. ULONG CServerObject_InstanceProviderRegistrationV1 :: AddRef ()
  3264. {
  3265. return InterlockedIncrement ( & m_ReferenceCount ) ;
  3266. }
  3267. /******************************************************************************
  3268. *
  3269. * Name:
  3270. *
  3271. *
  3272. * Description:
  3273. *
  3274. *
  3275. *****************************************************************************/
  3276. ULONG CServerObject_InstanceProviderRegistrationV1 :: Release ()
  3277. {
  3278. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  3279. if ( t_ReferenceCount == 0 )
  3280. {
  3281. delete this ;
  3282. }
  3283. return t_ReferenceCount ;
  3284. }
  3285. /******************************************************************************
  3286. *
  3287. * Name:
  3288. *
  3289. *
  3290. * Description:
  3291. *
  3292. *
  3293. *****************************************************************************/
  3294. HRESULT CServerObject_InstanceProviderRegistrationV1 :: SetContext (
  3295. IWbemContext *a_Context ,
  3296. IWbemPath *a_Namespace ,
  3297. IWbemServices *a_Repository
  3298. )
  3299. {
  3300. HRESULT t_Result = S_OK ;
  3301. m_Context = a_Context ;
  3302. m_Namespace = a_Namespace ;
  3303. m_Repository = a_Repository ;
  3304. if ( m_Context )
  3305. {
  3306. m_Context->AddRef () ;
  3307. }
  3308. if ( m_Namespace )
  3309. {
  3310. m_Namespace->AddRef () ;
  3311. }
  3312. if ( m_Repository )
  3313. {
  3314. m_Repository->AddRef () ;
  3315. }
  3316. return t_Result ;
  3317. }
  3318. /******************************************************************************
  3319. *
  3320. * Name:
  3321. *
  3322. *
  3323. * Description:
  3324. *
  3325. *
  3326. *****************************************************************************/
  3327. HRESULT CServerObject_InstanceProviderRegistrationV1 :: QueryProperties (
  3328. Enum_PropertyMask a_Mask ,
  3329. IWbemClassObject *a_Object
  3330. )
  3331. {
  3332. HRESULT t_Result = S_OK ;
  3333. m_Supported = TRUE ;
  3334. if ( a_Mask & e_SupportsPut )
  3335. {
  3336. VARIANT t_Variant ;
  3337. VariantInit ( & t_Variant ) ;
  3338. LONG t_VarType = 0 ;
  3339. LONG t_Flavour = 0 ;
  3340. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsPut , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3341. if ( SUCCEEDED ( t_TempResult ) )
  3342. {
  3343. if ( t_Variant.vt == VT_BOOL )
  3344. {
  3345. m_SupportsPut = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  3346. }
  3347. else if ( t_Variant.vt == VT_NULL )
  3348. {
  3349. m_SupportsPut = FALSE ;
  3350. }
  3351. else
  3352. {
  3353. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3354. }
  3355. }
  3356. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3357. {
  3358. t_Result = t_TempResult;
  3359. }
  3360. VariantClear ( & t_Variant ) ;
  3361. }
  3362. if ( SUCCEEDED(t_Result) && (a_Mask & e_SupportsGet) )
  3363. {
  3364. VARIANT t_Variant ;
  3365. VariantInit ( & t_Variant ) ;
  3366. LONG t_VarType = 0 ;
  3367. LONG t_Flavour = 0 ;
  3368. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsGet , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3369. if ( SUCCEEDED ( t_TempResult ) )
  3370. {
  3371. if ( t_Variant.vt == VT_BOOL )
  3372. {
  3373. m_SupportsGet = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  3374. }
  3375. else if ( t_Variant.vt == VT_NULL )
  3376. {
  3377. m_SupportsGet = FALSE ;
  3378. }
  3379. else
  3380. {
  3381. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3382. }
  3383. }
  3384. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3385. {
  3386. t_Result = t_TempResult;
  3387. }
  3388. VariantClear ( & t_Variant ) ;
  3389. }
  3390. if ( SUCCEEDED(t_Result) && (a_Mask & e_SupportsDelete) )
  3391. {
  3392. VARIANT t_Variant ;
  3393. VariantInit ( & t_Variant ) ;
  3394. LONG t_VarType = 0 ;
  3395. LONG t_Flavour = 0 ;
  3396. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsDelete , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3397. if ( SUCCEEDED ( t_TempResult ) )
  3398. {
  3399. if ( t_Variant.vt == VT_BOOL )
  3400. {
  3401. m_SupportsDelete = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  3402. }
  3403. else if ( t_Variant.vt == VT_NULL )
  3404. {
  3405. m_SupportsDelete = FALSE ;
  3406. }
  3407. else
  3408. {
  3409. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3410. }
  3411. }
  3412. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3413. {
  3414. t_Result = t_TempResult;
  3415. }
  3416. VariantClear ( & t_Variant ) ;
  3417. }
  3418. if ( SUCCEEDED(t_Result) && (a_Mask & e_SupportsEnumeration) )
  3419. {
  3420. VARIANT t_Variant ;
  3421. VariantInit ( & t_Variant ) ;
  3422. LONG t_VarType = 0 ;
  3423. LONG t_Flavour = 0 ;
  3424. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsEnumeration , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3425. if ( SUCCEEDED ( t_TempResult ) )
  3426. {
  3427. if ( t_Variant.vt == VT_BOOL )
  3428. {
  3429. m_SupportsEnumeration = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  3430. }
  3431. else if ( t_Variant.vt == VT_NULL )
  3432. {
  3433. m_SupportsEnumeration = FALSE ;
  3434. }
  3435. else
  3436. {
  3437. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3438. }
  3439. }
  3440. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3441. {
  3442. t_Result = t_TempResult;
  3443. }
  3444. VariantClear ( & t_Variant ) ;
  3445. }
  3446. if ( SUCCEEDED(t_Result) && (a_Mask & e_SupportsBatching) )
  3447. {
  3448. VARIANT t_Variant ;
  3449. VariantInit ( & t_Variant ) ;
  3450. LONG t_VarType = 0 ;
  3451. LONG t_Flavour = 0 ;
  3452. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsBatching , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3453. if ( SUCCEEDED ( t_TempResult ) )
  3454. {
  3455. if ( t_Variant.vt == VT_BOOL )
  3456. {
  3457. m_SupportsBatching = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  3458. }
  3459. else if ( t_Variant.vt == VT_NULL )
  3460. {
  3461. m_SupportsBatching = FALSE ;
  3462. }
  3463. else
  3464. {
  3465. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3466. }
  3467. }
  3468. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3469. {
  3470. t_Result = t_TempResult;
  3471. }
  3472. VariantClear ( & t_Variant ) ;
  3473. }
  3474. if ( SUCCEEDED(t_Result) && (a_Mask & e_SupportsTransactions) )
  3475. {
  3476. VARIANT t_Variant ;
  3477. VariantInit ( & t_Variant ) ;
  3478. LONG t_VarType = 0 ;
  3479. LONG t_Flavour = 0 ;
  3480. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsTransactions , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3481. if ( SUCCEEDED ( t_TempResult ) )
  3482. {
  3483. if ( t_Variant.vt == VT_BOOL )
  3484. {
  3485. m_SupportsTransactions = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  3486. }
  3487. else if ( t_Variant.vt == VT_NULL )
  3488. {
  3489. m_SupportsTransactions = FALSE ;
  3490. }
  3491. else
  3492. {
  3493. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3494. }
  3495. }
  3496. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3497. {
  3498. t_Result = t_TempResult;
  3499. }
  3500. VariantClear ( & t_Variant ) ;
  3501. }
  3502. if (SUCCEEDED(t_Result) && ( a_Mask & e_QuerySupportLevels ) )
  3503. {
  3504. VARIANT t_Variant ;
  3505. VariantInit ( & t_Variant ) ;
  3506. LONG t_VarType = 0 ;
  3507. LONG t_Flavour = 0 ;
  3508. HRESULT t_TempResult = a_Object->Get ( s_Strings_QuerySupportLevels , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3509. if ( SUCCEEDED ( t_TempResult ) )
  3510. {
  3511. if ( t_Variant.vt == ( VT_BSTR | VT_ARRAY ) )
  3512. {
  3513. if ( SafeArrayGetDim ( t_Variant.parray ) == 1 )
  3514. {
  3515. LONG t_Dimension = 1 ;
  3516. LONG t_Lower ;
  3517. SafeArrayGetLBound ( t_Variant.parray , t_Dimension , & t_Lower ) ;
  3518. LONG t_Upper ;
  3519. SafeArrayGetUBound ( t_Variant.parray , t_Dimension , & t_Upper ) ;
  3520. LONG t_Count = ( t_Upper - t_Lower ) + 1 ;
  3521. if ( t_Count )
  3522. {
  3523. for ( LONG t_ElementIndex = t_Lower ; t_ElementIndex <= t_Upper ; t_ElementIndex ++ )
  3524. {
  3525. BSTR t_Element ;
  3526. if ( SUCCEEDED ( SafeArrayGetElement ( t_Variant.parray , &t_ElementIndex , & t_Element ) ) )
  3527. {
  3528. if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_UnarySelect , t_Element ) == 0 )
  3529. {
  3530. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_UnarySelect ;
  3531. }
  3532. else if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_References , t_Element ) == 0 )
  3533. {
  3534. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_References ;
  3535. }
  3536. else if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_Associators , t_Element ) == 0 )
  3537. {
  3538. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_Associators ;
  3539. }
  3540. else if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_V1ProviderDefined , t_Element ) == 0 )
  3541. {
  3542. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_V1ProviderDefined ;
  3543. }
  3544. else
  3545. {
  3546. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3547. }
  3548. SysFreeString ( t_Element ) ;
  3549. }
  3550. }
  3551. }
  3552. else
  3553. {
  3554. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3555. }
  3556. }
  3557. }
  3558. else if ( t_Variant.vt == VT_NULL )
  3559. {
  3560. m_QuerySupportLevels = e_QuerySupportLevels_None ;
  3561. }
  3562. else
  3563. {
  3564. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3565. }
  3566. }
  3567. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3568. {
  3569. t_Result = t_TempResult;
  3570. }
  3571. VariantClear ( & t_Variant ) ;
  3572. }
  3573. if (SUCCEEDED(t_Result) && ( a_Mask & e_InteractionType) )
  3574. {
  3575. VARIANT t_Variant ;
  3576. VariantInit ( & t_Variant ) ;
  3577. LONG t_VarType = 0 ;
  3578. LONG t_Flavour = 0 ;
  3579. HRESULT t_TempResult = a_Object->Get ( s_Strings_InteractionType , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3580. if ( SUCCEEDED ( t_TempResult ) )
  3581. {
  3582. if ( t_Variant.vt == VT_I4 )
  3583. {
  3584. switch ( t_Variant.lVal )
  3585. {
  3586. case 0:
  3587. {
  3588. m_InteractionType = e_InteractionType_Pull ;
  3589. }
  3590. break ;
  3591. case 1:
  3592. {
  3593. m_InteractionType = e_InteractionType_Push ;
  3594. }
  3595. break ;
  3596. case 2:
  3597. {
  3598. m_InteractionType = e_InteractionType_PushVerify ;
  3599. }
  3600. break ;
  3601. default:
  3602. {
  3603. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3604. }
  3605. break ;
  3606. }
  3607. }
  3608. else if ( t_Variant.vt == VT_NULL )
  3609. {
  3610. m_InteractionType = e_InteractionType_Pull ;
  3611. }
  3612. else
  3613. {
  3614. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3615. }
  3616. }
  3617. else if (t_TempResult != WBEM_E_NOT_FOUND)
  3618. {
  3619. t_Result = t_TempResult;
  3620. }
  3621. VariantClear ( & t_Variant ) ;
  3622. }
  3623. return t_Result ;
  3624. }
  3625. /******************************************************************************
  3626. *
  3627. * Name:
  3628. *
  3629. *
  3630. * Description:
  3631. *
  3632. *
  3633. *****************************************************************************/
  3634. HRESULT CServerObject_InstanceProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  3635. Enum_PropertyMask a_Mask ,
  3636. IWbemPath *a_Scope,
  3637. BSTR a_Query
  3638. )
  3639. {
  3640. HRESULT t_Result = S_OK ;
  3641. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  3642. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  3643. if ( t_Language )
  3644. {
  3645. t_Result = m_Repository->ExecQuery (
  3646. t_Language ,
  3647. a_Query ,
  3648. WBEM_FLAG_FORWARD_ONLY ,
  3649. m_Context ,
  3650. & t_ClassObjectEnum
  3651. ) ;
  3652. if ( SUCCEEDED ( t_Result ) )
  3653. {
  3654. IWbemClassObject *t_ClassObject = NULL ;
  3655. ULONG t_ObjectCount = 0 ;
  3656. t_ClassObjectEnum->Reset () ;
  3657. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  3658. {
  3659. VARIANT t_Variant ;
  3660. VariantInit ( & t_Variant ) ;
  3661. LONG t_VarType = 0 ;
  3662. LONG t_Flavour = 0 ;
  3663. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  3664. if ( SUCCEEDED ( t_Result ) )
  3665. {
  3666. if ( t_Variant.vt == VT_BSTR )
  3667. {
  3668. if ( wbem_wcsicmp ( s_Strings_InstanceProviderRegistration , t_Variant.bstrVal ) == 0 )
  3669. {
  3670. t_Result = QueryProperties (
  3671. a_Mask ,
  3672. t_ClassObject
  3673. ) ;
  3674. }
  3675. }
  3676. }
  3677. VariantClear ( & t_Variant ) ;
  3678. t_ClassObject->Release () ;
  3679. }
  3680. t_ClassObjectEnum->Release () ;
  3681. }
  3682. else
  3683. {
  3684. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  3685. }
  3686. SysFreeString ( t_Language ) ;
  3687. }
  3688. else
  3689. {
  3690. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3691. }
  3692. return t_Result ;
  3693. }
  3694. /******************************************************************************
  3695. *
  3696. * Name:
  3697. *
  3698. *
  3699. * Description:
  3700. *
  3701. *
  3702. *****************************************************************************/
  3703. HRESULT CServerObject_InstanceProviderRegistrationV1 :: QueryRepository (
  3704. Enum_PropertyMask a_Mask ,
  3705. IWbemPath *a_Scope,
  3706. LPCWSTR a_ProviderName
  3707. )
  3708. {
  3709. BSTR t_Query = NULL ;
  3710. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  3711. 3 ,
  3712. & t_Query ,
  3713. L"references of {__Win32Provider.Name=\"" ,
  3714. a_ProviderName ,
  3715. L"\"}"
  3716. ) ;
  3717. if ( SUCCEEDED ( t_Result ) )
  3718. {
  3719. t_Result = QueryRepositoryUsingQuery (
  3720. a_Mask ,
  3721. a_Scope,
  3722. t_Query
  3723. ) ;
  3724. SysFreeString ( t_Query ) ;
  3725. }
  3726. return t_Result ;
  3727. }
  3728. /******************************************************************************
  3729. *
  3730. * Name:
  3731. *
  3732. *
  3733. * Description:
  3734. *
  3735. *
  3736. *****************************************************************************/
  3737. HRESULT CServerObject_InstanceProviderRegistrationV1 :: QueryRepository (
  3738. Enum_PropertyMask a_Mask ,
  3739. IWbemPath *a_Scope,
  3740. IWbemPath *a_Provider
  3741. )
  3742. {
  3743. BSTR t_ObjectPath = NULL ;
  3744. ULONG t_ObjectPathLength = 0 ;
  3745. HRESULT t_Result = a_Provider->GetText (
  3746. WBEMPATH_GET_RELATIVE_ONLY ,
  3747. & t_ObjectPathLength ,
  3748. NULL
  3749. ) ;
  3750. if ( SUCCEEDED ( t_Result ) )
  3751. {
  3752. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  3753. if ( t_ObjectPath )
  3754. {
  3755. t_Result = a_Provider->GetText (
  3756. WBEMPATH_GET_RELATIVE_ONLY ,
  3757. & t_ObjectPathLength ,
  3758. t_ObjectPath
  3759. ) ;
  3760. if ( SUCCEEDED ( t_Result ) )
  3761. {
  3762. BSTR t_Query = NULL ;
  3763. t_Result = WmiHelper :: ConcatenateStrings (
  3764. 3 ,
  3765. & t_Query ,
  3766. L"references of {" ,
  3767. t_ObjectPath ,
  3768. L"}"
  3769. ) ;
  3770. if ( SUCCEEDED ( t_Result ) )
  3771. {
  3772. t_Result = QueryRepositoryUsingQuery (
  3773. a_Mask ,
  3774. a_Scope,
  3775. t_Query
  3776. ) ;
  3777. SysFreeString ( t_Query ) ;
  3778. }
  3779. }
  3780. SysFreeString ( t_ObjectPath ) ;
  3781. }
  3782. else
  3783. {
  3784. t_Result = WBEM_E_OUT_OF_MEMORY;
  3785. }
  3786. }
  3787. return t_Result ;
  3788. }
  3789. /******************************************************************************
  3790. *
  3791. * Name:
  3792. *
  3793. *
  3794. * Description:
  3795. *
  3796. *
  3797. *****************************************************************************/
  3798. HRESULT CServerObject_InstanceProviderRegistrationV1 :: Load (
  3799. Enum_PropertyMask a_Mask ,
  3800. IWbemPath *a_Scope,
  3801. IWbemClassObject *a_Class
  3802. )
  3803. {
  3804. HRESULT t_Result = S_OK ;
  3805. IWbemQualifierSet *t_QualifierObject = NULL ;
  3806. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  3807. if ( SUCCEEDED ( t_Result ) )
  3808. {
  3809. VARIANT t_Variant ;
  3810. VariantInit ( & t_Variant ) ;
  3811. LONG t_Flavour = 0 ;
  3812. t_Result = t_QualifierObject->Get (
  3813. ProviderSubSystem_Common_Globals :: s_Provider ,
  3814. 0 ,
  3815. & t_Variant ,
  3816. & t_Flavour
  3817. ) ;
  3818. if ( SUCCEEDED ( t_Result ) )
  3819. {
  3820. if ( t_Variant.vt == VT_BSTR )
  3821. {
  3822. t_Result = QueryRepository (
  3823. a_Mask ,
  3824. a_Scope ,
  3825. t_Variant.bstrVal
  3826. ) ;
  3827. VariantClear ( & t_Variant ) ;
  3828. }
  3829. }
  3830. t_QualifierObject->Release () ;
  3831. }
  3832. return t_Result ;
  3833. }
  3834. /******************************************************************************
  3835. *
  3836. * Name:
  3837. *
  3838. *
  3839. * Description:
  3840. *
  3841. *
  3842. *****************************************************************************/
  3843. HRESULT CServerObject_InstanceProviderRegistrationV1 :: Load (
  3844. Enum_PropertyMask a_Mask ,
  3845. IWbemPath *a_Scope,
  3846. LPCWSTR a_Provider
  3847. )
  3848. {
  3849. HRESULT t_Result = S_OK ;
  3850. t_Result = QueryRepository (
  3851. a_Mask ,
  3852. a_Scope ,
  3853. a_Provider
  3854. ) ;
  3855. return t_Result ;
  3856. }
  3857. /******************************************************************************
  3858. *
  3859. * Name:
  3860. *
  3861. *
  3862. * Description:
  3863. *
  3864. *
  3865. *****************************************************************************/
  3866. HRESULT CServerObject_InstanceProviderRegistrationV1 :: Load (
  3867. Enum_PropertyMask a_Mask ,
  3868. IWbemPath *a_Scope,
  3869. IWbemPath *a_Provider
  3870. )
  3871. {
  3872. HRESULT t_Result = S_OK ;
  3873. t_Result = QueryRepository (
  3874. a_Mask ,
  3875. a_Scope ,
  3876. a_Provider
  3877. ) ;
  3878. return t_Result ;
  3879. }
  3880. /******************************************************************************
  3881. *
  3882. * Name:
  3883. *
  3884. *
  3885. * Description:
  3886. *
  3887. *
  3888. *****************************************************************************/
  3889. CServerObject_ClassProviderRegistrationV1 :: CServerObject_ClassProviderRegistrationV1 () :
  3890. m_Context ( NULL ) ,
  3891. m_Namespace ( NULL ) ,
  3892. m_Repository ( NULL ) ,
  3893. m_SupportsPut ( FALSE ) ,
  3894. m_SupportsGet ( FALSE ) ,
  3895. m_SupportsDelete ( FALSE ) ,
  3896. m_SupportsEnumeration ( FALSE ) ,
  3897. m_SupportsBatching ( FALSE ) ,
  3898. m_SupportsTransactions ( FALSE ) ,
  3899. m_Supported ( FALSE ) ,
  3900. m_ReSynchroniseOnNamespaceOpen ( FALSE ) ,
  3901. m_PerUserSchema ( FALSE ) ,
  3902. m_HasReferencedSet( FALSE ),
  3903. m_CacheRefreshInterval ( NULL ) ,
  3904. m_CacheRefreshIntervalMilliSeconds ( 0 ) ,
  3905. m_QuerySupportLevels ( e_QuerySupportLevels_Unknown ) ,
  3906. m_InteractionType ( e_InteractionType_Unknown ) ,
  3907. m_ResultSetQueryTreeCount ( 0 ) ,
  3908. m_UnSupportedQueryTreeCount ( 0 ) ,
  3909. m_ReferencedSetQueryTreeCount ( 0 ) ,
  3910. m_ResultSetQueryTree ( NULL ) ,
  3911. m_UnSupportedQueryTree ( NULL ) ,
  3912. m_ReferencedSetQueryTree ( NULL ) ,
  3913. m_ProviderName ( NULL ) ,
  3914. m_Version ( 1 ) ,
  3915. m_Result ( S_OK )
  3916. {
  3917. }
  3918. /******************************************************************************
  3919. *
  3920. * Name:
  3921. *
  3922. *
  3923. * Description:
  3924. *
  3925. *
  3926. *****************************************************************************/
  3927. CServerObject_ClassProviderRegistrationV1::~CServerObject_ClassProviderRegistrationV1 ()
  3928. {
  3929. if ( m_ResultSetQueryTree )
  3930. {
  3931. for ( ULONG t_Index = 0 ; t_Index < m_ResultSetQueryTreeCount ; t_Index ++ )
  3932. {
  3933. if ( m_ResultSetQueryTree [ t_Index ] )
  3934. {
  3935. delete m_ResultSetQueryTree [ t_Index ] ;
  3936. }
  3937. }
  3938. delete [] m_ResultSetQueryTree ;
  3939. }
  3940. if ( m_UnSupportedQueryTree )
  3941. {
  3942. for ( ULONG t_Index = 0 ; t_Index < m_UnSupportedQueryTreeCount ; t_Index ++ )
  3943. {
  3944. if ( m_UnSupportedQueryTree [ t_Index ] )
  3945. {
  3946. delete m_UnSupportedQueryTree [ t_Index ] ;
  3947. }
  3948. }
  3949. delete [] m_UnSupportedQueryTree ;
  3950. }
  3951. if ( m_ReferencedSetQueryTree )
  3952. {
  3953. for ( ULONG t_Index = 0 ; t_Index < m_ReferencedSetQueryTreeCount ; t_Index ++ )
  3954. {
  3955. if ( m_ReferencedSetQueryTree [ t_Index ] )
  3956. {
  3957. delete m_ReferencedSetQueryTree [ t_Index ] ;
  3958. }
  3959. }
  3960. delete [] m_ReferencedSetQueryTree ;
  3961. }
  3962. if ( m_Context )
  3963. {
  3964. m_Context->Release () ;
  3965. }
  3966. if ( m_Namespace )
  3967. {
  3968. m_Namespace->Release () ;
  3969. }
  3970. if ( m_Repository )
  3971. {
  3972. m_Repository->Release () ;
  3973. }
  3974. if ( m_ProviderName )
  3975. {
  3976. delete [] m_ProviderName ;
  3977. }
  3978. if ( m_CacheRefreshInterval )
  3979. {
  3980. SysFreeString ( m_CacheRefreshInterval ) ;
  3981. }
  3982. }
  3983. /******************************************************************************
  3984. *
  3985. * Name:
  3986. *
  3987. *
  3988. * Description:
  3989. *
  3990. *
  3991. *****************************************************************************/
  3992. ULONG CServerObject_ClassProviderRegistrationV1 :: AddRef ()
  3993. {
  3994. return InterlockedIncrement ( & m_ReferenceCount ) ;
  3995. }
  3996. /******************************************************************************
  3997. *
  3998. * Name:
  3999. *
  4000. *
  4001. * Description:
  4002. *
  4003. *
  4004. *****************************************************************************/
  4005. ULONG CServerObject_ClassProviderRegistrationV1 :: Release ()
  4006. {
  4007. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  4008. if ( t_ReferenceCount == 0 )
  4009. {
  4010. delete this ;
  4011. }
  4012. return t_ReferenceCount ;
  4013. }
  4014. /******************************************************************************
  4015. *
  4016. * Name:
  4017. *
  4018. *
  4019. * Description:
  4020. *
  4021. *
  4022. *****************************************************************************/
  4023. HRESULT CServerObject_ClassProviderRegistrationV1 :: SetContext (
  4024. IWbemContext *a_Context ,
  4025. IWbemPath *a_Namespace ,
  4026. IWbemServices *a_Repository
  4027. )
  4028. {
  4029. HRESULT t_Result = S_OK ;
  4030. m_Context = a_Context ;
  4031. m_Namespace = a_Namespace ;
  4032. m_Repository = a_Repository ;
  4033. if ( m_Context )
  4034. {
  4035. m_Context->AddRef () ;
  4036. }
  4037. if ( m_Namespace )
  4038. {
  4039. m_Namespace->AddRef () ;
  4040. }
  4041. if ( m_Repository )
  4042. {
  4043. m_Repository->AddRef () ;
  4044. }
  4045. return t_Result ;
  4046. }
  4047. /******************************************************************************
  4048. *
  4049. * Name:
  4050. *
  4051. *
  4052. * Description:
  4053. *
  4054. *
  4055. *****************************************************************************/
  4056. HRESULT CServerObject_ClassProviderRegistrationV1 :: ParseQuery (
  4057. ULONG &a_Count ,
  4058. WmiTreeNode **&a_Root ,
  4059. SAFEARRAY *a_Array
  4060. )
  4061. {
  4062. HRESULT t_Result = S_OK ;
  4063. if ( SafeArrayGetDim ( a_Array ) == 1 )
  4064. {
  4065. LONG t_Dimension = 1 ;
  4066. LONG t_Lower ;
  4067. SafeArrayGetLBound ( a_Array , t_Dimension , & t_Lower ) ;
  4068. LONG t_Upper ;
  4069. SafeArrayGetUBound ( a_Array , t_Dimension , & t_Upper ) ;
  4070. LONG t_Count = ( t_Upper - t_Lower ) + 1 ;
  4071. a_Root = NULL ;
  4072. a_Count = t_Count ;
  4073. if ( t_Count )
  4074. {
  4075. a_Root = new WmiTreeNode * [ t_Count ] ;
  4076. if ( a_Root )
  4077. {
  4078. ZeroMemory ( a_Root , sizeof ( WmiTreeNode * ) * t_Count ) ;
  4079. for ( LONG t_ElementIndex = t_Lower ; SUCCEEDED ( t_Result ) && ( t_ElementIndex <= t_Upper ) ; t_ElementIndex ++ )
  4080. {
  4081. BSTR t_Element ;
  4082. if ( SUCCEEDED ( t_Result = SafeArrayGetElement ( a_Array , &t_ElementIndex , & t_Element ) ) )
  4083. {
  4084. QueryPreprocessor t_PreProcessor ;
  4085. IWbemQuery *t_QueryAnalyser = NULL ;
  4086. t_Result = CoCreateInstance (
  4087. CLSID_WbemQuery ,
  4088. NULL ,
  4089. CLSCTX_INPROC_SERVER ,
  4090. IID_IWbemQuery ,
  4091. ( void ** ) & t_QueryAnalyser
  4092. ) ;
  4093. if ( SUCCEEDED ( t_Result ) )
  4094. {
  4095. switch ( t_PreProcessor.Query ( t_Element , t_QueryAnalyser ) )
  4096. {
  4097. case QueryPreprocessor :: State_True:
  4098. {
  4099. WmiTreeNode *t_Root = NULL ;
  4100. switch ( t_PreProcessor.PreProcess ( m_Context , t_QueryAnalyser , t_Root ) )
  4101. {
  4102. case QueryPreprocessor :: State_True:
  4103. {
  4104. a_Root [ t_ElementIndex - t_Lower ] = t_Root ;
  4105. }
  4106. break ;
  4107. case QueryPreprocessor :: State_Error:
  4108. {
  4109. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4110. }
  4111. break;
  4112. default:
  4113. {
  4114. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4115. }
  4116. break ;
  4117. }
  4118. }
  4119. break ;
  4120. case QueryPreprocessor :: State_Error:
  4121. {
  4122. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4123. }
  4124. break;
  4125. default:
  4126. {
  4127. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4128. }
  4129. break ;
  4130. }
  4131. t_QueryAnalyser->Release () ;
  4132. }
  4133. SysFreeString ( t_Element ) ;
  4134. }
  4135. }
  4136. if ( FAILED ( t_Result ) )
  4137. {
  4138. for ( LONG t_ElementIndex = t_Lower ; t_ElementIndex <= t_Upper ; t_ElementIndex ++ )
  4139. {
  4140. delete a_Root [ t_ElementIndex - t_Lower] ;
  4141. }
  4142. delete [] a_Root ;
  4143. a_Root = NULL ;
  4144. a_Count = 0 ;
  4145. if ( m_Version == 1 )
  4146. {
  4147. t_Result = S_OK ;
  4148. }
  4149. }
  4150. }
  4151. else
  4152. {
  4153. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4154. }
  4155. }
  4156. }
  4157. else
  4158. {
  4159. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4160. }
  4161. return t_Result ;
  4162. }
  4163. /******************************************************************************
  4164. *
  4165. * Name:
  4166. *
  4167. *
  4168. * Description:
  4169. *
  4170. *
  4171. *****************************************************************************/
  4172. HRESULT CServerObject_ClassProviderRegistrationV1 :: QueryProperties (
  4173. Enum_PropertyMask a_Mask ,
  4174. IWbemClassObject *a_Object
  4175. )
  4176. {
  4177. HRESULT t_Result = S_OK ;
  4178. m_Supported = TRUE ;
  4179. if ( a_Mask & e_Version )
  4180. {
  4181. VARIANT t_Variant ;
  4182. VariantInit ( & t_Variant ) ;
  4183. LONG t_VarType = 0 ;
  4184. LONG t_Flavour = 0 ;
  4185. HRESULT t_TempResult = a_Object->Get ( s_Strings_Version , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4186. if ( SUCCEEDED ( t_TempResult ) )
  4187. {
  4188. if ( t_Variant.vt == VT_I4 )
  4189. {
  4190. m_Version = t_Variant.lVal ;
  4191. }
  4192. else if ( t_Variant.vt == VT_NULL )
  4193. {
  4194. m_Version = 1 ;
  4195. }
  4196. else
  4197. {
  4198. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4199. }
  4200. }
  4201. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4202. {
  4203. t_Result = t_TempResult;
  4204. }
  4205. VariantClear ( & t_Variant ) ;
  4206. }
  4207. if ( SUCCEEDED ( t_Result ) )
  4208. {
  4209. if ( a_Mask & e_SupportsPut )
  4210. {
  4211. VARIANT t_Variant ;
  4212. VariantInit ( & t_Variant ) ;
  4213. LONG t_VarType = 0 ;
  4214. LONG t_Flavour = 0 ;
  4215. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsPut , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4216. if ( SUCCEEDED ( t_TempResult ) )
  4217. {
  4218. if ( t_Variant.vt == VT_BOOL )
  4219. {
  4220. m_SupportsPut = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4221. }
  4222. else if ( t_Variant.vt == VT_NULL )
  4223. {
  4224. m_SupportsPut = FALSE ;
  4225. }
  4226. else
  4227. {
  4228. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4229. }
  4230. }
  4231. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4232. {
  4233. t_Result = t_TempResult;
  4234. }
  4235. VariantClear ( & t_Variant ) ;
  4236. }
  4237. }
  4238. if ( SUCCEEDED ( t_Result ) )
  4239. {
  4240. if ( a_Mask & e_SupportsGet )
  4241. {
  4242. VARIANT t_Variant ;
  4243. VariantInit ( & t_Variant ) ;
  4244. LONG t_VarType = 0 ;
  4245. LONG t_Flavour = 0 ;
  4246. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsGet , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4247. if ( SUCCEEDED ( t_TempResult ) )
  4248. {
  4249. if ( t_Variant.vt == VT_BOOL )
  4250. {
  4251. m_SupportsGet = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4252. }
  4253. else if ( t_Variant.vt == VT_NULL )
  4254. {
  4255. m_SupportsGet = FALSE ;
  4256. }
  4257. else
  4258. {
  4259. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4260. }
  4261. }
  4262. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4263. {
  4264. t_Result = t_TempResult;
  4265. }
  4266. VariantClear ( & t_Variant ) ;
  4267. }
  4268. }
  4269. if ( SUCCEEDED ( t_Result ) )
  4270. {
  4271. if ( a_Mask & e_SupportsDelete )
  4272. {
  4273. VARIANT t_Variant ;
  4274. VariantInit ( & t_Variant ) ;
  4275. LONG t_VarType = 0 ;
  4276. LONG t_Flavour = 0 ;
  4277. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsDelete , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4278. if ( SUCCEEDED ( t_TempResult ) )
  4279. {
  4280. if ( t_Variant.vt == VT_BOOL )
  4281. {
  4282. m_SupportsDelete = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4283. }
  4284. else if ( t_Variant.vt == VT_NULL )
  4285. {
  4286. m_SupportsDelete = FALSE ;
  4287. }
  4288. else
  4289. {
  4290. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4291. }
  4292. }
  4293. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4294. {
  4295. t_Result = t_TempResult;
  4296. }
  4297. VariantClear ( & t_Variant ) ;
  4298. }
  4299. }
  4300. if ( SUCCEEDED ( t_Result ) )
  4301. {
  4302. if ( a_Mask & e_SupportsEnumeration )
  4303. {
  4304. VARIANT t_Variant ;
  4305. VariantInit ( & t_Variant ) ;
  4306. LONG t_VarType = 0 ;
  4307. LONG t_Flavour = 0 ;
  4308. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsEnumeration , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4309. if ( SUCCEEDED ( t_TempResult ) )
  4310. {
  4311. if ( t_Variant.vt == VT_BOOL )
  4312. {
  4313. m_SupportsEnumeration = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4314. }
  4315. else if ( t_Variant.vt == VT_NULL )
  4316. {
  4317. m_SupportsEnumeration = FALSE ;
  4318. }
  4319. else
  4320. {
  4321. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4322. }
  4323. }
  4324. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4325. {
  4326. t_Result = t_TempResult;
  4327. }
  4328. VariantClear ( & t_Variant ) ;
  4329. }
  4330. }
  4331. if ( SUCCEEDED ( t_Result ) )
  4332. {
  4333. if ( a_Mask & e_SupportsBatching )
  4334. {
  4335. VARIANT t_Variant ;
  4336. VariantInit ( & t_Variant ) ;
  4337. LONG t_VarType = 0 ;
  4338. LONG t_Flavour = 0 ;
  4339. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsBatching , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4340. if ( SUCCEEDED ( t_TempResult ) )
  4341. {
  4342. if ( t_Variant.vt == VT_BOOL )
  4343. {
  4344. m_SupportsBatching = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4345. }
  4346. else if ( t_Variant.vt == VT_NULL )
  4347. {
  4348. m_SupportsBatching = FALSE ;
  4349. }
  4350. else
  4351. {
  4352. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4353. }
  4354. }
  4355. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4356. {
  4357. t_Result = t_TempResult;
  4358. }
  4359. VariantClear ( & t_Variant ) ;
  4360. }
  4361. }
  4362. if ( SUCCEEDED ( t_Result ) )
  4363. {
  4364. if ( a_Mask & e_SupportsTransactions )
  4365. {
  4366. VARIANT t_Variant ;
  4367. VariantInit ( & t_Variant ) ;
  4368. LONG t_VarType = 0 ;
  4369. LONG t_Flavour = 0 ;
  4370. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsTransactions , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4371. if ( SUCCEEDED ( t_TempResult ) )
  4372. {
  4373. if ( t_Variant.vt == VT_BOOL )
  4374. {
  4375. m_SupportsTransactions = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4376. }
  4377. else if ( t_Variant.vt == VT_NULL )
  4378. {
  4379. m_SupportsTransactions = FALSE ;
  4380. }
  4381. else
  4382. {
  4383. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4384. }
  4385. }
  4386. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4387. {
  4388. t_Result = t_TempResult;
  4389. }
  4390. VariantClear ( & t_Variant ) ;
  4391. }
  4392. }
  4393. if ( SUCCEEDED ( t_Result ) )
  4394. {
  4395. if ( a_Mask & e_PerUserSchema )
  4396. {
  4397. VARIANT t_Variant ;
  4398. VariantInit ( & t_Variant ) ;
  4399. LONG t_VarType = 0 ;
  4400. LONG t_Flavour = 0 ;
  4401. HRESULT t_TempResult = a_Object->Get ( s_Strings_PerUserSchema , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4402. if ( SUCCEEDED ( t_TempResult ) )
  4403. {
  4404. if ( t_Variant.vt == VT_BOOL )
  4405. {
  4406. m_PerUserSchema = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4407. }
  4408. else if ( t_Variant.vt == VT_NULL )
  4409. {
  4410. m_PerUserSchema = FALSE ;
  4411. }
  4412. else
  4413. {
  4414. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4415. }
  4416. }
  4417. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4418. {
  4419. t_Result = t_TempResult;
  4420. }
  4421. VariantClear ( & t_Variant ) ;
  4422. }
  4423. }
  4424. if ( SUCCEEDED ( t_Result ) )
  4425. {
  4426. if ( a_Mask & e_ReSynchroniseOnNamespaceOpen )
  4427. {
  4428. VARIANT t_Variant ;
  4429. VariantInit ( & t_Variant ) ;
  4430. LONG t_VarType = 0 ;
  4431. LONG t_Flavour = 0 ;
  4432. HRESULT t_TempResult = a_Object->Get ( s_Strings_ReSynchroniseOnNamespaceOpen , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4433. if ( SUCCEEDED ( t_TempResult ) )
  4434. {
  4435. if ( t_Variant.vt == VT_BOOL )
  4436. {
  4437. m_ReSynchroniseOnNamespaceOpen = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  4438. }
  4439. else if ( t_Variant.vt == VT_NULL )
  4440. {
  4441. m_ReSynchroniseOnNamespaceOpen = FALSE ;
  4442. }
  4443. else
  4444. {
  4445. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4446. }
  4447. }
  4448. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4449. {
  4450. t_Result = t_TempResult;
  4451. }
  4452. VariantClear ( & t_Variant ) ;
  4453. }
  4454. }
  4455. if ( SUCCEEDED ( t_Result ) )
  4456. {
  4457. if ( a_Mask & e_QuerySupportLevels )
  4458. {
  4459. VARIANT t_Variant ;
  4460. VariantInit ( & t_Variant ) ;
  4461. LONG t_VarType = 0 ;
  4462. LONG t_Flavour = 0 ;
  4463. HRESULT t_TempResult = a_Object->Get ( s_Strings_QuerySupportLevels , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4464. if ( SUCCEEDED ( t_TempResult ) )
  4465. {
  4466. if ( t_Variant.vt == ( VT_BSTR | VT_ARRAY ) )
  4467. {
  4468. if ( SafeArrayGetDim ( t_Variant.parray ) == 1 )
  4469. {
  4470. LONG t_Dimension = 1 ;
  4471. LONG t_Lower ;
  4472. SafeArrayGetLBound ( t_Variant.parray , t_Dimension , & t_Lower ) ;
  4473. LONG t_Upper ;
  4474. SafeArrayGetUBound ( t_Variant.parray , t_Dimension , & t_Upper ) ;
  4475. LONG t_Count = ( t_Upper - t_Lower ) + 1 ;
  4476. if ( t_Count )
  4477. {
  4478. for ( LONG t_ElementIndex = t_Lower ; t_ElementIndex <= t_Upper ; t_ElementIndex ++ )
  4479. {
  4480. BSTR t_Element ;
  4481. if ( SUCCEEDED ( SafeArrayGetElement ( t_Variant.parray , &t_ElementIndex , & t_Element ) ) )
  4482. {
  4483. if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_UnarySelect , t_Element ) == 0 )
  4484. {
  4485. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_UnarySelect ;
  4486. }
  4487. else if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_References , t_Element ) == 0 )
  4488. {
  4489. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_References ;
  4490. }
  4491. else if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_Associators , t_Element ) == 0 )
  4492. {
  4493. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_Associators ;
  4494. }
  4495. else if ( wbem_wcsicmp ( s_Strings_QuerySupportLevels_V1ProviderDefined , t_Element ) == 0 )
  4496. {
  4497. m_QuerySupportLevels = m_QuerySupportLevels | e_QuerySupportLevels_V1ProviderDefined ;
  4498. }
  4499. else
  4500. {
  4501. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4502. }
  4503. SysFreeString ( t_Element ) ;
  4504. }
  4505. }
  4506. }
  4507. else
  4508. {
  4509. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4510. }
  4511. }
  4512. else
  4513. {
  4514. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4515. }
  4516. }
  4517. else if ( t_Variant.vt == VT_NULL )
  4518. {
  4519. m_QuerySupportLevels = e_QuerySupportLevels_None ;
  4520. }
  4521. else
  4522. {
  4523. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4524. }
  4525. }
  4526. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4527. {
  4528. t_Result = t_TempResult;
  4529. }
  4530. VariantClear ( & t_Variant ) ;
  4531. }
  4532. }
  4533. if ( SUCCEEDED ( t_Result ) )
  4534. {
  4535. if ( a_Mask & e_InteractionType )
  4536. {
  4537. VARIANT t_Variant ;
  4538. VariantInit ( & t_Variant ) ;
  4539. LONG t_VarType = 0 ;
  4540. LONG t_Flavour = 0 ;
  4541. HRESULT t_TempResult = a_Object->Get ( s_Strings_InteractionType , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4542. if ( SUCCEEDED ( t_TempResult ) )
  4543. {
  4544. if ( t_Variant.vt == VT_I4 )
  4545. {
  4546. switch ( t_Variant.lVal )
  4547. {
  4548. case 0:
  4549. {
  4550. m_InteractionType = e_InteractionType_Pull ;
  4551. }
  4552. break ;
  4553. case 1:
  4554. {
  4555. m_InteractionType = e_InteractionType_Push ;
  4556. }
  4557. break ;
  4558. case 2:
  4559. {
  4560. m_InteractionType = e_InteractionType_PushVerify ;
  4561. }
  4562. break ;
  4563. default:
  4564. {
  4565. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4566. }
  4567. break ;
  4568. }
  4569. }
  4570. else if ( t_Variant.vt == VT_NULL )
  4571. {
  4572. m_InteractionType = e_InteractionType_Pull ;
  4573. }
  4574. else
  4575. {
  4576. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4577. }
  4578. }
  4579. VariantClear ( & t_Variant ) ;
  4580. }
  4581. }
  4582. if ( SUCCEEDED ( t_Result ) )
  4583. {
  4584. if ( a_Mask & e_ResultSetQueries )
  4585. {
  4586. VARIANT t_Variant ;
  4587. VariantInit ( & t_Variant ) ;
  4588. LONG t_VarType = 0 ;
  4589. LONG t_Flavour = 0 ;
  4590. HRESULT t_TempResult = a_Object->Get ( s_Strings_ResultSetQueries , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4591. if ( SUCCEEDED ( t_TempResult ) )
  4592. {
  4593. if ( t_Variant.vt == ( VT_ARRAY | VT_BSTR ) )
  4594. {
  4595. t_Result = ParseQuery ( m_ResultSetQueryTreeCount , m_ResultSetQueryTree , t_Variant.parray ) ;
  4596. }
  4597. else if ( t_Variant.vt == VT_NULL )
  4598. {
  4599. }
  4600. else
  4601. {
  4602. }
  4603. }
  4604. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4605. {
  4606. t_Result = t_TempResult;
  4607. }
  4608. VariantClear ( & t_Variant ) ;
  4609. }
  4610. }
  4611. if ( SUCCEEDED ( t_Result ) )
  4612. {
  4613. if ( a_Mask & e_UnSupportedQueries )
  4614. {
  4615. VARIANT t_Variant ;
  4616. VariantInit ( & t_Variant ) ;
  4617. LONG t_VarType = 0 ;
  4618. LONG t_Flavour = 0 ;
  4619. HRESULT t_TempResult = a_Object->Get ( s_Strings_UnSupportedQueries , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4620. if ( SUCCEEDED ( t_TempResult ) )
  4621. {
  4622. if ( t_Variant.vt == ( VT_ARRAY | VT_BSTR ) )
  4623. {
  4624. t_Result = ParseQuery ( m_UnSupportedQueryTreeCount , m_UnSupportedQueryTree , t_Variant.parray ) ;
  4625. }
  4626. else if ( t_Variant.vt == VT_NULL )
  4627. {
  4628. }
  4629. else
  4630. {
  4631. }
  4632. }
  4633. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4634. {
  4635. t_Result = t_TempResult;
  4636. }
  4637. VariantClear ( & t_Variant ) ;
  4638. }
  4639. }
  4640. if ( SUCCEEDED ( t_Result ) )
  4641. {
  4642. if ( a_Mask & e_ReferencedSetQueries )
  4643. {
  4644. VARIANT t_Variant ;
  4645. VariantInit ( & t_Variant ) ;
  4646. LONG t_VarType = 0 ;
  4647. LONG t_Flavour = 0 ;
  4648. HRESULT t_TempResult = a_Object->Get ( s_Strings_ReferencedSetQueries , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4649. if ( SUCCEEDED ( t_TempResult ) )
  4650. {
  4651. if ( t_Variant.vt == ( VT_ARRAY | VT_BSTR ) )
  4652. {
  4653. t_Result = ParseQuery ( m_ReferencedSetQueryTreeCount , m_ReferencedSetQueryTree , t_Variant.parray ) ;
  4654. // Backwards compatibility.
  4655. // W2K code, Query is not really parsed, as long as there is a
  4656. // value, m_HasReferencedSet is TRUE.
  4657. LONG t_Lower ;
  4658. SafeArrayGetLBound ( t_Variant.parray , 1 , & t_Lower ) ;
  4659. LONG t_Upper ;
  4660. SafeArrayGetUBound ( t_Variant.parray , 1 , & t_Upper ) ;
  4661. LONG t_Count = ( t_Upper - t_Lower ) + 1 ;
  4662. m_HasReferencedSet = ( ( t_Upper - t_Lower ) + 1 ) > 0;
  4663. }
  4664. else if ( t_Variant.vt == VT_NULL )
  4665. {
  4666. }
  4667. else
  4668. {
  4669. }
  4670. }
  4671. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4672. {
  4673. t_Result = t_TempResult;
  4674. }
  4675. VariantClear ( & t_Variant ) ;
  4676. }
  4677. }
  4678. if ( SUCCEEDED ( t_Result ) )
  4679. {
  4680. if ( a_Mask & e_CacheRefreshInterval )
  4681. {
  4682. VARIANT t_Variant ;
  4683. VariantInit ( & t_Variant ) ;
  4684. LONG t_VarType = 0 ;
  4685. LONG t_Flavour = 0 ;
  4686. HRESULT t_TempResult = a_Object->Get ( s_Strings_CacheRefreshInterval , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4687. if ( SUCCEEDED ( t_TempResult ) )
  4688. {
  4689. if ( t_Variant.vt == VT_BSTR )
  4690. {
  4691. if ( m_CacheRefreshInterval )
  4692. {
  4693. SysFreeString ( m_CacheRefreshInterval ) ;
  4694. }
  4695. m_CacheRefreshInterval = SysAllocString ( t_Variant.bstrVal ) ;
  4696. if ( m_CacheRefreshInterval )
  4697. {
  4698. CWbemDateTime t_Interval ;
  4699. t_Result = t_Interval.PutValue ( m_CacheRefreshInterval ) ;
  4700. if ( SUCCEEDED ( t_Result ) )
  4701. {
  4702. VARIANT_BOOL t_Bool = VARIANT_FALSE ;
  4703. t_Result = t_Interval.GetIsInterval ( & t_Bool ) ;
  4704. if ( t_Bool == VARIANT_TRUE )
  4705. {
  4706. LONG t_MicroSeconds = 0 ;
  4707. LONG t_Seconds = 0 ;
  4708. LONG t_Minutes = 0 ;
  4709. LONG t_Hours = 0 ;
  4710. LONG t_Days = 0 ;
  4711. t_Interval.GetMicroseconds ( & t_MicroSeconds ) ;
  4712. t_Interval.GetSeconds ( & t_Seconds ) ;
  4713. t_Interval.GetMinutes ( & t_Minutes ) ;
  4714. t_Interval.GetHours ( & t_Hours ) ;
  4715. t_Interval.GetDay ( & t_Days ) ;
  4716. m_CacheRefreshIntervalMilliSeconds = ( t_Days * 24 * 60 * 60 * 1000 ) +
  4717. ( t_Hours * 60 * 60 * 1000 ) +
  4718. ( t_Minutes * 60 * 1000 ) +
  4719. ( t_Seconds * 1000 ) +
  4720. ( t_MicroSeconds / 1000 ) ;
  4721. }
  4722. else
  4723. {
  4724. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4725. }
  4726. }
  4727. else
  4728. {
  4729. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4730. }
  4731. }
  4732. else
  4733. {
  4734. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4735. }
  4736. }
  4737. else if ( t_Variant.vt == VT_NULL )
  4738. {
  4739. if ( m_CacheRefreshInterval )
  4740. {
  4741. SysFreeString ( m_CacheRefreshInterval ) ;
  4742. m_CacheRefreshInterval = NULL ;
  4743. }
  4744. }
  4745. else
  4746. {
  4747. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4748. }
  4749. }
  4750. else if (t_TempResult != WBEM_E_NOT_FOUND)
  4751. {
  4752. t_Result = t_TempResult;
  4753. }
  4754. VariantClear ( & t_Variant ) ;
  4755. }
  4756. }
  4757. if ( SUCCEEDED ( t_Result ) )
  4758. {
  4759. if ( ( m_InteractionType == e_InteractionType_Pull ) && ( ( m_SupportsEnumeration == FALSE ) || ( m_SupportsGet == FALSE ) ) )
  4760. {
  4761. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4762. }
  4763. }
  4764. return t_Result ;
  4765. }
  4766. /******************************************************************************
  4767. *
  4768. * Name:
  4769. *
  4770. *
  4771. * Description:
  4772. *
  4773. *
  4774. *****************************************************************************/
  4775. HRESULT CServerObject_ClassProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  4776. Enum_PropertyMask a_Mask ,
  4777. IWbemPath *a_Scope,
  4778. BSTR a_Query
  4779. )
  4780. {
  4781. HRESULT t_Result = S_OK ;
  4782. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  4783. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  4784. if ( t_Language )
  4785. {
  4786. t_Result = m_Repository->ExecQuery (
  4787. t_Language ,
  4788. a_Query ,
  4789. WBEM_FLAG_FORWARD_ONLY ,
  4790. m_Context ,
  4791. & t_ClassObjectEnum
  4792. ) ;
  4793. if ( SUCCEEDED ( t_Result ) )
  4794. {
  4795. IWbemClassObject *t_ClassObject = NULL ;
  4796. ULONG t_ObjectCount = 0 ;
  4797. t_ClassObjectEnum->Reset () ;
  4798. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  4799. {
  4800. VARIANT t_Variant ;
  4801. VariantInit ( & t_Variant ) ;
  4802. LONG t_VarType = 0 ;
  4803. LONG t_Flavour = 0 ;
  4804. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  4805. if ( SUCCEEDED ( t_Result ) )
  4806. {
  4807. if ( t_Variant.vt == VT_BSTR )
  4808. {
  4809. if ( wbem_wcsicmp ( s_Strings_ClassProviderRegistration , t_Variant.bstrVal ) == 0 )
  4810. {
  4811. t_Result = QueryProperties (
  4812. a_Mask ,
  4813. t_ClassObject
  4814. ) ;
  4815. }
  4816. }
  4817. }
  4818. VariantClear ( & t_Variant ) ;
  4819. t_ClassObject->Release () ;
  4820. }
  4821. t_ClassObjectEnum->Release () ;
  4822. }
  4823. else
  4824. {
  4825. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  4826. }
  4827. SysFreeString ( t_Language ) ;
  4828. }
  4829. else
  4830. {
  4831. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4832. }
  4833. return t_Result ;
  4834. }
  4835. /******************************************************************************
  4836. *
  4837. * Name:
  4838. *
  4839. *
  4840. * Description:
  4841. *
  4842. *
  4843. *****************************************************************************/
  4844. HRESULT CServerObject_ClassProviderRegistrationV1 :: QueryRepository (
  4845. Enum_PropertyMask a_Mask ,
  4846. IWbemPath *a_Scope,
  4847. LPCWSTR a_ProviderName
  4848. )
  4849. {
  4850. BSTR t_Query = NULL ;
  4851. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  4852. 3 ,
  4853. & t_Query ,
  4854. L"references of {__Win32Provider.Name=\"" ,
  4855. a_ProviderName ,
  4856. L"\"}"
  4857. ) ;
  4858. if ( SUCCEEDED ( t_Result ) )
  4859. {
  4860. t_Result = QueryRepositoryUsingQuery (
  4861. a_Mask ,
  4862. a_Scope,
  4863. t_Query
  4864. ) ;
  4865. if ( SUCCEEDED ( t_Result ) )
  4866. {
  4867. m_ProviderName = new wchar_t [ wcslen ( a_ProviderName ) + 1 ] ;
  4868. if ( m_ProviderName )
  4869. {
  4870. StringCchCopy ( m_ProviderName , wcslen ( a_ProviderName ) + 1, a_ProviderName ) ;
  4871. }
  4872. else
  4873. {
  4874. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4875. }
  4876. }
  4877. SysFreeString ( t_Query ) ;
  4878. }
  4879. return t_Result ;
  4880. }
  4881. /******************************************************************************
  4882. *
  4883. * Name:
  4884. *
  4885. *
  4886. * Description:
  4887. *
  4888. *
  4889. *****************************************************************************/
  4890. HRESULT CServerObject_ClassProviderRegistrationV1 :: QueryRepository (
  4891. Enum_PropertyMask a_Mask ,
  4892. IWbemPath *a_Scope,
  4893. IWbemPath *a_Provider
  4894. )
  4895. {
  4896. BSTR t_ObjectPath = NULL ;
  4897. ULONG t_ObjectPathLength = 0 ;
  4898. HRESULT t_Result = a_Provider->GetText (
  4899. WBEMPATH_GET_RELATIVE_ONLY ,
  4900. & t_ObjectPathLength ,
  4901. NULL
  4902. ) ;
  4903. if ( SUCCEEDED ( t_Result ) )
  4904. {
  4905. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  4906. if ( t_ObjectPath )
  4907. {
  4908. t_Result = a_Provider->GetText (
  4909. WBEMPATH_GET_RELATIVE_ONLY ,
  4910. & t_ObjectPathLength ,
  4911. t_ObjectPath
  4912. ) ;
  4913. if ( SUCCEEDED ( t_Result ) )
  4914. {
  4915. BSTR t_Query = NULL ;
  4916. t_Result = WmiHelper :: ConcatenateStrings (
  4917. 3 ,
  4918. & t_Query ,
  4919. L"references of {" ,
  4920. t_ObjectPath ,
  4921. L"}"
  4922. ) ;
  4923. if ( SUCCEEDED ( t_Result ) )
  4924. {
  4925. t_Result = QueryRepositoryUsingQuery (
  4926. a_Mask ,
  4927. a_Scope,
  4928. t_Query
  4929. ) ;
  4930. if ( SUCCEEDED ( t_Result ) )
  4931. {
  4932. IWbemPathKeyList *t_Keys = NULL ;
  4933. t_Result = a_Provider->GetKeyList (
  4934. & t_Keys
  4935. ) ;
  4936. if ( SUCCEEDED ( t_Result ) )
  4937. {
  4938. ULONG t_ProviderNameLength = 0 ;
  4939. ULONG t_Type = 0 ;
  4940. t_Result = t_Keys->GetKey (
  4941. 0 ,
  4942. 0 ,
  4943. NULL ,
  4944. NULL ,
  4945. & t_ProviderNameLength ,
  4946. m_ProviderName ,
  4947. & t_Type
  4948. ) ;
  4949. if ( SUCCEEDED ( t_Result ) )
  4950. {
  4951. m_ProviderName = new wchar_t [ ( t_ProviderNameLength / sizeof ( wchar_t ) ) + 1 ] ;
  4952. if ( m_ProviderName )
  4953. {
  4954. t_Result = t_Keys->GetKey (
  4955. 0 ,
  4956. 0 ,
  4957. NULL ,
  4958. NULL ,
  4959. & t_ProviderNameLength ,
  4960. m_ProviderName ,
  4961. & t_Type
  4962. ) ;
  4963. }
  4964. else
  4965. {
  4966. t_Result = WBEM_E_OUT_OF_MEMORY;
  4967. }
  4968. }
  4969. t_Keys->Release () ;
  4970. }
  4971. }
  4972. SysFreeString ( t_Query ) ;
  4973. }
  4974. }
  4975. SysFreeString ( t_ObjectPath ) ;
  4976. }
  4977. }
  4978. return t_Result ;
  4979. }
  4980. /******************************************************************************
  4981. *
  4982. * Name:
  4983. *
  4984. *
  4985. * Description:
  4986. *
  4987. *
  4988. *****************************************************************************/
  4989. HRESULT CServerObject_ClassProviderRegistrationV1 :: Load (
  4990. Enum_PropertyMask a_Mask ,
  4991. IWbemPath *a_Scope,
  4992. IWbemClassObject *a_Class
  4993. )
  4994. {
  4995. HRESULT t_Result = S_OK ;
  4996. IWbemQualifierSet *t_QualifierObject = NULL ;
  4997. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  4998. if ( SUCCEEDED ( t_Result ) )
  4999. {
  5000. VARIANT t_Variant ;
  5001. VariantInit ( & t_Variant ) ;
  5002. LONG t_Flavour = 0 ;
  5003. t_Result = t_QualifierObject->Get (
  5004. ProviderSubSystem_Common_Globals :: s_Provider ,
  5005. 0 ,
  5006. & t_Variant ,
  5007. & t_Flavour
  5008. ) ;
  5009. if ( SUCCEEDED ( t_Result ) )
  5010. {
  5011. if ( t_Variant.vt == VT_BSTR )
  5012. {
  5013. t_Result = QueryRepository (
  5014. a_Mask ,
  5015. a_Scope ,
  5016. t_Variant.bstrVal
  5017. ) ;
  5018. VariantClear ( & t_Variant ) ;
  5019. }
  5020. }
  5021. t_QualifierObject->Release () ;
  5022. }
  5023. return t_Result ;
  5024. }
  5025. /******************************************************************************
  5026. *
  5027. * Name:
  5028. *
  5029. *
  5030. * Description:
  5031. *
  5032. *
  5033. *****************************************************************************/
  5034. HRESULT CServerObject_ClassProviderRegistrationV1 :: Load (
  5035. Enum_PropertyMask a_Mask ,
  5036. IWbemPath *a_Scope,
  5037. LPCWSTR a_Provider
  5038. )
  5039. {
  5040. HRESULT t_Result = S_OK ;
  5041. t_Result = QueryRepository (
  5042. a_Mask ,
  5043. a_Scope ,
  5044. a_Provider
  5045. ) ;
  5046. return t_Result ;
  5047. }
  5048. /******************************************************************************
  5049. *
  5050. * Name:
  5051. *
  5052. *
  5053. * Description:
  5054. *
  5055. *
  5056. *****************************************************************************/
  5057. HRESULT CServerObject_ClassProviderRegistrationV1 :: Load (
  5058. Enum_PropertyMask a_Mask ,
  5059. IWbemPath *a_Scope,
  5060. IWbemPath * a_Provider
  5061. )
  5062. {
  5063. HRESULT t_Result = S_OK ;
  5064. t_Result = QueryRepository (
  5065. a_Mask ,
  5066. a_Scope ,
  5067. a_Provider
  5068. ) ;
  5069. if ( FAILED ( t_Result ) )
  5070. {
  5071. m_Result = t_Result ;
  5072. t_Result = S_OK ;
  5073. }
  5074. return t_Result ;
  5075. }
  5076. /******************************************************************************
  5077. *
  5078. * Name:
  5079. *
  5080. *
  5081. * Description:
  5082. *
  5083. *
  5084. *****************************************************************************/
  5085. CServerObject_MethodProviderRegistrationV1 :: CServerObject_MethodProviderRegistrationV1 () :
  5086. m_Context ( NULL ) ,
  5087. m_Namespace ( NULL ) ,
  5088. m_Repository ( NULL ) ,
  5089. m_SupportsMethods ( FALSE ) ,
  5090. m_Supported ( FALSE ) ,
  5091. m_Result ( S_OK )
  5092. {
  5093. }
  5094. /******************************************************************************
  5095. *
  5096. * Name:
  5097. *
  5098. *
  5099. * Description:
  5100. *
  5101. *
  5102. *****************************************************************************/
  5103. CServerObject_MethodProviderRegistrationV1::~CServerObject_MethodProviderRegistrationV1 ()
  5104. {
  5105. if ( m_Context )
  5106. {
  5107. m_Context->Release () ;
  5108. }
  5109. if ( m_Namespace )
  5110. {
  5111. m_Namespace->Release () ;
  5112. }
  5113. if ( m_Repository )
  5114. {
  5115. m_Repository->Release () ;
  5116. }
  5117. }
  5118. /******************************************************************************
  5119. *
  5120. * Name:
  5121. *
  5122. *
  5123. * Description:
  5124. *
  5125. *
  5126. *****************************************************************************/
  5127. ULONG CServerObject_MethodProviderRegistrationV1 :: AddRef ()
  5128. {
  5129. return InterlockedIncrement ( & m_ReferenceCount ) ;
  5130. }
  5131. /******************************************************************************
  5132. *
  5133. * Name:
  5134. *
  5135. *
  5136. * Description:
  5137. *
  5138. *
  5139. *****************************************************************************/
  5140. ULONG CServerObject_MethodProviderRegistrationV1 :: Release ()
  5141. {
  5142. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  5143. if ( t_ReferenceCount == 0 )
  5144. {
  5145. delete this ;
  5146. }
  5147. return t_ReferenceCount ;
  5148. }
  5149. /******************************************************************************
  5150. *
  5151. * Name:
  5152. *
  5153. *
  5154. * Description:
  5155. *
  5156. *
  5157. *****************************************************************************/
  5158. HRESULT CServerObject_MethodProviderRegistrationV1 :: SetContext (
  5159. IWbemContext *a_Context ,
  5160. IWbemPath *a_Namespace ,
  5161. IWbemServices *a_Repository
  5162. )
  5163. {
  5164. HRESULT t_Result = S_OK ;
  5165. m_Context = a_Context ;
  5166. m_Namespace = a_Namespace ;
  5167. m_Repository = a_Repository ;
  5168. if ( m_Context )
  5169. {
  5170. m_Context->AddRef () ;
  5171. }
  5172. if ( m_Namespace )
  5173. {
  5174. m_Namespace->AddRef () ;
  5175. }
  5176. if ( m_Repository )
  5177. {
  5178. m_Repository->AddRef () ;
  5179. }
  5180. return t_Result ;
  5181. }
  5182. /******************************************************************************
  5183. *
  5184. * Name:
  5185. *
  5186. *
  5187. * Description:
  5188. *
  5189. *
  5190. *****************************************************************************/
  5191. HRESULT CServerObject_MethodProviderRegistrationV1 :: QueryProperties (
  5192. Enum_PropertyMask a_Mask ,
  5193. IWbemClassObject *a_Object
  5194. )
  5195. {
  5196. HRESULT t_Result = S_OK ;
  5197. m_SupportsMethods = TRUE ;
  5198. m_Supported = TRUE ;
  5199. return t_Result ;
  5200. }
  5201. /******************************************************************************
  5202. *
  5203. * Name:
  5204. *
  5205. *
  5206. * Description:
  5207. *
  5208. *
  5209. *****************************************************************************/
  5210. HRESULT CServerObject_MethodProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  5211. Enum_PropertyMask a_Mask ,
  5212. IWbemPath *a_Scope,
  5213. BSTR a_Query
  5214. )
  5215. {
  5216. HRESULT t_Result = S_OK ;
  5217. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  5218. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  5219. if ( t_Language )
  5220. {
  5221. t_Result = m_Repository->ExecQuery (
  5222. t_Language ,
  5223. a_Query ,
  5224. WBEM_FLAG_FORWARD_ONLY ,
  5225. m_Context ,
  5226. & t_ClassObjectEnum
  5227. ) ;
  5228. if ( SUCCEEDED ( t_Result ) )
  5229. {
  5230. IWbemClassObject *t_ClassObject = NULL ;
  5231. ULONG t_ObjectCount = 0 ;
  5232. t_ClassObjectEnum->Reset () ;
  5233. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  5234. {
  5235. VARIANT t_Variant ;
  5236. VariantInit ( & t_Variant ) ;
  5237. LONG t_VarType = 0 ;
  5238. LONG t_Flavour = 0 ;
  5239. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  5240. if ( SUCCEEDED ( t_Result ) )
  5241. {
  5242. if ( t_Variant.vt == VT_BSTR )
  5243. {
  5244. if ( wbem_wcsicmp ( s_Strings_MethodProviderRegistration , t_Variant.bstrVal ) == 0 )
  5245. {
  5246. t_Result = QueryProperties (
  5247. a_Mask ,
  5248. t_ClassObject
  5249. ) ;
  5250. }
  5251. }
  5252. }
  5253. VariantClear ( & t_Variant ) ;
  5254. t_ClassObject->Release () ;
  5255. }
  5256. t_ClassObjectEnum->Release () ;
  5257. }
  5258. else
  5259. {
  5260. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  5261. }
  5262. SysFreeString ( t_Language ) ;
  5263. }
  5264. return t_Result ;
  5265. }
  5266. /******************************************************************************
  5267. *
  5268. * Name:
  5269. *
  5270. *
  5271. * Description:
  5272. *
  5273. *
  5274. *****************************************************************************/
  5275. HRESULT CServerObject_MethodProviderRegistrationV1 :: QueryRepository (
  5276. Enum_PropertyMask a_Mask ,
  5277. IWbemPath *a_Scope,
  5278. LPCWSTR a_ProviderName
  5279. )
  5280. {
  5281. BSTR t_Query = NULL ;
  5282. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  5283. 3 ,
  5284. & t_Query ,
  5285. L"references of {__Win32Provider.Name=\"" ,
  5286. a_ProviderName ,
  5287. L"\"}"
  5288. ) ;
  5289. if ( SUCCEEDED ( t_Result ) )
  5290. {
  5291. t_Result = QueryRepositoryUsingQuery (
  5292. a_Mask ,
  5293. a_Scope,
  5294. t_Query
  5295. ) ;
  5296. SysFreeString ( t_Query ) ;
  5297. }
  5298. return t_Result ;
  5299. }
  5300. /******************************************************************************
  5301. *
  5302. * Name:
  5303. *
  5304. *
  5305. * Description:
  5306. *
  5307. *
  5308. *****************************************************************************/
  5309. HRESULT CServerObject_MethodProviderRegistrationV1 :: QueryRepository (
  5310. Enum_PropertyMask a_Mask ,
  5311. IWbemPath *a_Scope,
  5312. IWbemPath *a_Provider
  5313. )
  5314. {
  5315. BSTR t_ObjectPath = NULL ;
  5316. ULONG t_ObjectPathLength = 0 ;
  5317. HRESULT t_Result = a_Provider->GetText (
  5318. WBEMPATH_GET_RELATIVE_ONLY ,
  5319. & t_ObjectPathLength ,
  5320. NULL
  5321. ) ;
  5322. if ( SUCCEEDED ( t_Result ) )
  5323. {
  5324. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  5325. if ( t_ObjectPath )
  5326. {
  5327. t_Result = a_Provider->GetText (
  5328. WBEMPATH_GET_RELATIVE_ONLY ,
  5329. & t_ObjectPathLength ,
  5330. t_ObjectPath
  5331. ) ;
  5332. if ( SUCCEEDED ( t_Result ) )
  5333. {
  5334. BSTR t_Query = NULL ;
  5335. t_Result = WmiHelper :: ConcatenateStrings (
  5336. 3 ,
  5337. & t_Query ,
  5338. L"references of {" ,
  5339. t_ObjectPath ,
  5340. L"}"
  5341. ) ;
  5342. if ( SUCCEEDED ( t_Result ) )
  5343. {
  5344. t_Result = QueryRepositoryUsingQuery (
  5345. a_Mask ,
  5346. a_Scope,
  5347. t_Query
  5348. ) ;
  5349. SysFreeString ( t_Query ) ;
  5350. }
  5351. }
  5352. SysFreeString ( t_ObjectPath ) ;
  5353. }
  5354. }
  5355. return t_Result ;
  5356. }
  5357. /******************************************************************************
  5358. *
  5359. * Name:
  5360. *
  5361. *
  5362. * Description:
  5363. *
  5364. *
  5365. *****************************************************************************/
  5366. HRESULT CServerObject_MethodProviderRegistrationV1 :: Load (
  5367. Enum_PropertyMask a_Mask ,
  5368. IWbemPath *a_Scope,
  5369. IWbemClassObject *a_Class
  5370. )
  5371. {
  5372. HRESULT t_Result = S_OK ;
  5373. IWbemQualifierSet *t_QualifierObject = NULL ;
  5374. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  5375. if ( SUCCEEDED ( t_Result ) )
  5376. {
  5377. VARIANT t_Variant ;
  5378. VariantInit ( & t_Variant ) ;
  5379. LONG t_Flavour = 0 ;
  5380. t_Result = t_QualifierObject->Get (
  5381. ProviderSubSystem_Common_Globals :: s_Provider ,
  5382. 0 ,
  5383. & t_Variant ,
  5384. & t_Flavour
  5385. ) ;
  5386. if ( SUCCEEDED ( t_Result ) )
  5387. {
  5388. if ( t_Variant.vt == VT_BSTR )
  5389. {
  5390. t_Result = QueryRepository (
  5391. a_Mask ,
  5392. a_Scope ,
  5393. t_Variant.bstrVal
  5394. ) ;
  5395. VariantClear ( & t_Variant ) ;
  5396. }
  5397. }
  5398. t_QualifierObject->Release () ;
  5399. }
  5400. return t_Result ;
  5401. }
  5402. /******************************************************************************
  5403. *
  5404. * Name:
  5405. *
  5406. *
  5407. * Description:
  5408. *
  5409. *
  5410. *****************************************************************************/
  5411. HRESULT CServerObject_MethodProviderRegistrationV1 :: Load (
  5412. Enum_PropertyMask a_Mask ,
  5413. IWbemPath *a_Scope,
  5414. LPCWSTR a_Provider
  5415. )
  5416. {
  5417. HRESULT t_Result = S_OK ;
  5418. t_Result = QueryRepository (
  5419. a_Mask ,
  5420. a_Scope ,
  5421. a_Provider
  5422. ) ;
  5423. return t_Result ;
  5424. }
  5425. /******************************************************************************
  5426. *
  5427. * Name:
  5428. *
  5429. *
  5430. * Description:
  5431. *
  5432. *
  5433. *****************************************************************************/
  5434. HRESULT CServerObject_MethodProviderRegistrationV1 :: Load (
  5435. Enum_PropertyMask a_Mask ,
  5436. IWbemPath *a_Scope,
  5437. IWbemPath *a_Provider
  5438. )
  5439. {
  5440. HRESULT t_Result = S_OK ;
  5441. t_Result = QueryRepository (
  5442. a_Mask ,
  5443. a_Scope ,
  5444. a_Provider
  5445. ) ;
  5446. return t_Result ;
  5447. }
  5448. /******************************************************************************
  5449. *
  5450. * Name:
  5451. *
  5452. *
  5453. * Description:
  5454. *
  5455. *
  5456. *****************************************************************************/
  5457. CServerObject_DynamicPropertyProviderRegistrationV1 :: CServerObject_DynamicPropertyProviderRegistrationV1 () :
  5458. m_Context ( NULL ) ,
  5459. m_Namespace ( NULL ) ,
  5460. m_Repository ( NULL ) ,
  5461. m_SupportsPut ( FALSE ) ,
  5462. m_SupportsGet ( FALSE ) ,
  5463. m_Supported ( FALSE ) ,
  5464. m_Result ( S_OK )
  5465. {
  5466. }
  5467. /******************************************************************************
  5468. *
  5469. * Name:
  5470. *
  5471. *
  5472. * Description:
  5473. *
  5474. *
  5475. *****************************************************************************/
  5476. CServerObject_DynamicPropertyProviderRegistrationV1::~CServerObject_DynamicPropertyProviderRegistrationV1 ()
  5477. {
  5478. if ( m_Context )
  5479. {
  5480. m_Context->Release () ;
  5481. }
  5482. if ( m_Namespace )
  5483. {
  5484. m_Namespace->Release () ;
  5485. }
  5486. if ( m_Repository )
  5487. {
  5488. m_Repository->Release () ;
  5489. }
  5490. }
  5491. /******************************************************************************
  5492. *
  5493. * Name:
  5494. *
  5495. *
  5496. * Description:
  5497. *
  5498. *
  5499. *****************************************************************************/
  5500. ULONG CServerObject_DynamicPropertyProviderRegistrationV1 :: AddRef ()
  5501. {
  5502. return InterlockedIncrement ( & m_ReferenceCount ) ;
  5503. }
  5504. /******************************************************************************
  5505. *
  5506. * Name:
  5507. *
  5508. *
  5509. * Description:
  5510. *
  5511. *
  5512. *****************************************************************************/
  5513. ULONG CServerObject_DynamicPropertyProviderRegistrationV1 :: Release ()
  5514. {
  5515. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  5516. if ( t_ReferenceCount == 0 )
  5517. {
  5518. delete this ;
  5519. }
  5520. return t_ReferenceCount ;
  5521. }
  5522. /******************************************************************************
  5523. *
  5524. * Name:
  5525. *
  5526. *
  5527. * Description:
  5528. *
  5529. *
  5530. *****************************************************************************/
  5531. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: SetContext (
  5532. IWbemContext *a_Context ,
  5533. IWbemPath *a_Namespace ,
  5534. IWbemServices *a_Repository
  5535. )
  5536. {
  5537. HRESULT t_Result = S_OK ;
  5538. m_Context = a_Context ;
  5539. m_Namespace = a_Namespace ;
  5540. m_Repository = a_Repository ;
  5541. if ( m_Context )
  5542. {
  5543. m_Context->AddRef () ;
  5544. }
  5545. if ( m_Namespace )
  5546. {
  5547. m_Namespace->AddRef () ;
  5548. }
  5549. if ( m_Repository )
  5550. {
  5551. m_Repository->AddRef () ;
  5552. }
  5553. return t_Result ;
  5554. }
  5555. /******************************************************************************
  5556. *
  5557. * Name:
  5558. *
  5559. *
  5560. * Description:
  5561. *
  5562. *
  5563. *****************************************************************************/
  5564. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: QueryProperties (
  5565. Enum_PropertyMask a_Mask ,
  5566. IWbemClassObject *a_Object
  5567. )
  5568. {
  5569. HRESULT t_Result = S_OK ;
  5570. m_Supported = TRUE ;
  5571. if ( a_Mask & e_SupportsPut )
  5572. {
  5573. VARIANT t_Variant ;
  5574. VariantInit ( & t_Variant ) ;
  5575. LONG t_VarType = 0 ;
  5576. LONG t_Flavour = 0 ;
  5577. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsPut , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  5578. if ( SUCCEEDED ( t_TempResult ) )
  5579. {
  5580. if ( t_Variant.vt == VT_BOOL )
  5581. {
  5582. m_SupportsPut = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  5583. }
  5584. else if ( t_Variant.vt == VT_NULL )
  5585. {
  5586. m_SupportsPut = FALSE ;
  5587. }
  5588. else
  5589. {
  5590. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  5591. }
  5592. }
  5593. else if (t_TempResult != WBEM_E_NOT_FOUND)
  5594. {
  5595. t_Result = t_TempResult;
  5596. }
  5597. VariantClear ( & t_Variant ) ;
  5598. }
  5599. if ( SUCCEEDED(t_Result) && (a_Mask & e_SupportsGet) )
  5600. {
  5601. VARIANT t_Variant ;
  5602. VariantInit ( & t_Variant ) ;
  5603. LONG t_VarType = 0 ;
  5604. LONG t_Flavour = 0 ;
  5605. HRESULT t_TempResult = a_Object->Get ( s_Strings_SupportsGet , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  5606. if ( SUCCEEDED ( t_TempResult ) )
  5607. {
  5608. if ( t_Variant.vt == VT_BOOL )
  5609. {
  5610. m_SupportsGet = ( t_Variant.boolVal == VARIANT_TRUE ) ? TRUE : FALSE ;
  5611. }
  5612. else if ( t_Variant.vt == VT_NULL )
  5613. {
  5614. m_SupportsGet = FALSE ;
  5615. }
  5616. else
  5617. {
  5618. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  5619. }
  5620. }
  5621. else if (t_TempResult != WBEM_E_NOT_FOUND)
  5622. {
  5623. t_Result = t_TempResult;
  5624. }
  5625. VariantClear ( & t_Variant ) ;
  5626. }
  5627. return t_Result ;
  5628. }
  5629. /******************************************************************************
  5630. *
  5631. * Name:
  5632. *
  5633. *
  5634. * Description:
  5635. *
  5636. *
  5637. *****************************************************************************/
  5638. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  5639. Enum_PropertyMask a_Mask ,
  5640. IWbemPath *a_Scope,
  5641. BSTR a_Query
  5642. )
  5643. {
  5644. HRESULT t_Result = S_OK ;
  5645. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  5646. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  5647. if ( t_Language )
  5648. {
  5649. t_Result = m_Repository->ExecQuery (
  5650. t_Language ,
  5651. a_Query ,
  5652. WBEM_FLAG_FORWARD_ONLY ,
  5653. m_Context ,
  5654. & t_ClassObjectEnum
  5655. ) ;
  5656. if ( SUCCEEDED ( t_Result ) )
  5657. {
  5658. IWbemClassObject *t_ClassObject = NULL ;
  5659. ULONG t_ObjectCount = 0 ;
  5660. t_ClassObjectEnum->Reset () ;
  5661. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  5662. {
  5663. VARIANT t_Variant ;
  5664. VariantInit ( & t_Variant ) ;
  5665. LONG t_VarType = 0 ;
  5666. LONG t_Flavour = 0 ;
  5667. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  5668. if ( SUCCEEDED ( t_Result ) )
  5669. {
  5670. if ( t_Variant.vt == VT_BSTR )
  5671. {
  5672. if ( wbem_wcsicmp ( s_Strings_PropertyProviderRegistration , t_Variant.bstrVal ) == 0 )
  5673. {
  5674. t_Result = QueryProperties (
  5675. a_Mask ,
  5676. t_ClassObject
  5677. ) ;
  5678. }
  5679. }
  5680. }
  5681. VariantClear ( & t_Variant ) ;
  5682. t_ClassObject->Release () ;
  5683. }
  5684. t_ClassObjectEnum->Release () ;
  5685. }
  5686. else
  5687. {
  5688. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  5689. }
  5690. SysFreeString ( t_Language ) ;
  5691. }
  5692. return t_Result ;
  5693. }
  5694. /******************************************************************************
  5695. *
  5696. * Name:
  5697. *
  5698. *
  5699. * Description:
  5700. *
  5701. *
  5702. *****************************************************************************/
  5703. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: QueryRepository (
  5704. Enum_PropertyMask a_Mask ,
  5705. IWbemPath *a_Scope,
  5706. LPCWSTR a_ProviderName
  5707. )
  5708. {
  5709. BSTR t_Query = NULL ;
  5710. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  5711. 3 ,
  5712. & t_Query ,
  5713. L"references of {__Win32Provider.Name=\"" ,
  5714. a_ProviderName ,
  5715. L"\"}"
  5716. ) ;
  5717. if ( SUCCEEDED ( t_Result ) )
  5718. {
  5719. t_Result = QueryRepositoryUsingQuery (
  5720. a_Mask ,
  5721. a_Scope,
  5722. t_Query
  5723. ) ;
  5724. SysFreeString ( t_Query ) ;
  5725. }
  5726. return t_Result ;
  5727. }
  5728. /******************************************************************************
  5729. *
  5730. * Name:
  5731. *
  5732. *
  5733. * Description:
  5734. *
  5735. *
  5736. *****************************************************************************/
  5737. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: QueryRepository (
  5738. Enum_PropertyMask a_Mask ,
  5739. IWbemPath *a_Scope,
  5740. IWbemPath *a_Provider
  5741. )
  5742. {
  5743. BSTR t_ObjectPath = NULL ;
  5744. ULONG t_ObjectPathLength = 0 ;
  5745. HRESULT t_Result = a_Provider->GetText (
  5746. WBEMPATH_GET_RELATIVE_ONLY ,
  5747. & t_ObjectPathLength ,
  5748. NULL
  5749. ) ;
  5750. if ( SUCCEEDED ( t_Result ) )
  5751. {
  5752. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  5753. if ( t_ObjectPath )
  5754. {
  5755. t_Result = a_Provider->GetText (
  5756. WBEMPATH_GET_RELATIVE_ONLY ,
  5757. & t_ObjectPathLength ,
  5758. t_ObjectPath
  5759. ) ;
  5760. if ( SUCCEEDED ( t_Result ) )
  5761. {
  5762. BSTR t_Query = NULL ;
  5763. t_Result = WmiHelper :: ConcatenateStrings (
  5764. 3 ,
  5765. & t_Query ,
  5766. L"references of {" ,
  5767. t_ObjectPath ,
  5768. L"}"
  5769. ) ;
  5770. if ( SUCCEEDED ( t_Result ) )
  5771. {
  5772. t_Result = QueryRepositoryUsingQuery (
  5773. a_Mask ,
  5774. a_Scope,
  5775. t_Query
  5776. ) ;
  5777. SysFreeString ( t_Query ) ;
  5778. }
  5779. }
  5780. SysFreeString ( t_ObjectPath ) ;
  5781. }
  5782. }
  5783. return t_Result ;
  5784. }
  5785. /******************************************************************************
  5786. *
  5787. * Name:
  5788. *
  5789. *
  5790. * Description:
  5791. *
  5792. *
  5793. *****************************************************************************/
  5794. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: Load (
  5795. Enum_PropertyMask a_Mask ,
  5796. IWbemPath *a_Scope,
  5797. IWbemClassObject *a_Class
  5798. )
  5799. {
  5800. HRESULT t_Result = S_OK ;
  5801. IWbemQualifierSet *t_QualifierObject = NULL ;
  5802. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  5803. if ( SUCCEEDED ( t_Result ) )
  5804. {
  5805. VARIANT t_Variant ;
  5806. VariantInit ( & t_Variant ) ;
  5807. LONG t_Flavour = 0 ;
  5808. t_Result = t_QualifierObject->Get (
  5809. ProviderSubSystem_Common_Globals :: s_Provider ,
  5810. 0 ,
  5811. & t_Variant ,
  5812. & t_Flavour
  5813. ) ;
  5814. if ( SUCCEEDED ( t_Result ) )
  5815. {
  5816. if ( t_Variant.vt == VT_BSTR )
  5817. {
  5818. t_Result = QueryRepository (
  5819. a_Mask ,
  5820. a_Scope ,
  5821. t_Variant.bstrVal
  5822. ) ;
  5823. VariantClear ( & t_Variant ) ;
  5824. }
  5825. }
  5826. t_QualifierObject->Release () ;
  5827. }
  5828. return t_Result ;
  5829. }
  5830. /******************************************************************************
  5831. *
  5832. * Name:
  5833. *
  5834. *
  5835. * Description:
  5836. *
  5837. *
  5838. *****************************************************************************/
  5839. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: Load (
  5840. Enum_PropertyMask a_Mask ,
  5841. IWbemPath *a_Scope,
  5842. LPCWSTR a_Provider
  5843. )
  5844. {
  5845. HRESULT t_Result = S_OK ;
  5846. t_Result = QueryRepository (
  5847. a_Mask ,
  5848. a_Scope ,
  5849. a_Provider
  5850. ) ;
  5851. return t_Result ;
  5852. }
  5853. /******************************************************************************
  5854. *
  5855. * Name:
  5856. *
  5857. *
  5858. * Description:
  5859. *
  5860. *
  5861. *****************************************************************************/
  5862. HRESULT CServerObject_DynamicPropertyProviderRegistrationV1 :: Load (
  5863. Enum_PropertyMask a_Mask ,
  5864. IWbemPath *a_Scope,
  5865. IWbemPath *a_Provider
  5866. )
  5867. {
  5868. HRESULT t_Result = S_OK ;
  5869. t_Result = QueryRepository (
  5870. a_Mask ,
  5871. a_Scope ,
  5872. a_Provider
  5873. ) ;
  5874. return t_Result ;
  5875. }
  5876. /******************************************************************************
  5877. *
  5878. * Name:
  5879. *
  5880. *
  5881. * Description:
  5882. *
  5883. *
  5884. *****************************************************************************/
  5885. CServerObject_EventProviderRegistrationV1 :: CServerObject_EventProviderRegistrationV1 () :
  5886. m_Context ( NULL ) ,
  5887. m_Namespace ( NULL ) ,
  5888. m_Repository ( NULL ) ,
  5889. m_Supported ( FALSE ) ,
  5890. m_Result ( S_OK )
  5891. {
  5892. }
  5893. /******************************************************************************
  5894. *
  5895. * Name:
  5896. *
  5897. *
  5898. * Description:
  5899. *
  5900. *
  5901. *****************************************************************************/
  5902. CServerObject_EventProviderRegistrationV1::~CServerObject_EventProviderRegistrationV1 ()
  5903. {
  5904. if ( m_Context )
  5905. {
  5906. m_Context->Release () ;
  5907. }
  5908. if ( m_Namespace )
  5909. {
  5910. m_Namespace->Release () ;
  5911. }
  5912. if ( m_Repository )
  5913. {
  5914. m_Repository->Release () ;
  5915. }
  5916. }
  5917. /******************************************************************************
  5918. *
  5919. * Name:
  5920. *
  5921. *
  5922. * Description:
  5923. *
  5924. *
  5925. *****************************************************************************/
  5926. ULONG CServerObject_EventProviderRegistrationV1 :: AddRef ()
  5927. {
  5928. return InterlockedIncrement ( & m_ReferenceCount ) ;
  5929. }
  5930. /******************************************************************************
  5931. *
  5932. * Name:
  5933. *
  5934. *
  5935. * Description:
  5936. *
  5937. *
  5938. *****************************************************************************/
  5939. ULONG CServerObject_EventProviderRegistrationV1 :: Release ()
  5940. {
  5941. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  5942. if ( t_ReferenceCount == 0 )
  5943. {
  5944. delete this ;
  5945. }
  5946. return t_ReferenceCount ;
  5947. }
  5948. /******************************************************************************
  5949. *
  5950. * Name:
  5951. *
  5952. *
  5953. * Description:
  5954. *
  5955. *
  5956. *****************************************************************************/
  5957. HRESULT CServerObject_EventProviderRegistrationV1 :: SetContext (
  5958. IWbemContext *a_Context ,
  5959. IWbemPath *a_Namespace ,
  5960. IWbemServices *a_Repository
  5961. )
  5962. {
  5963. HRESULT t_Result = S_OK ;
  5964. m_Context = a_Context ;
  5965. m_Namespace = a_Namespace ;
  5966. m_Repository = a_Repository ;
  5967. if ( m_Context )
  5968. {
  5969. m_Context->AddRef () ;
  5970. }
  5971. if ( m_Namespace )
  5972. {
  5973. m_Namespace->AddRef () ;
  5974. }
  5975. if ( m_Repository )
  5976. {
  5977. m_Repository->AddRef () ;
  5978. }
  5979. return t_Result ;
  5980. }
  5981. /******************************************************************************
  5982. *
  5983. * Name:
  5984. *
  5985. *
  5986. * Description:
  5987. *
  5988. *
  5989. *****************************************************************************/
  5990. HRESULT CServerObject_EventProviderRegistrationV1 :: QueryProperties (
  5991. Enum_PropertyMask a_Mask ,
  5992. IWbemClassObject *a_Object
  5993. )
  5994. {
  5995. HRESULT t_Result = S_OK ;
  5996. m_Supported = TRUE ;
  5997. return t_Result ;
  5998. }
  5999. /******************************************************************************
  6000. *
  6001. * Name:
  6002. *
  6003. *
  6004. * Description:
  6005. *
  6006. *
  6007. *****************************************************************************/
  6008. HRESULT CServerObject_EventProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  6009. Enum_PropertyMask a_Mask ,
  6010. IWbemPath *a_Scope,
  6011. BSTR a_Query
  6012. )
  6013. {
  6014. HRESULT t_Result = S_OK ;
  6015. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  6016. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  6017. if ( t_Language )
  6018. {
  6019. t_Result = m_Repository->ExecQuery (
  6020. t_Language ,
  6021. a_Query ,
  6022. WBEM_FLAG_FORWARD_ONLY ,
  6023. m_Context ,
  6024. & t_ClassObjectEnum
  6025. ) ;
  6026. if ( SUCCEEDED ( t_Result ) )
  6027. {
  6028. IWbemClassObject *t_ClassObject = NULL ;
  6029. ULONG t_ObjectCount = 0 ;
  6030. t_ClassObjectEnum->Reset () ;
  6031. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  6032. {
  6033. VARIANT t_Variant ;
  6034. VariantInit ( & t_Variant ) ;
  6035. LONG t_VarType = 0 ;
  6036. LONG t_Flavour = 0 ;
  6037. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  6038. if ( SUCCEEDED ( t_Result ) )
  6039. {
  6040. if ( t_Variant.vt == VT_BSTR )
  6041. {
  6042. if ( wbem_wcsicmp ( s_Strings_EventProviderRegistration , t_Variant.bstrVal ) == 0 )
  6043. {
  6044. t_Result = QueryProperties (
  6045. a_Mask ,
  6046. t_ClassObject
  6047. ) ;
  6048. }
  6049. }
  6050. }
  6051. VariantClear ( & t_Variant ) ;
  6052. t_ClassObject->Release () ;
  6053. }
  6054. t_ClassObjectEnum->Release () ;
  6055. }
  6056. else
  6057. {
  6058. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  6059. }
  6060. SysFreeString ( t_Language ) ;
  6061. }
  6062. return t_Result ;
  6063. }
  6064. /******************************************************************************
  6065. *
  6066. * Name:
  6067. *
  6068. *
  6069. * Description:
  6070. *
  6071. *
  6072. *****************************************************************************/
  6073. HRESULT CServerObject_EventProviderRegistrationV1 :: QueryRepository (
  6074. Enum_PropertyMask a_Mask ,
  6075. IWbemPath *a_Scope,
  6076. LPCWSTR a_ProviderName
  6077. )
  6078. {
  6079. BSTR t_Query = NULL ;
  6080. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  6081. 3 ,
  6082. & t_Query ,
  6083. L"references of {__Win32Provider.Name=\"" ,
  6084. a_ProviderName ,
  6085. L"\"}"
  6086. ) ;
  6087. if ( SUCCEEDED ( t_Result ) )
  6088. {
  6089. t_Result = QueryRepositoryUsingQuery (
  6090. a_Mask ,
  6091. a_Scope,
  6092. t_Query
  6093. ) ;
  6094. SysFreeString ( t_Query ) ;
  6095. }
  6096. return t_Result ;
  6097. }
  6098. /******************************************************************************
  6099. *
  6100. * Name:
  6101. *
  6102. *
  6103. * Description:
  6104. *
  6105. *
  6106. *****************************************************************************/
  6107. HRESULT CServerObject_EventProviderRegistrationV1 :: QueryRepository (
  6108. Enum_PropertyMask a_Mask ,
  6109. IWbemPath *a_Scope,
  6110. IWbemPath *a_Provider
  6111. )
  6112. {
  6113. BSTR t_ObjectPath = NULL ;
  6114. ULONG t_ObjectPathLength = 0 ;
  6115. HRESULT t_Result = a_Provider->GetText (
  6116. WBEMPATH_GET_RELATIVE_ONLY ,
  6117. & t_ObjectPathLength ,
  6118. NULL
  6119. ) ;
  6120. if ( SUCCEEDED ( t_Result ) )
  6121. {
  6122. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  6123. if ( t_ObjectPath )
  6124. {
  6125. t_Result = a_Provider->GetText (
  6126. WBEMPATH_GET_RELATIVE_ONLY ,
  6127. & t_ObjectPathLength ,
  6128. t_ObjectPath
  6129. ) ;
  6130. if ( SUCCEEDED ( t_Result ) )
  6131. {
  6132. BSTR t_Query = NULL ;
  6133. t_Result = WmiHelper :: ConcatenateStrings (
  6134. 3 ,
  6135. & t_Query ,
  6136. L"references of {" ,
  6137. t_ObjectPath ,
  6138. L"}"
  6139. ) ;
  6140. if ( SUCCEEDED ( t_Result ) )
  6141. {
  6142. t_Result = QueryRepositoryUsingQuery (
  6143. a_Mask ,
  6144. a_Scope,
  6145. t_Query
  6146. ) ;
  6147. SysFreeString ( t_Query ) ;
  6148. }
  6149. }
  6150. SysFreeString ( t_ObjectPath ) ;
  6151. }
  6152. }
  6153. return t_Result ;
  6154. }
  6155. /******************************************************************************
  6156. *
  6157. * Name:
  6158. *
  6159. *
  6160. * Description:
  6161. *
  6162. *
  6163. *****************************************************************************/
  6164. HRESULT CServerObject_EventProviderRegistrationV1 :: Load (
  6165. Enum_PropertyMask a_Mask ,
  6166. IWbemPath *a_Scope,
  6167. IWbemClassObject *a_Class
  6168. )
  6169. {
  6170. HRESULT t_Result = S_OK ;
  6171. IWbemQualifierSet *t_QualifierObject = NULL ;
  6172. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  6173. if ( SUCCEEDED ( t_Result ) )
  6174. {
  6175. VARIANT t_Variant ;
  6176. VariantInit ( & t_Variant ) ;
  6177. LONG t_Flavour = 0 ;
  6178. t_Result = t_QualifierObject->Get (
  6179. ProviderSubSystem_Common_Globals :: s_Provider ,
  6180. 0 ,
  6181. & t_Variant ,
  6182. & t_Flavour
  6183. ) ;
  6184. if ( SUCCEEDED ( t_Result ) )
  6185. {
  6186. if ( t_Variant.vt == VT_BSTR )
  6187. {
  6188. t_Result = QueryRepository (
  6189. a_Mask ,
  6190. a_Scope ,
  6191. t_Variant.bstrVal
  6192. ) ;
  6193. VariantClear ( & t_Variant ) ;
  6194. }
  6195. }
  6196. t_QualifierObject->Release () ;
  6197. }
  6198. return t_Result ;
  6199. }
  6200. /******************************************************************************
  6201. *
  6202. * Name:
  6203. *
  6204. *
  6205. * Description:
  6206. *
  6207. *
  6208. *****************************************************************************/
  6209. HRESULT CServerObject_EventProviderRegistrationV1 :: Load (
  6210. Enum_PropertyMask a_Mask ,
  6211. IWbemPath *a_Scope,
  6212. LPCWSTR a_Provider
  6213. )
  6214. {
  6215. HRESULT t_Result = S_OK ;
  6216. t_Result = QueryRepository (
  6217. a_Mask ,
  6218. a_Scope ,
  6219. a_Provider
  6220. ) ;
  6221. return t_Result ;
  6222. }
  6223. /******************************************************************************
  6224. *
  6225. * Name:
  6226. *
  6227. *
  6228. * Description:
  6229. *
  6230. *
  6231. *****************************************************************************/
  6232. HRESULT CServerObject_EventProviderRegistrationV1 :: Load (
  6233. Enum_PropertyMask a_Mask ,
  6234. IWbemPath *a_Scope,
  6235. IWbemPath *a_Provider
  6236. )
  6237. {
  6238. HRESULT t_Result = S_OK ;
  6239. t_Result = QueryRepository (
  6240. a_Mask ,
  6241. a_Scope ,
  6242. a_Provider
  6243. ) ;
  6244. return t_Result ;
  6245. }
  6246. /******************************************************************************
  6247. *
  6248. * Name:
  6249. *
  6250. *
  6251. * Description:
  6252. *
  6253. *
  6254. *****************************************************************************/
  6255. CServerObject_EventConsumerProviderRegistrationV1 :: CServerObject_EventConsumerProviderRegistrationV1 () :
  6256. m_Context ( NULL ) ,
  6257. m_Namespace ( NULL ) ,
  6258. m_Repository ( NULL ) ,
  6259. m_Supported ( FALSE ) ,
  6260. m_Result ( S_OK )
  6261. {
  6262. }
  6263. /******************************************************************************
  6264. *
  6265. * Name:
  6266. *
  6267. *
  6268. * Description:
  6269. *
  6270. *
  6271. *****************************************************************************/
  6272. CServerObject_EventConsumerProviderRegistrationV1::~CServerObject_EventConsumerProviderRegistrationV1 ()
  6273. {
  6274. if ( m_Context )
  6275. {
  6276. m_Context->Release () ;
  6277. }
  6278. if ( m_Namespace )
  6279. {
  6280. m_Namespace->Release () ;
  6281. }
  6282. if ( m_Repository )
  6283. {
  6284. m_Repository->Release () ;
  6285. }
  6286. }
  6287. /******************************************************************************
  6288. *
  6289. * Name:
  6290. *
  6291. *
  6292. * Description:
  6293. *
  6294. *
  6295. *****************************************************************************/
  6296. ULONG CServerObject_EventConsumerProviderRegistrationV1 :: AddRef ()
  6297. {
  6298. return InterlockedIncrement ( & m_ReferenceCount ) ;
  6299. }
  6300. /******************************************************************************
  6301. *
  6302. * Name:
  6303. *
  6304. *
  6305. * Description:
  6306. *
  6307. *
  6308. *****************************************************************************/
  6309. ULONG CServerObject_EventConsumerProviderRegistrationV1 :: Release ()
  6310. {
  6311. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  6312. if ( t_ReferenceCount == 0 )
  6313. {
  6314. delete this ;
  6315. }
  6316. return t_ReferenceCount ;
  6317. }
  6318. /******************************************************************************
  6319. *
  6320. * Name:
  6321. *
  6322. *
  6323. * Description:
  6324. *
  6325. *
  6326. *****************************************************************************/
  6327. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: SetContext (
  6328. IWbemContext *a_Context ,
  6329. IWbemPath *a_Namespace ,
  6330. IWbemServices *a_Repository
  6331. )
  6332. {
  6333. HRESULT t_Result = S_OK ;
  6334. m_Context = a_Context ;
  6335. m_Namespace = a_Namespace ;
  6336. m_Repository = a_Repository ;
  6337. if ( m_Context )
  6338. {
  6339. m_Context->AddRef () ;
  6340. }
  6341. if ( m_Namespace )
  6342. {
  6343. m_Namespace->AddRef () ;
  6344. }
  6345. if ( m_Repository )
  6346. {
  6347. m_Repository->AddRef () ;
  6348. }
  6349. return t_Result ;
  6350. }
  6351. /******************************************************************************
  6352. *
  6353. * Name:
  6354. *
  6355. *
  6356. * Description:
  6357. *
  6358. *
  6359. *****************************************************************************/
  6360. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: QueryProperties (
  6361. Enum_PropertyMask a_Mask ,
  6362. IWbemClassObject *a_Object
  6363. )
  6364. {
  6365. HRESULT t_Result = S_OK ;
  6366. m_Supported = TRUE ;
  6367. return t_Result ;
  6368. }
  6369. /******************************************************************************
  6370. *
  6371. * Name:
  6372. *
  6373. *
  6374. * Description:
  6375. *
  6376. *
  6377. *****************************************************************************/
  6378. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  6379. Enum_PropertyMask a_Mask ,
  6380. IWbemPath *a_Scope,
  6381. BSTR a_Query
  6382. )
  6383. {
  6384. HRESULT t_Result = S_OK ;
  6385. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  6386. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  6387. if ( t_Language )
  6388. {
  6389. t_Result = m_Repository->ExecQuery (
  6390. t_Language ,
  6391. a_Query ,
  6392. WBEM_FLAG_FORWARD_ONLY ,
  6393. m_Context ,
  6394. & t_ClassObjectEnum
  6395. ) ;
  6396. if ( SUCCEEDED ( t_Result ) )
  6397. {
  6398. IWbemClassObject *t_ClassObject = NULL ;
  6399. ULONG t_ObjectCount = 0 ;
  6400. t_ClassObjectEnum->Reset () ;
  6401. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  6402. {
  6403. VARIANT t_Variant ;
  6404. VariantInit ( & t_Variant ) ;
  6405. LONG t_VarType = 0 ;
  6406. LONG t_Flavour = 0 ;
  6407. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  6408. if ( SUCCEEDED ( t_Result ) )
  6409. {
  6410. if ( t_Variant.vt == VT_BSTR )
  6411. {
  6412. if ( wbem_wcsicmp ( s_Strings_EventConsumerProviderRegistration , t_Variant.bstrVal ) == 0 )
  6413. {
  6414. t_Result = QueryProperties (
  6415. a_Mask ,
  6416. t_ClassObject
  6417. ) ;
  6418. }
  6419. }
  6420. }
  6421. VariantClear ( & t_Variant ) ;
  6422. t_ClassObject->Release () ;
  6423. }
  6424. t_ClassObjectEnum->Release () ;
  6425. }
  6426. else
  6427. {
  6428. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  6429. }
  6430. SysFreeString ( t_Language ) ;
  6431. }
  6432. return t_Result ;
  6433. }
  6434. /******************************************************************************
  6435. *
  6436. * Name:
  6437. *
  6438. *
  6439. * Description:
  6440. *
  6441. *
  6442. *****************************************************************************/
  6443. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: QueryRepository (
  6444. Enum_PropertyMask a_Mask ,
  6445. IWbemPath *a_Scope,
  6446. LPCWSTR a_ProviderName
  6447. )
  6448. {
  6449. BSTR t_Query = NULL ;
  6450. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  6451. 3 ,
  6452. & t_Query ,
  6453. L"references of {__Win32Provider.Name=\"" ,
  6454. a_ProviderName ,
  6455. L"\"}"
  6456. ) ;
  6457. if ( SUCCEEDED ( t_Result ) )
  6458. {
  6459. t_Result = QueryRepositoryUsingQuery (
  6460. a_Mask ,
  6461. a_Scope,
  6462. t_Query
  6463. ) ;
  6464. SysFreeString ( t_Query ) ;
  6465. }
  6466. return t_Result ;
  6467. }
  6468. /******************************************************************************
  6469. *
  6470. * Name:
  6471. *
  6472. *
  6473. * Description:
  6474. *
  6475. *
  6476. *****************************************************************************/
  6477. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: QueryRepository (
  6478. Enum_PropertyMask a_Mask ,
  6479. IWbemPath *a_Scope,
  6480. IWbemPath *a_Provider
  6481. )
  6482. {
  6483. BSTR t_ObjectPath = NULL ;
  6484. ULONG t_ObjectPathLength = 0 ;
  6485. HRESULT t_Result = a_Provider->GetText (
  6486. WBEMPATH_GET_RELATIVE_ONLY ,
  6487. & t_ObjectPathLength ,
  6488. NULL
  6489. ) ;
  6490. if ( SUCCEEDED ( t_Result ) )
  6491. {
  6492. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  6493. if ( t_ObjectPath )
  6494. {
  6495. t_Result = a_Provider->GetText (
  6496. WBEMPATH_GET_RELATIVE_ONLY ,
  6497. & t_ObjectPathLength ,
  6498. t_ObjectPath
  6499. ) ;
  6500. if ( SUCCEEDED ( t_Result ) )
  6501. {
  6502. BSTR t_Query = NULL ;
  6503. t_Result = WmiHelper :: ConcatenateStrings (
  6504. 3 ,
  6505. & t_Query ,
  6506. L"references of {" ,
  6507. t_ObjectPath ,
  6508. L"}"
  6509. ) ;
  6510. if ( SUCCEEDED ( t_Result ) )
  6511. {
  6512. t_Result = QueryRepositoryUsingQuery (
  6513. a_Mask ,
  6514. a_Scope,
  6515. t_Query
  6516. ) ;
  6517. SysFreeString ( t_Query ) ;
  6518. }
  6519. }
  6520. SysFreeString ( t_ObjectPath ) ;
  6521. }
  6522. }
  6523. return t_Result ;
  6524. }
  6525. /******************************************************************************
  6526. *
  6527. * Name:
  6528. *
  6529. *
  6530. * Description:
  6531. *
  6532. *
  6533. *****************************************************************************/
  6534. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: Load (
  6535. Enum_PropertyMask a_Mask ,
  6536. IWbemPath *a_Scope,
  6537. IWbemClassObject *a_Class
  6538. )
  6539. {
  6540. HRESULT t_Result = S_OK ;
  6541. IWbemQualifierSet *t_QualifierObject = NULL ;
  6542. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  6543. if ( SUCCEEDED ( t_Result ) )
  6544. {
  6545. VARIANT t_Variant ;
  6546. VariantInit ( & t_Variant ) ;
  6547. LONG t_Flavour = 0 ;
  6548. t_Result = t_QualifierObject->Get (
  6549. ProviderSubSystem_Common_Globals :: s_Provider ,
  6550. 0 ,
  6551. & t_Variant ,
  6552. & t_Flavour
  6553. ) ;
  6554. if ( SUCCEEDED ( t_Result ) )
  6555. {
  6556. if ( t_Variant.vt == VT_BSTR )
  6557. {
  6558. t_Result = QueryRepository (
  6559. a_Mask ,
  6560. a_Scope ,
  6561. t_Variant.bstrVal
  6562. ) ;
  6563. VariantClear ( & t_Variant ) ;
  6564. }
  6565. }
  6566. t_QualifierObject->Release () ;
  6567. }
  6568. return t_Result ;
  6569. }
  6570. /******************************************************************************
  6571. *
  6572. * Name:
  6573. *
  6574. *
  6575. * Description:
  6576. *
  6577. *
  6578. *****************************************************************************/
  6579. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: Load (
  6580. Enum_PropertyMask a_Mask ,
  6581. IWbemPath *a_Scope,
  6582. LPCWSTR a_Provider
  6583. )
  6584. {
  6585. HRESULT t_Result = S_OK ;
  6586. t_Result = QueryRepository (
  6587. a_Mask ,
  6588. a_Scope ,
  6589. a_Provider
  6590. ) ;
  6591. return t_Result ;
  6592. }
  6593. /******************************************************************************
  6594. *
  6595. * Name:
  6596. *
  6597. *
  6598. * Description:
  6599. *
  6600. *
  6601. *****************************************************************************/
  6602. HRESULT CServerObject_EventConsumerProviderRegistrationV1 :: Load (
  6603. Enum_PropertyMask a_Mask ,
  6604. IWbemPath *a_Scope,
  6605. IWbemPath *a_Provider
  6606. )
  6607. {
  6608. HRESULT t_Result = S_OK ;
  6609. t_Result = QueryRepository (
  6610. a_Mask ,
  6611. a_Scope ,
  6612. a_Provider
  6613. ) ;
  6614. return t_Result ;
  6615. }
  6616. /******************************************************************************
  6617. *
  6618. * Name:
  6619. *
  6620. *
  6621. * Description:
  6622. *
  6623. *
  6624. *****************************************************************************/
  6625. CServerObject_ProviderRegistrationV1 :: CServerObject_ProviderRegistrationV1 () :
  6626. m_Context ( NULL ) ,
  6627. m_Namespace ( NULL ) ,
  6628. m_Repository ( NULL ) ,
  6629. m_Result ( S_OK ) ,
  6630. m_ReferenceCount ( 0 )
  6631. {
  6632. }
  6633. /******************************************************************************
  6634. *
  6635. * Name:
  6636. *
  6637. *
  6638. * Description:
  6639. *
  6640. *
  6641. *****************************************************************************/
  6642. CServerObject_ProviderRegistrationV1::~CServerObject_ProviderRegistrationV1 ()
  6643. {
  6644. if ( m_Context )
  6645. {
  6646. m_Context->Release () ;
  6647. }
  6648. if ( m_Namespace )
  6649. {
  6650. m_Namespace->Release () ;
  6651. }
  6652. if ( m_Repository )
  6653. {
  6654. m_Repository->Release () ;
  6655. }
  6656. }
  6657. /******************************************************************************
  6658. *
  6659. * Name:
  6660. *
  6661. *
  6662. * Description:
  6663. *
  6664. *
  6665. *****************************************************************************/
  6666. ULONG CServerObject_ProviderRegistrationV1 :: AddRef ()
  6667. {
  6668. return InterlockedIncrement ( & m_ReferenceCount ) ;
  6669. }
  6670. /******************************************************************************
  6671. *
  6672. * Name:
  6673. *
  6674. *
  6675. * Description:
  6676. *
  6677. *
  6678. *****************************************************************************/
  6679. ULONG CServerObject_ProviderRegistrationV1 :: Release ()
  6680. {
  6681. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  6682. if ( t_ReferenceCount == 0 )
  6683. {
  6684. delete this ;
  6685. }
  6686. return t_ReferenceCount ;
  6687. }
  6688. /******************************************************************************
  6689. *
  6690. * Name:
  6691. *
  6692. *
  6693. * Description:
  6694. *
  6695. *
  6696. *****************************************************************************/
  6697. HRESULT CServerObject_ProviderRegistrationV1 :: SetContext (
  6698. IWbemContext *a_Context ,
  6699. IWbemPath *a_Namespace ,
  6700. IWbemServices *a_Repository
  6701. )
  6702. {
  6703. HRESULT t_Result = S_OK ;
  6704. m_Context = a_Context ;
  6705. m_Namespace = a_Namespace ;
  6706. m_Repository = a_Repository ;
  6707. if ( m_Context )
  6708. {
  6709. m_Context->AddRef () ;
  6710. }
  6711. if ( m_Namespace )
  6712. {
  6713. m_Namespace->AddRef () ;
  6714. }
  6715. if ( m_Repository )
  6716. {
  6717. m_Repository->AddRef () ;
  6718. }
  6719. t_Result = m_ComRegistration.SetContext (
  6720. a_Context ,
  6721. a_Namespace ,
  6722. a_Repository
  6723. ) ;
  6724. return t_Result ;
  6725. }
  6726. /******************************************************************************
  6727. *
  6728. * Name:
  6729. *
  6730. *
  6731. * Description:
  6732. *
  6733. *
  6734. *****************************************************************************/
  6735. HRESULT CServerObject_ProviderRegistrationV1 :: QueryRepositoryUsingQuery (
  6736. Enum_PropertyMask a_Mask ,
  6737. IWbemPath *a_Scope,
  6738. BSTR a_Query
  6739. )
  6740. {
  6741. HRESULT t_Result = S_OK ;
  6742. IEnumWbemClassObject *t_ClassObjectEnum = NULL ;
  6743. BSTR t_Language = SysAllocString ( ProviderSubSystem_Common_Globals :: s_Wql ) ;
  6744. if ( t_Language )
  6745. {
  6746. t_Result = m_Repository->ExecQuery (
  6747. t_Language ,
  6748. a_Query ,
  6749. WBEM_FLAG_FORWARD_ONLY ,
  6750. m_Context ,
  6751. & t_ClassObjectEnum
  6752. ) ;
  6753. if ( SUCCEEDED ( t_Result ) )
  6754. {
  6755. IWbemClassObject *t_ClassObject = NULL ;
  6756. ULONG t_ObjectCount = 0 ;
  6757. t_ClassObjectEnum->Reset () ;
  6758. while ( SUCCEEDED ( t_Result ) && ( t_ClassObjectEnum->Next ( WBEM_INFINITE , 1 , & t_ClassObject , &t_ObjectCount ) == WBEM_NO_ERROR ) )
  6759. {
  6760. VARIANT t_Variant ;
  6761. VariantInit ( & t_Variant ) ;
  6762. LONG t_VarType = 0 ;
  6763. LONG t_Flavour = 0 ;
  6764. t_Result = t_ClassObject->Get ( s_Strings_Class , 0 , & t_Variant , & t_VarType , & t_Flavour ) ;
  6765. if ( SUCCEEDED ( t_Result ) )
  6766. {
  6767. if ( t_Variant.vt == VT_BSTR )
  6768. {
  6769. if ( wbem_wcsicmp ( s_Strings_InstanceProviderRegistration , t_Variant.bstrVal ) == 0 )
  6770. {
  6771. t_Result = m_InstanceProviderRegistration.QueryProperties (
  6772. a_Mask ,
  6773. t_ClassObject
  6774. ) ;
  6775. }
  6776. else if ( wbem_wcsicmp ( s_Strings_ClassProviderRegistration , t_Variant.bstrVal ) == 0 )
  6777. {
  6778. t_Result = m_ClassProviderRegistration.QueryProperties (
  6779. a_Mask ,
  6780. t_ClassObject
  6781. ) ;
  6782. }
  6783. else if ( wbem_wcsicmp ( s_Strings_MethodProviderRegistration , t_Variant.bstrVal ) == 0 )
  6784. {
  6785. t_Result = m_MethodProviderRegistration.QueryProperties (
  6786. a_Mask ,
  6787. t_ClassObject
  6788. ) ;
  6789. }
  6790. else if ( wbem_wcsicmp ( s_Strings_PropertyProviderRegistration , t_Variant.bstrVal ) == 0 )
  6791. {
  6792. t_Result = m_PropertyProviderRegistration.QueryProperties (
  6793. a_Mask ,
  6794. t_ClassObject
  6795. ) ;
  6796. }
  6797. else if ( wbem_wcsicmp ( s_Strings_EventProviderRegistration , t_Variant.bstrVal ) == 0 )
  6798. {
  6799. t_Result = m_EventProviderRegistration.QueryProperties (
  6800. a_Mask ,
  6801. t_ClassObject
  6802. ) ;
  6803. }
  6804. else if ( wbem_wcsicmp ( s_Strings_EventConsumerProviderRegistration , t_Variant.bstrVal ) == 0 )
  6805. {
  6806. t_Result = m_EventConsumerProviderRegistration.QueryProperties (
  6807. a_Mask ,
  6808. t_ClassObject
  6809. ) ;
  6810. }
  6811. }
  6812. }
  6813. VariantClear ( & t_Variant ) ;
  6814. t_ClassObject->Release () ;
  6815. }
  6816. t_ClassObjectEnum->Release () ;
  6817. }
  6818. else
  6819. {
  6820. t_Result = WBEM_E_INVALID_PROVIDER_REGISTRATION ;
  6821. }
  6822. SysFreeString ( t_Language ) ;
  6823. }
  6824. else
  6825. {
  6826. t_Result = WBEM_E_OUT_OF_MEMORY ;
  6827. }
  6828. return t_Result ;
  6829. }
  6830. /******************************************************************************
  6831. *
  6832. * Name:
  6833. *
  6834. *
  6835. * Description:
  6836. *
  6837. *
  6838. *****************************************************************************/
  6839. HRESULT CServerObject_ProviderRegistrationV1 :: QueryRepository (
  6840. Enum_PropertyMask a_Mask ,
  6841. IWbemPath *a_Scope,
  6842. LPCWSTR a_ProviderName
  6843. )
  6844. {
  6845. BSTR t_Query = NULL ;
  6846. HRESULT t_Result = WmiHelper :: ConcatenateStrings (
  6847. 3 ,
  6848. & t_Query ,
  6849. L"references of {__Win32Provider.Name=\"" ,
  6850. a_ProviderName ,
  6851. L"\"}"
  6852. ) ;
  6853. if ( SUCCEEDED ( t_Result ) )
  6854. {
  6855. t_Result = QueryRepositoryUsingQuery (
  6856. a_Mask ,
  6857. a_Scope,
  6858. t_Query
  6859. ) ;
  6860. SysFreeString ( t_Query ) ;
  6861. }
  6862. return t_Result ;
  6863. }
  6864. /******************************************************************************
  6865. *
  6866. * Name:
  6867. *
  6868. *
  6869. * Description:
  6870. *
  6871. *
  6872. *****************************************************************************/
  6873. HRESULT CServerObject_ProviderRegistrationV1 :: QueryRepository (
  6874. Enum_PropertyMask a_Mask ,
  6875. IWbemPath *a_Scope,
  6876. IWbemPath *a_Provider
  6877. )
  6878. {
  6879. BSTR t_ObjectPath = NULL ;
  6880. ULONG t_ObjectPathLength = 0 ;
  6881. HRESULT t_Result = a_Provider->GetText (
  6882. WBEMPATH_GET_RELATIVE_ONLY ,
  6883. & t_ObjectPathLength ,
  6884. NULL
  6885. ) ;
  6886. if ( SUCCEEDED ( t_Result ) )
  6887. {
  6888. t_ObjectPath = SysAllocStringLen ( NULL , t_ObjectPathLength ) ;
  6889. if ( t_ObjectPath )
  6890. {
  6891. t_Result = a_Provider->GetText (
  6892. WBEMPATH_GET_RELATIVE_ONLY ,
  6893. & t_ObjectPathLength ,
  6894. t_ObjectPath
  6895. ) ;
  6896. if ( SUCCEEDED ( t_Result ) )
  6897. {
  6898. BSTR t_Query = NULL ;
  6899. t_Result = WmiHelper :: ConcatenateStrings (
  6900. 3 ,
  6901. & t_Query ,
  6902. L"references of {" ,
  6903. t_ObjectPath ,
  6904. L"}"
  6905. ) ;
  6906. if ( SUCCEEDED ( t_Result ) )
  6907. {
  6908. t_Result = QueryRepositoryUsingQuery (
  6909. a_Mask ,
  6910. a_Scope,
  6911. t_Query
  6912. ) ;
  6913. SysFreeString ( t_Query ) ;
  6914. }
  6915. }
  6916. SysFreeString ( t_ObjectPath ) ;
  6917. }
  6918. }
  6919. return t_Result ;
  6920. }
  6921. /******************************************************************************
  6922. *
  6923. * Name:
  6924. *
  6925. *
  6926. * Description:
  6927. *
  6928. *
  6929. *****************************************************************************/
  6930. HRESULT CServerObject_ProviderRegistrationV1 :: Load (
  6931. Enum_PropertyMask a_Mask ,
  6932. IWbemPath *a_Scope,
  6933. IWbemClassObject *a_Class
  6934. )
  6935. {
  6936. HRESULT t_Result = S_OK ;
  6937. IWbemQualifierSet *t_QualifierObject = NULL ;
  6938. t_Result = a_Class->GetQualifierSet ( & t_QualifierObject ) ;
  6939. if ( SUCCEEDED ( t_Result ) )
  6940. {
  6941. VARIANT t_Variant ;
  6942. VariantInit ( & t_Variant ) ;
  6943. LONG t_Flavour = 0 ;
  6944. t_Result = t_QualifierObject->Get (
  6945. ProviderSubSystem_Common_Globals :: s_Provider ,
  6946. 0 ,
  6947. & t_Variant ,
  6948. & t_Flavour
  6949. ) ;
  6950. if ( SUCCEEDED ( t_Result ) )
  6951. {
  6952. if ( t_Variant.vt == VT_BSTR )
  6953. {
  6954. t_Result = m_ComRegistration.QueryRepository (
  6955. a_Mask ,
  6956. a_Scope ,
  6957. t_Variant.bstrVal
  6958. ) ;
  6959. if ( SUCCEEDED ( t_Result ) )
  6960. {
  6961. t_Result = QueryRepository (
  6962. a_Mask ,
  6963. a_Scope ,
  6964. t_Variant.bstrVal
  6965. ) ;
  6966. }
  6967. VariantClear ( & t_Variant ) ;
  6968. }
  6969. }
  6970. t_QualifierObject->Release () ;
  6971. }
  6972. return t_Result ;
  6973. }
  6974. /******************************************************************************
  6975. *
  6976. * Name:
  6977. *
  6978. *
  6979. * Description:
  6980. *
  6981. *
  6982. *****************************************************************************/
  6983. HRESULT CServerObject_ProviderRegistrationV1 :: Load (
  6984. Enum_PropertyMask a_Mask ,
  6985. IWbemPath *a_Scope,
  6986. LPCWSTR a_Provider
  6987. )
  6988. {
  6989. HRESULT t_Result = S_OK ;
  6990. t_Result = m_ComRegistration.QueryRepository (
  6991. a_Mask ,
  6992. a_Scope ,
  6993. a_Provider
  6994. ) ;
  6995. if ( SUCCEEDED ( t_Result ) )
  6996. {
  6997. t_Result = QueryRepository (
  6998. a_Mask ,
  6999. a_Scope ,
  7000. a_Provider
  7001. ) ;
  7002. }
  7003. return t_Result ;
  7004. }
  7005. /******************************************************************************
  7006. *
  7007. * Name:
  7008. *
  7009. *
  7010. * Description:
  7011. *
  7012. *
  7013. *****************************************************************************/
  7014. HRESULT CServerObject_ProviderRegistrationV1 :: Load (
  7015. Enum_PropertyMask a_Mask ,
  7016. IWbemPath *a_Scope,
  7017. IWbemPath *a_Provider
  7018. )
  7019. {
  7020. HRESULT t_Result = S_OK ;
  7021. t_Result = m_ComRegistration.QueryRepository (
  7022. a_Mask ,
  7023. a_Scope ,
  7024. a_Provider
  7025. ) ;
  7026. if ( SUCCEEDED ( t_Result ) )
  7027. {
  7028. t_Result = QueryRepository (
  7029. a_Mask ,
  7030. a_Scope ,
  7031. a_Provider
  7032. ) ;
  7033. }
  7034. return t_Result ;
  7035. }
  7036. /******************************************************************************
  7037. *
  7038. * Name:
  7039. *
  7040. *
  7041. * Description:
  7042. *
  7043. *
  7044. *****************************************************************************/
  7045. BOOL CServerObject_ProviderRegistrationV1 :: ObjectProvider ()
  7046. {
  7047. BOOL t_Supported = GetClassProviderRegistration ().Supported () ||
  7048. GetInstanceProviderRegistration ().Supported () ||
  7049. GetMethodProviderRegistration ().Supported () ||
  7050. GetPropertyProviderRegistration ().Supported () ;
  7051. return t_Supported ;
  7052. }
  7053. /******************************************************************************
  7054. *
  7055. * Name:
  7056. *
  7057. *
  7058. * Description:
  7059. *
  7060. *
  7061. *****************************************************************************/
  7062. BOOL CServerObject_ProviderRegistrationV1 :: EventProvider ()
  7063. {
  7064. BOOL t_Supported = GetEventConsumerProviderRegistration ().Supported () ||
  7065. GetEventProviderRegistration ().Supported () ;
  7066. return t_Supported ;
  7067. }