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.

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