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.

3346 lines
105 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. STDCLASS.CPP
  5. Abstract:
  6. Class definitions for standard system classes.
  7. History:
  8. raymcc 18-Jul-96 Created.
  9. --*/
  10. #include "precomp.h"
  11. #include "sechelp.h"
  12. #include "StdClass.h"
  13. #include "Reg.h"
  14. #include "CfgMgr.h"
  15. #include <arrtempl.h>
  16. #include <genutils.h>
  17. #include <comdef.h>
  18. #include <autoptr.h>
  19. #define NEW_CLASS_PRECREATE_SIZE 1000
  20. #define NEW_INSTANCE_PRECREATE_SIZE 100
  21. #define NOT_NULL_FLAVOR \
  22. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  23. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS | \
  24. WBEM_FLAVOR_NOT_OVERRIDABLE
  25. #define READ_FLAVOR \
  26. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  27. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS | \
  28. WBEM_FLAVOR_NOT_OVERRIDABLE
  29. #define UNITS_FLAVOR \
  30. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  31. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS | \
  32. WBEM_FLAVOR_NOT_OVERRIDABLE
  33. #define SINGLETON_FLAVOR \
  34. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  35. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS | \
  36. WBEM_FLAVOR_NOT_OVERRIDABLE
  37. #define SYNTAX_FLAVOR \
  38. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  39. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS
  40. #define ABSTRACT_FLAVOR 0 // no propagation
  41. #define ASSOC_FLAVOR \
  42. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  43. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS | \
  44. WBEM_FLAVOR_NOT_OVERRIDABLE
  45. #define VALUES_FLAVOR \
  46. WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | \
  47. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS
  48. void CThisNamespaceClass::Init()
  49. {
  50. CSystemClass System;
  51. System.Init();
  52. HRESULT hRes = CreateDerivedClass(&System);
  53. if (hRes == WBEM_E_OUT_OF_MEMORY)
  54. throw CX_MemoryException();
  55. CVar v(VT_BSTR, L"__thisNAMESPACE");
  56. hRes = SetPropValue(L"__CLASS", &v, 0);
  57. if (hRes == WBEM_E_OUT_OF_MEMORY)
  58. throw CX_MemoryException();
  59. // CVar vNull;
  60. // vNull.SetAsNull();
  61. // hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  62. // if (hRes == WBEM_E_OUT_OF_MEMORY)
  63. // throw CX_MemoryException();
  64. CVar vEmpty;
  65. vEmpty.SetAsNull();
  66. hRes = SetPropValue(L"SECURITY_DESCRIPTOR", &vEmpty, CIM_FLAG_ARRAY | CIM_UINT8);
  67. if (hRes == WBEM_E_OUT_OF_MEMORY)
  68. throw CX_MemoryException();
  69. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  70. hRes = SetQualifier(L"singleton", &vTrue, SINGLETON_FLAVOR);
  71. if (hRes == WBEM_E_OUT_OF_MEMORY)
  72. throw CX_MemoryException();
  73. }
  74. void CThisNamespaceInstance::Init(CThisNamespaceClass* pClass)
  75. {
  76. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  77. throw CX_MemoryException();
  78. }
  79. BOOL GetLocalSystemSid(CVar& v)
  80. {
  81. PSID pSid;
  82. //
  83. // Allocate the SID for the LOCAL SYSTEM account
  84. //
  85. SID_IDENTIFIER_AUTHORITY id = SECURITY_NT_AUTHORITY;
  86. if(AllocateAndInitializeSid( &id, 1, // SEC:REVIEWED 2002-03-22 : Ok
  87. SECURITY_LOCAL_SYSTEM_RID, 0,0,0,0,0,0,0,&pSid))
  88. {
  89. BYTE* pBuffer = (BYTE*)pSid;
  90. //
  91. // Transfer its contents into a CVar
  92. //
  93. CVarVector* pvv = new CVarVector(VT_UI1);
  94. if(pvv == NULL)
  95. {
  96. FreeSid(pSid);
  97. return FALSE;
  98. }
  99. for(int i = 0; i < GetLengthSid(pSid); i++)
  100. pvv->Add(CVar(pBuffer[i]));
  101. FreeSid(pSid);
  102. v.SetVarVector(pvv, TRUE);
  103. return TRUE;
  104. }
  105. else
  106. return FALSE;
  107. }
  108. void CSystemClass::Init()
  109. {
  110. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  111. {
  112. throw CX_MemoryException();
  113. }
  114. CVar v(VT_BSTR, L"__SystemClass");
  115. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  116. if (hRes == WBEM_E_OUT_OF_MEMORY)
  117. throw CX_MemoryException();
  118. CVar vt(VARIANT_TRUE, VT_BOOL);
  119. hRes = SetQualifier(L"abstract", &vt, ABSTRACT_FLAVOR);
  120. if (hRes == WBEM_E_OUT_OF_MEMORY)
  121. throw CX_MemoryException();
  122. }
  123. void CParametersClass::Init()
  124. {
  125. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  126. {
  127. throw CX_MemoryException();
  128. }
  129. CVar v(VT_BSTR, L"__PARAMETERS");
  130. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  131. if (hRes == WBEM_E_OUT_OF_MEMORY)
  132. throw CX_MemoryException();
  133. CVar vt(VARIANT_TRUE, VT_BOOL);
  134. hRes = SetQualifier(L"abstract", &vt, ABSTRACT_FLAVOR);
  135. if (hRes == WBEM_E_OUT_OF_MEMORY)
  136. throw CX_MemoryException();
  137. }
  138. //******************************************************************************
  139. void CGenericClass::Init()
  140. {
  141. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  142. {
  143. throw CX_MemoryException();
  144. }
  145. CVar v(VT_BSTR, L"__GENERIC");
  146. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  147. if (hRes == WBEM_E_OUT_OF_MEMORY)
  148. throw CX_MemoryException();
  149. CVar vt(VARIANT_TRUE, VT_BOOL);
  150. hRes = SetQualifier(L"sample", &vt, ABSTRACT_FLAVOR);
  151. if (hRes == WBEM_E_OUT_OF_MEMORY)
  152. throw CX_MemoryException();
  153. }
  154. //******************************************************************************
  155. void CNotifyStatusClass::Init()
  156. {
  157. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  158. {
  159. throw CX_MemoryException();
  160. }
  161. CVar v(VT_BSTR, L"__NotifyStatus");
  162. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  163. if (hRes == WBEM_E_OUT_OF_MEMORY)
  164. throw CX_MemoryException();
  165. //CVar vs((LONG) 0);
  166. CVar vs;
  167. vs.SetAsNull();
  168. hRes = SetPropValue(L"StatusCode", &vs, CIM_UINT32);
  169. if (hRes == WBEM_E_OUT_OF_MEMORY)
  170. throw CX_MemoryException();
  171. CVar vt(VARIANT_TRUE, VT_BOOL);
  172. // all error classes are like that!
  173. hRes = SetQualifier(L"abstract", &vt, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
  174. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS |
  175. WBEM_FLAVOR_NOT_OVERRIDABLE);
  176. if (hRes == WBEM_E_OUT_OF_MEMORY)
  177. throw CX_MemoryException();
  178. }
  179. //******************************************************************************
  180. void CNamespaceClass::Init()
  181. {
  182. CSystemClass System;
  183. System.Init();
  184. HRESULT hRes = CreateDerivedClass(&System);
  185. if (hRes == WBEM_E_OUT_OF_MEMORY)
  186. throw CX_MemoryException();
  187. CVar v(VT_BSTR, L"__NAMESPACE");
  188. hRes = SetPropValue(L"__CLASS", &v, 0);
  189. if (hRes == WBEM_E_OUT_OF_MEMORY)
  190. throw CX_MemoryException();
  191. CVar vNull;
  192. vNull.SetAsNull();
  193. hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  194. if (hRes == WBEM_E_OUT_OF_MEMORY)
  195. throw CX_MemoryException();
  196. // Mark name as 'key'.
  197. // ===================
  198. CVar vb(VARIANT_TRUE, VT_BOOL);
  199. hRes = SetPropQualifier(L"Name", L"key", 0, &vb);
  200. if (hRes == WBEM_E_OUT_OF_MEMORY)
  201. throw CX_MemoryException();
  202. }
  203. CNamespaceClass* CNamespace::mstatic_pClass = NULL;
  204. CStaticCritSec CNamespace::mstatic_cs;
  205. CNamespace::__CleanUp CNamespace::cleanup;
  206. void CNamespace::Init(LPWSTR pName)
  207. {
  208. CInCritSec local_lock (&mstatic_cs); // SEC:REVIEWED 2002-03-22 : Assumes entry
  209. if(mstatic_pClass == NULL)
  210. {
  211. wmilib::auto_ptr<CNamespaceClass> p(new CNamespaceClass);
  212. if (p.get() == 0)
  213. {
  214. throw CX_MemoryException();
  215. }
  216. p->Init();
  217. mstatic_pClass = p.release();
  218. }
  219. if (FAILED(InitNew(mstatic_pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  220. throw CX_MemoryException();
  221. CVar vk(VT_BSTR, pName);
  222. HRESULT hRes = SetPropValue(L"Name", &vk, 0);
  223. if (hRes == WBEM_E_OUT_OF_MEMORY)
  224. throw CX_MemoryException();
  225. }
  226. //******************************************************************************
  227. void CProviderClass::Init()
  228. {
  229. CSystemClass System;
  230. System.Init();
  231. HRESULT hRes = CreateDerivedClass(&System);
  232. if (hRes == WBEM_E_OUT_OF_MEMORY)
  233. throw CX_MemoryException();
  234. CVar v(VT_BSTR, L"__Provider");
  235. hRes = SetPropValue(L"__CLASS", &v, 0);
  236. if (hRes == WBEM_E_OUT_OF_MEMORY)
  237. throw CX_MemoryException();
  238. CVar vNull;
  239. vNull.SetAsNull();
  240. hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  241. if (hRes == WBEM_E_OUT_OF_MEMORY)
  242. throw CX_MemoryException();
  243. CVar vk(VARIANT_TRUE, VT_BOOL);
  244. hRes = SetPropQualifier(L"Name", L"key", 0, &vk);
  245. if (hRes == WBEM_E_OUT_OF_MEMORY)
  246. throw CX_MemoryException();
  247. hRes = SetQualifier(L"abstract", &vk, ABSTRACT_FLAVOR);
  248. if (hRes == WBEM_E_OUT_OF_MEMORY)
  249. throw CX_MemoryException();
  250. }
  251. void CWin32ProviderClass::Init()
  252. {
  253. CProviderClass ProviderClass;
  254. ProviderClass.Init();
  255. HRESULT hRes = CreateDerivedClass(&ProviderClass);
  256. if (hRes == WBEM_E_OUT_OF_MEMORY)
  257. throw CX_MemoryException();
  258. CVar v(VT_BSTR, L"__Win32Provider");
  259. hRes = SetPropValue(L"__CLASS", &v, 0);
  260. if (hRes == WBEM_E_OUT_OF_MEMORY)
  261. throw CX_MemoryException();
  262. CVar vNull;
  263. vNull.SetAsNull();
  264. hRes = SetPropValue(L"CLSID", &vNull, CIM_STRING);
  265. if (hRes == WBEM_E_OUT_OF_MEMORY)
  266. throw CX_MemoryException();
  267. hRes = SetPropValue(L"ClientLoadableCLSID", &vNull, CIM_STRING);
  268. if (hRes == WBEM_E_OUT_OF_MEMORY)
  269. throw CX_MemoryException();
  270. hRes = SetPropValue(L"DefaultMachineName", &vNull, CIM_STRING);
  271. if (hRes == WBEM_E_OUT_OF_MEMORY)
  272. throw CX_MemoryException();
  273. hRes = SetPropValue(L"UnloadTimeout", &vNull, CIM_DATETIME);
  274. if (hRes == WBEM_E_OUT_OF_MEMORY)
  275. throw CX_MemoryException();
  276. hRes = SetPropValue(L"InitializeAsAdminFirst", &vNull, CIM_BOOLEAN);
  277. if (hRes == WBEM_E_OUT_OF_MEMORY)
  278. throw CX_MemoryException();
  279. hRes = SetPropValue(L"Version", &vNull, CIM_UINT32);
  280. if (hRes == WBEM_E_OUT_OF_MEMORY)
  281. throw CX_MemoryException();
  282. CVar vZero;
  283. vZero.SetLong(0);
  284. hRes = SetPropValue(L"ImpersonationLevel", &vZero, CIM_SINT32);
  285. if (hRes == WBEM_E_OUT_OF_MEMORY)
  286. throw CX_MemoryException();
  287. hRes = SetPropValue(L"InitializationReentrancy", &vZero, CIM_SINT32);
  288. if (hRes == WBEM_E_OUT_OF_MEMORY)
  289. throw CX_MemoryException();
  290. CVar vFalse(VARIANT_FALSE, VT_BOOL);
  291. hRes = SetPropValue(L"PerUserInitialization", &vFalse, CIM_BOOLEAN);
  292. if (hRes == WBEM_E_OUT_OF_MEMORY)
  293. throw CX_MemoryException();
  294. hRes = SetPropValue(L"PerLocaleInitialization", &vFalse, CIM_BOOLEAN);
  295. if (hRes == WBEM_E_OUT_OF_MEMORY)
  296. throw CX_MemoryException();
  297. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  298. hRes = SetPropValue(L"Pure", &vTrue, CIM_BOOLEAN);
  299. if (hRes == WBEM_E_OUT_OF_MEMORY)
  300. throw CX_MemoryException();
  301. CVar vInterval(VT_BSTR, L"interval");
  302. hRes = SetPropQualifier(L"UnloadTimeout", L"SUBTYPE", SYNTAX_FLAVOR, &vInterval);
  303. if (hRes == WBEM_E_OUT_OF_MEMORY)
  304. throw CX_MemoryException();
  305. CVar vProtectedClsid(VT_BSTR, L"CLSID");
  306. CVar vProtectedNamespace(VT_BSTR, L"Namespace");
  307. CVar vProtectedComObject(VT_BSTR, L"COM Object");
  308. CVarVector *pvvReentrancy = new CVarVector(VT_BSTR);
  309. if (pvvReentrancy == 0)
  310. throw CX_MemoryException();
  311. if (pvvReentrancy->Add(vProtectedClsid) != CVarVector::no_error)
  312. throw CX_MemoryException();
  313. if (pvvReentrancy->Add(vProtectedNamespace) != CVarVector::no_error)
  314. throw CX_MemoryException();
  315. if (pvvReentrancy->Add(vProtectedComObject) != CVarVector::no_error)
  316. throw CX_MemoryException();
  317. CVar vReentrancy(pvvReentrancy, TRUE);
  318. hRes = SetPropQualifier(L"InitializationReentrancy", L"Values",
  319. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS, &vReentrancy);
  320. if (hRes == WBEM_E_OUT_OF_MEMORY)
  321. throw CX_MemoryException();
  322. CVar vLevelNone(VT_BSTR, L"None");
  323. CVarVector* pvvLevel = new CVarVector(VT_BSTR);
  324. if (pvvLevel == 0)
  325. throw CX_MemoryException();
  326. if (pvvLevel->Add(vLevelNone) != CVarVector::no_error)
  327. throw CX_MemoryException();
  328. CVar vLevel(pvvLevel, TRUE);
  329. hRes = SetPropQualifier(L"ImpersonationLevel", L"Values",
  330. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS, &vLevel);
  331. if (hRes == WBEM_E_OUT_OF_MEMORY)
  332. throw CX_MemoryException();
  333. hRes = SetPropValue(L"HostingModel", &vNull, CIM_STRING);
  334. if (hRes == WBEM_E_OUT_OF_MEMORY)
  335. throw CX_MemoryException();
  336. CVar vHosting_WmiCore (VT_BSTR, L"WmiCore");
  337. CVar vHosting_WmiCoreSelfHost (VT_BSTR, L"WmiCoreOrSelfHost");
  338. CVar vHosting_SelfHost (VT_BSTR, L"SelfHost");
  339. CVar vHosting_Decoupled (VT_BSTR, L"Decoupled");
  340. CVar vHosting_LocalSystemHost (VT_BSTR, L"LocalSystemHost");
  341. CVar vHosting_LocalSystemHostOrSelfHost (VT_BSTR, L"LocalSystemHostOrSelfHost");
  342. CVar vHosting_LocalServiceHost (VT_BSTR, L"LocalServiceHost");
  343. CVar vHosting_NetworkServiceHost (VT_BSTR, L"NetworkServiceHost");
  344. CVar vHosting_UserHost (VT_BSTR, L"UserHost");
  345. CVarVector *pvvHostingModels = new CVarVector(VT_BSTR);
  346. if (pvvHostingModels == 0)
  347. throw CX_MemoryException();
  348. if (pvvLevel->Add(vHosting_WmiCore) != CVarVector::no_error)
  349. throw CX_MemoryException();
  350. if (pvvLevel->Add(vHosting_WmiCoreSelfHost) != CVarVector::no_error)
  351. throw CX_MemoryException();
  352. if (pvvLevel->Add(vHosting_SelfHost) != CVarVector::no_error)
  353. throw CX_MemoryException();
  354. if (pvvLevel->Add(vHosting_Decoupled) != CVarVector::no_error)
  355. throw CX_MemoryException();
  356. if (pvvLevel->Add(vHosting_LocalSystemHost) != CVarVector::no_error)
  357. throw CX_MemoryException();
  358. if (pvvLevel->Add(vHosting_LocalSystemHostOrSelfHost) != CVarVector::no_error)
  359. throw CX_MemoryException();
  360. if (pvvLevel->Add(vHosting_LocalServiceHost) != CVarVector::no_error)
  361. throw CX_MemoryException();
  362. if (pvvLevel->Add(vHosting_NetworkServiceHost) != CVarVector::no_error)
  363. throw CX_MemoryException();
  364. if (pvvLevel->Add(vHosting_UserHost) != CVarVector::no_error)
  365. throw CX_MemoryException();
  366. CVar vHostingModels(pvvHostingModels, TRUE);
  367. hRes = SetPropQualifier(L"HostingModel", L"Values",
  368. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS, &vHostingModels);
  369. if (hRes == WBEM_E_OUT_OF_MEMORY)
  370. throw CX_MemoryException();
  371. hRes = SetPropValue(L"Concurrency", &vNull, CIM_SINT32);
  372. if (hRes == WBEM_E_OUT_OF_MEMORY)
  373. throw CX_MemoryException();
  374. hRes = SetPropValue(L"SupportsSendStatus", &vNull, CIM_BOOLEAN);
  375. if (hRes == WBEM_E_OUT_OF_MEMORY)
  376. throw CX_MemoryException();
  377. hRes = SetPropValue(L"SupportsExplicitShutdown", &vNull, CIM_BOOLEAN);
  378. if (hRes == WBEM_E_OUT_OF_MEMORY)
  379. throw CX_MemoryException();
  380. hRes = SetPropValue(L"SupportsExtendedStatus", &vNull, CIM_BOOLEAN);
  381. if (hRes == WBEM_E_OUT_OF_MEMORY)
  382. throw CX_MemoryException();
  383. hRes = SetPropValue(L"SupportsThrottling", &vNull, CIM_BOOLEAN);
  384. if (hRes == WBEM_E_OUT_OF_MEMORY)
  385. throw CX_MemoryException();
  386. hRes = SetPropValue(L"OperationTimeoutInterval", &vNull, CIM_DATETIME);
  387. if (hRes == WBEM_E_OUT_OF_MEMORY)
  388. throw CX_MemoryException();
  389. hRes = SetPropQualifier(L"OperationTimeoutInterval", L"SUBTYPE", SYNTAX_FLAVOR, &vInterval);
  390. if (hRes == WBEM_E_OUT_OF_MEMORY)
  391. throw CX_MemoryException();
  392. hRes = SetPropValue(L"InitializationTimeoutInterval", &vNull, CIM_DATETIME);
  393. if (hRes == WBEM_E_OUT_OF_MEMORY)
  394. throw CX_MemoryException();
  395. hRes = SetPropQualifier(L"InitializationTimeoutInterval", L"SUBTYPE", SYNTAX_FLAVOR, &vInterval);
  396. if (hRes == WBEM_E_OUT_OF_MEMORY)
  397. throw CX_MemoryException();
  398. hRes = SetPropValue(L"SupportsQuotas", &vNull, CIM_BOOLEAN);
  399. if (hRes == WBEM_E_OUT_OF_MEMORY)
  400. throw CX_MemoryException();
  401. hRes = SetPropValue(L"Enabled", &vNull, CIM_BOOLEAN);
  402. if (hRes == WBEM_E_OUT_OF_MEMORY)
  403. throw CX_MemoryException();
  404. hRes = SetPropValue(L"SupportsShutdown", &vNull, CIM_BOOLEAN);
  405. if (hRes == WBEM_E_OUT_OF_MEMORY)
  406. throw CX_MemoryException();
  407. hRes = SetPropValue(L"SecurityDescriptor", &vNull, CIM_STRING);
  408. if (hRes == WBEM_E_OUT_OF_MEMORY)
  409. throw CX_MemoryException();
  410. }
  411. void CProviderRegistrationClass::Init()
  412. {
  413. CSystemClass System;
  414. System.Init();
  415. HRESULT hRes =CreateDerivedClass(&System);
  416. if (hRes == WBEM_E_OUT_OF_MEMORY)
  417. throw CX_MemoryException();
  418. CVar v(VT_BSTR, L"__ProviderRegistration");
  419. hRes = SetPropValue(L"__CLASS", &v, 0);
  420. if (hRes == WBEM_E_OUT_OF_MEMORY)
  421. throw CX_MemoryException();
  422. CVar vNull;
  423. vNull.SetAsNull();
  424. hRes = SetPropValue(L"Provider", &vNull, CIM_REFERENCE);
  425. if (hRes == WBEM_E_OUT_OF_MEMORY)
  426. throw CX_MemoryException();
  427. CVar vCimtype(VT_BSTR, L"ref:__Provider");
  428. hRes = SetPropQualifier(L"Provider", L"cimtype", 0, &vCimtype);
  429. if (hRes == WBEM_E_OUT_OF_MEMORY)
  430. throw CX_MemoryException();
  431. CVar vk(VARIANT_TRUE, VT_BOOL);
  432. hRes = SetQualifier(L"abstract", &vk, ABSTRACT_FLAVOR);
  433. if (hRes == WBEM_E_OUT_OF_MEMORY)
  434. throw CX_MemoryException();
  435. };
  436. void CObjectProviderRegistrationClass::Init()
  437. {
  438. CProviderRegistrationClass RegClass;
  439. RegClass.Init();
  440. HRESULT hRes = CreateDerivedClass(&RegClass);
  441. if (hRes == WBEM_E_OUT_OF_MEMORY)
  442. throw CX_MemoryException();
  443. CVar v(VT_BSTR, L"__ObjectProviderRegistration");
  444. hRes = SetPropValue(L"__CLASS", &v, 0);
  445. if (hRes == WBEM_E_OUT_OF_MEMORY)
  446. throw CX_MemoryException();
  447. CVar vNull;
  448. vNull.SetAsNull();
  449. CVar vFalse(VARIANT_FALSE, VT_BOOL);
  450. hRes = SetPropValue(L"SupportsPut", &vFalse, CIM_BOOLEAN);
  451. if (hRes == WBEM_E_OUT_OF_MEMORY)
  452. throw CX_MemoryException();
  453. hRes = SetPropValue(L"SupportsGet", &vFalse, CIM_BOOLEAN);
  454. if (hRes == WBEM_E_OUT_OF_MEMORY)
  455. throw CX_MemoryException();
  456. hRes = SetPropValue(L"SupportsDelete", &vFalse, CIM_BOOLEAN);
  457. if (hRes == WBEM_E_OUT_OF_MEMORY)
  458. throw CX_MemoryException();
  459. hRes = SetPropValue(L"SupportsEnumeration", &vFalse, CIM_BOOLEAN);
  460. if (hRes == WBEM_E_OUT_OF_MEMORY)
  461. throw CX_MemoryException();
  462. hRes = SetPropValue(L"QuerySupportLevels", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  463. if (hRes == WBEM_E_OUT_OF_MEMORY)
  464. throw CX_MemoryException();
  465. CVar vZero;
  466. vZero.SetLong(0);
  467. hRes = SetPropValue(L"InteractionType", &vZero, CIM_SINT32);
  468. if (hRes == WBEM_E_OUT_OF_MEMORY)
  469. throw CX_MemoryException();
  470. CVar vk(VARIANT_TRUE, VT_BOOL);
  471. hRes = SetQualifier(L"abstract", &vk, ABSTRACT_FLAVOR);
  472. CVar vPull(VT_BSTR, L"Pull");
  473. CVar vPush(VT_BSTR, L"Push");
  474. CVar vPushVerify(VT_BSTR, L"PushVerify");
  475. CVarVector* pvvInteraction = new CVarVector(VT_BSTR);
  476. if (pvvInteraction == 0)
  477. throw CX_MemoryException();
  478. if (pvvInteraction->Add(vPull) != CVarVector::no_error)
  479. throw CX_MemoryException();
  480. if (pvvInteraction->Add(vPush) != CVarVector::no_error)
  481. throw CX_MemoryException();
  482. if (pvvInteraction->Add(vPushVerify) != CVarVector::no_error)
  483. throw CX_MemoryException();
  484. CVar vInteraction(pvvInteraction, TRUE);
  485. hRes = SetPropQualifier(L"InteractionType", L"Values",
  486. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS, &vInteraction);
  487. if (hRes == WBEM_E_OUT_OF_MEMORY)
  488. throw CX_MemoryException();
  489. CVar vUnarySelect(VT_BSTR, L"WQL:UnarySelect");
  490. CVar vProvDef(VT_BSTR, L"WQL:V1ProviderDefined");
  491. CVar vAssoc(VT_BSTR, L"WQL:Associators");
  492. CVar vRef(VT_BSTR, L"WQL:References");
  493. CVarVector* pvvQueries = new CVarVector(VT_BSTR);
  494. if (pvvQueries == 0)
  495. throw CX_MemoryException();
  496. if (pvvQueries->Add(vUnarySelect) != CVarVector::no_error)
  497. throw CX_MemoryException();
  498. if (pvvQueries->Add(vRef) != CVarVector::no_error)
  499. throw CX_MemoryException();
  500. if (pvvQueries->Add(vAssoc) != CVarVector::no_error)
  501. throw CX_MemoryException();
  502. if (pvvQueries->Add(vProvDef) != CVarVector::no_error)
  503. throw CX_MemoryException();
  504. CVar vQueries(pvvQueries, TRUE);
  505. hRes = SetPropQualifier(L"QuerySupportLevels", L"ValueMap",
  506. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS, &vQueries);
  507. if (hRes == WBEM_E_OUT_OF_MEMORY)
  508. throw CX_MemoryException();
  509. hRes = SetPropValue(L"SupportsBatching", &vNull, CIM_BOOLEAN);
  510. if (hRes == WBEM_E_OUT_OF_MEMORY)
  511. throw CX_MemoryException();
  512. hRes = SetPropValue(L"SupportsTransactions", &vNull, CIM_BOOLEAN);
  513. if (hRes == WBEM_E_OUT_OF_MEMORY)
  514. throw CX_MemoryException();
  515. }
  516. void CClassProviderRegistrationClass::Init()
  517. {
  518. CObjectProviderRegistrationClass ObjectClass;
  519. ObjectClass.Init();
  520. HRESULT hRes = CreateDerivedClass(&ObjectClass);
  521. if (hRes == WBEM_E_OUT_OF_MEMORY)
  522. throw CX_MemoryException();
  523. CVar v(VT_BSTR, L"__ClassProviderRegistration");
  524. hRes = SetPropValue(L"__CLASS", &v, 0);
  525. if (hRes == WBEM_E_OUT_OF_MEMORY)
  526. throw CX_MemoryException();
  527. CVar vNull;
  528. vNull.SetAsNull();
  529. hRes = SetPropValue(L"Version", &vNull, CIM_UINT32);
  530. if (hRes == WBEM_E_OUT_OF_MEMORY)
  531. throw CX_MemoryException();
  532. hRes = SetPropValue(L"ResultSetQueries", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  533. if (hRes == WBEM_E_OUT_OF_MEMORY)
  534. throw CX_MemoryException();
  535. hRes = SetPropValue(L"ReferencedSetQueries", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  536. if (hRes == WBEM_E_OUT_OF_MEMORY)
  537. throw CX_MemoryException();
  538. hRes = SetPropValue(L"UnsupportedQueries", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  539. if (hRes == WBEM_E_OUT_OF_MEMORY)
  540. throw CX_MemoryException();
  541. CVar vk(VARIANT_TRUE, VT_BOOL);
  542. hRes = SetPropQualifier(L"Provider", L"key", 0, &vk);
  543. if (hRes == WBEM_E_OUT_OF_MEMORY)
  544. throw CX_MemoryException();
  545. hRes = SetPropValue(L"CacheRefreshInterval", &vNull, CIM_DATETIME);
  546. if (hRes == WBEM_E_OUT_OF_MEMORY)
  547. throw CX_MemoryException();
  548. CVar vInterval(VT_BSTR, L"interval");
  549. hRes = SetPropQualifier(L"CacheRefreshInterval", L"SUBTYPE", SYNTAX_FLAVOR, &vInterval);
  550. if (hRes == WBEM_E_OUT_OF_MEMORY)
  551. throw CX_MemoryException();
  552. hRes = SetPropValue(L"PerUserSchema", &vNull, CIM_BOOLEAN);
  553. if (hRes == WBEM_E_OUT_OF_MEMORY)
  554. throw CX_MemoryException();
  555. hRes = SetPropValue(L"ReSynchroniseOnNamespaceOpen", &vNull, CIM_BOOLEAN );
  556. if (hRes == WBEM_E_OUT_OF_MEMORY)
  557. throw CX_MemoryException();
  558. }
  559. void CInstanceProviderRegistrationClass::Init()
  560. {
  561. CObjectProviderRegistrationClass ObjectClass;
  562. ObjectClass.Init();
  563. HRESULT hRes = CreateDerivedClass(&ObjectClass);
  564. if (hRes == WBEM_E_OUT_OF_MEMORY)
  565. throw CX_MemoryException();
  566. CVar v(VT_BSTR, L"__InstanceProviderRegistration");
  567. hRes = SetPropValue(L"__CLASS", &v, 0);
  568. if (hRes == WBEM_E_OUT_OF_MEMORY)
  569. throw CX_MemoryException();
  570. CVar vk(VARIANT_TRUE, VT_BOOL);
  571. hRes = SetPropQualifier(L"Provider", L"key", 0, &vk);
  572. if (hRes == WBEM_E_OUT_OF_MEMORY)
  573. throw CX_MemoryException();
  574. }
  575. void CPropertyProviderRegistrationClass::Init()
  576. {
  577. CProviderRegistrationClass ProvReg;
  578. ProvReg.Init();
  579. HRESULT hRes = CreateDerivedClass(&ProvReg);
  580. if (hRes == WBEM_E_OUT_OF_MEMORY)
  581. throw CX_MemoryException();
  582. CVar v(VT_BSTR, L"__PropertyProviderRegistration");
  583. hRes = SetPropValue(L"__CLASS", &v, 0);
  584. if (hRes == WBEM_E_OUT_OF_MEMORY)
  585. throw CX_MemoryException();
  586. CVar vFalse(VARIANT_FALSE, VT_BOOL);
  587. hRes = SetPropValue(L"SupportsPut", &vFalse, CIM_BOOLEAN);
  588. if (hRes == WBEM_E_OUT_OF_MEMORY)
  589. throw CX_MemoryException();
  590. hRes = SetPropValue(L"SupportsGet", &vFalse, CIM_BOOLEAN);
  591. if (hRes == WBEM_E_OUT_OF_MEMORY)
  592. throw CX_MemoryException();
  593. CVar vk(VARIANT_TRUE, VT_BOOL);
  594. hRes = SetPropQualifier(L"Provider", L"key", 0, &vk);
  595. if (hRes == WBEM_E_OUT_OF_MEMORY)
  596. throw CX_MemoryException();
  597. }
  598. void CMethodProviderRegistrationClass::Init()
  599. {
  600. CProviderRegistrationClass ProvReg;
  601. ProvReg.Init();
  602. HRESULT hRes = CreateDerivedClass(&ProvReg);
  603. if (hRes == WBEM_E_OUT_OF_MEMORY)
  604. throw CX_MemoryException();
  605. CVar v(VT_BSTR, L"__MethodProviderRegistration");
  606. hRes = SetPropValue(L"__CLASS", &v, 0);
  607. if (hRes == WBEM_E_OUT_OF_MEMORY)
  608. throw CX_MemoryException();
  609. CVar vk(VARIANT_TRUE, VT_BOOL);
  610. hRes = SetPropQualifier(L"Provider", L"key", 0, &vk);
  611. if (hRes == WBEM_E_OUT_OF_MEMORY)
  612. throw CX_MemoryException();
  613. }
  614. void CEventProviderRegistrationClass::Init()
  615. {
  616. CProviderRegistrationClass ProvReg;
  617. ProvReg.Init();
  618. HRESULT hRes = CreateDerivedClass(&ProvReg);
  619. if (hRes == WBEM_E_OUT_OF_MEMORY)
  620. throw CX_MemoryException();
  621. CVar v(VT_BSTR, L"__EventProviderRegistration");
  622. hRes = SetPropValue(L"__CLASS", &v, 0);
  623. if (hRes == WBEM_E_OUT_OF_MEMORY)
  624. throw CX_MemoryException();
  625. CVar vk(VARIANT_TRUE, VT_BOOL);
  626. hRes = SetPropQualifier(L"Provider", L"key", 0, &vk);
  627. if (hRes == WBEM_E_OUT_OF_MEMORY)
  628. throw CX_MemoryException();
  629. CVar vNull;
  630. vNull.SetAsNull();
  631. hRes = SetPropValue(L"EventQueryList", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  632. if (hRes == WBEM_E_OUT_OF_MEMORY)
  633. throw CX_MemoryException();
  634. }
  635. void CEventConsumerProviderRegistrationClass::Init()
  636. {
  637. CProviderRegistrationClass ProvReg;
  638. ProvReg.Init();
  639. HRESULT hRes = CreateDerivedClass(&ProvReg);
  640. if (hRes == WBEM_E_OUT_OF_MEMORY)
  641. throw CX_MemoryException();
  642. CVar v(VT_BSTR, L"__EventConsumerProviderRegistration");
  643. hRes = SetPropValue(L"__CLASS", &v, 0);
  644. if (hRes == WBEM_E_OUT_OF_MEMORY)
  645. throw CX_MemoryException();
  646. CVar vProp;
  647. vProp.SetAsNull();
  648. hRes = SetPropValue(L"ConsumerClassNames", &vProp, CIM_STRING | CIM_FLAG_ARRAY);
  649. if (hRes == WBEM_E_OUT_OF_MEMORY)
  650. throw CX_MemoryException();
  651. CVar vk(VARIANT_TRUE, VT_BOOL);
  652. hRes = SetPropQualifier(L"Provider", L"key", 0, &vk);
  653. if (hRes == WBEM_E_OUT_OF_MEMORY)
  654. throw CX_MemoryException();
  655. }
  656. void CCIMOMIdentificationClass::Init()
  657. {
  658. CSystemClass System;
  659. System.Init();
  660. HRESULT hRes = CreateDerivedClass(&System);
  661. if (hRes == WBEM_E_OUT_OF_MEMORY)
  662. throw CX_MemoryException();
  663. CVar v(VT_BSTR, L"__CIMOMIdentification");
  664. hRes = SetPropValue(L"__CLASS", &v, 0);
  665. if (hRes == WBEM_E_OUT_OF_MEMORY)
  666. throw CX_MemoryException();
  667. // Registry r1(WBEM_REG_WBEM);
  668. Registry r(WBEM_REG_WINMGMT);
  669. SetPropFromReg(&r, __TEXT("Working Directory"), L"WorkingDirectory");
  670. SetPropFromReg(&r, __TEXT("SetupTime"), L"SetupTime");
  671. SetPropFromReg(&r, __TEXT("SetupDate"), L"SetupDate");
  672. // Get the current dll version info
  673. WCHAR wcVer[MAX_PATH];
  674. BOOL bRet = ConfigMgr::GetDllVersion(__TEXT("wbemcore.dll"), __TEXT("ProductVersion"),
  675. wcVer, MAX_PATH);
  676. if(bRet)
  677. {
  678. CVar v2(VT_BSTR, wcVer);
  679. hRes = SetPropValue(L"VersionUsedToCreateDB", &v2, CIM_STRING);
  680. if (hRes == WBEM_E_OUT_OF_MEMORY)
  681. throw CX_MemoryException();
  682. }
  683. else
  684. {
  685. hRes = Put(L"VersionUsedToCreateDB", 0, NULL, VT_BSTR);
  686. if (hRes == WBEM_E_OUT_OF_MEMORY)
  687. throw CX_MemoryException();
  688. }
  689. hRes = Put(L"VersionCurrentlyRunning", 0, NULL, VT_BSTR);
  690. if (hRes == WBEM_E_OUT_OF_MEMORY)
  691. throw CX_MemoryException();
  692. CVar vk(VARIANT_TRUE, VT_BOOL);
  693. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  694. if (hRes == WBEM_E_OUT_OF_MEMORY)
  695. throw CX_MemoryException();
  696. }
  697. void CCIMOMIdentificationClass::SetPropFromReg(Registry * pReg, TCHAR * pcRegName,
  698. WCHAR * pwcPropName)
  699. {
  700. WCHAR wcTemp[MAX_PATH];
  701. TCHAR *pTemp = NULL;
  702. int iRet = pReg->GetStr(pcRegName, &pTemp);
  703. if (((iRet != Registry::no_error) && (pReg->GetLastError() == 0)) || ((iRet != Registry::no_error) && (pReg->GetLastError() == ERROR_OUTOFMEMORY)))
  704. throw CX_MemoryException();
  705. if (pTemp == NULL)
  706. return;
  707. StringCchCopyW(wcTemp, MAX_PATH, pTemp);
  708. CVar vVersion(VT_BSTR, wcTemp);
  709. HRESULT hRes = SetPropValue(pwcPropName, &vVersion, CIM_STRING);
  710. if (hRes == WBEM_E_OUT_OF_MEMORY)
  711. {
  712. delete pTemp;
  713. throw CX_MemoryException();
  714. }
  715. delete pTemp;
  716. }
  717. // __AdapStatus
  718. void CAdapStatusClass::Init()
  719. {
  720. CSystemClass System;
  721. System.Init();
  722. HRESULT hRes = CreateDerivedClass(&System);
  723. if (hRes == WBEM_E_OUT_OF_MEMORY)
  724. throw CX_MemoryException();
  725. CVar v(VT_BSTR, L"__AdapStatus");
  726. hRes = SetPropValue(L"__CLASS", &v, 0);
  727. if (hRes == WBEM_E_OUT_OF_MEMORY)
  728. throw CX_MemoryException();
  729. CVar vk(VARIANT_TRUE, VT_BOOL);
  730. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  731. if (hRes == WBEM_E_OUT_OF_MEMORY)
  732. throw CX_MemoryException();
  733. CVar vEmpty;
  734. vEmpty.SetAsNull();
  735. hRes = SetPropValue(L"LastStartTime", &vEmpty, CIM_DATETIME);
  736. if (hRes == WBEM_E_OUT_OF_MEMORY)
  737. throw CX_MemoryException();
  738. hRes = SetPropValue(L"LastStopTime", &vEmpty, CIM_DATETIME);
  739. if (hRes == WBEM_E_OUT_OF_MEMORY)
  740. throw CX_MemoryException();
  741. hRes = SetPropValue(L"Status", &vEmpty, CIM_UINT32);
  742. if (hRes == WBEM_E_OUT_OF_MEMORY)
  743. throw CX_MemoryException();
  744. }
  745. void CAdapStatusInstance::Init(CAdapStatusClass* pClass)
  746. {
  747. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  748. throw CX_MemoryException();
  749. WCHAR wszBuffer[100];
  750. StringCchPrintfW(wszBuffer, 100, L"%04u%02u%02u%02u%02u%02u.%06u:000",
  751. 0, 0, 0, 0, 0, 0, 0);
  752. CVar v(VT_BSTR, wszBuffer);
  753. HRESULT hRes = SetPropValue(L"LastStartTime", &v, 0);
  754. if (hRes == WBEM_E_OUT_OF_MEMORY)
  755. throw CX_MemoryException();
  756. hRes = SetPropValue(L"LastStopTime", &v, 0);
  757. if (hRes == WBEM_E_OUT_OF_MEMORY)
  758. throw CX_MemoryException();
  759. CVar Var; //(VT_I4);
  760. Var.SetLong(0);
  761. hRes = SetPropValue(L"Status", &Var, 0);
  762. if (hRes == WBEM_E_OUT_OF_MEMORY)
  763. throw CX_MemoryException();
  764. }
  765. // __CIMOMIdentification
  766. void CIdentificationClass::Init()
  767. {
  768. CSystemClass System;
  769. System.Init();
  770. HRESULT hRes = CreateDerivedClass(&System);
  771. if (hRes == WBEM_E_OUT_OF_MEMORY)
  772. throw CX_MemoryException();
  773. CVar v(VT_BSTR, L"__CIMOMIdentification");
  774. hRes = SetPropValue(L"__CLASS", &v, 0);
  775. if (hRes == WBEM_E_OUT_OF_MEMORY)
  776. throw CX_MemoryException();
  777. CVar vk(VARIANT_TRUE, VT_BOOL);
  778. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  779. if (hRes == WBEM_E_OUT_OF_MEMORY)
  780. throw CX_MemoryException();
  781. CVar vEmpty;
  782. vEmpty.SetAsNull();
  783. hRes = SetPropValue(L"WorkingDirectory", &vEmpty, CIM_STRING);
  784. if (hRes == WBEM_E_OUT_OF_MEMORY)
  785. throw CX_MemoryException();
  786. hRes = SetPropValue(L"SetupTime", &vEmpty, CIM_STRING);
  787. if (hRes == WBEM_E_OUT_OF_MEMORY)
  788. throw CX_MemoryException();
  789. hRes = SetPropValue(L"SetupDate", &vEmpty, CIM_STRING);
  790. if (hRes == WBEM_E_OUT_OF_MEMORY)
  791. throw CX_MemoryException();
  792. hRes = SetPropValue(L"VersionUsedToCreateDB", &vEmpty, CIM_STRING);
  793. if (hRes == WBEM_E_OUT_OF_MEMORY)
  794. throw CX_MemoryException();
  795. hRes = SetPropValue(L"VersionCurrentlyRunning", &vEmpty, CIM_STRING);
  796. if (hRes == WBEM_E_OUT_OF_MEMORY)
  797. throw CX_MemoryException();
  798. }
  799. void CIdentificationInstance::Init(CIdentificationClass* pClass)
  800. {
  801. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  802. throw CX_MemoryException();
  803. HRESULT hRes;
  804. WCHAR wcVer[MAX_PATH];
  805. BOOL bRet = ConfigMgr::GetDllVersion(__TEXT("wbemcore.dll"), __TEXT("ProductVersion"), wcVer, MAX_PATH);
  806. if(bRet)
  807. {
  808. TCHAR *szDate;
  809. TCHAR *szTime;
  810. TCHAR *szWorkDir;
  811. //Get the time of installation
  812. Registry r(WBEM_REG_WINMGMT);
  813. r.GetStr(__TEXT("SetupDate"), (TCHAR **)&szDate);
  814. CDeleteMe<TCHAR> delMe1(szDate);
  815. r.GetStr(__TEXT("SetupTime"), (TCHAR **)&szTime);
  816. CDeleteMe<TCHAR> delMe2(szTime);
  817. r.GetStr(__TEXT("Working Directory"), (TCHAR **)&szWorkDir);
  818. CDeleteMe<TCHAR> delMe3(szWorkDir);
  819. if ((szDate == NULL) || (szTime == NULL) || (szWorkDir == NULL))
  820. {
  821. return;
  822. }
  823. CVar v(VT_BSTR, wcVer);
  824. hRes = SetPropValue(L"VersionUsedToCreateDB", &v, CIM_STRING);
  825. if (hRes == WBEM_E_OUT_OF_MEMORY)
  826. throw CX_MemoryException();
  827. hRes = SetPropValue(L"VersionCurrentlyRunning", &v, CIM_STRING);
  828. if (hRes == WBEM_E_OUT_OF_MEMORY)
  829. throw CX_MemoryException();
  830. BSTR TmpBString = SysAllocString(szDate);
  831. if (TmpBString)
  832. {
  833. CVar v2(VT_BSTR,auto_bstr(TmpBString));
  834. hRes = SetPropValue(L"SetupDate", &v2, CIM_STRING);
  835. if (hRes == WBEM_E_OUT_OF_MEMORY)
  836. throw CX_MemoryException();
  837. }
  838. else
  839. {
  840. throw CX_MemoryException();
  841. }
  842. TmpBString = SysAllocString(szTime);
  843. if (TmpBString)
  844. {
  845. CVar v3(VT_BSTR,auto_bstr(TmpBString));
  846. hRes = SetPropValue(L"SetupTime", &v3, CIM_STRING);
  847. if (hRes == WBEM_E_OUT_OF_MEMORY)
  848. throw CX_MemoryException();
  849. }
  850. else
  851. {
  852. throw CX_MemoryException();
  853. }
  854. TmpBString = SysAllocString(szWorkDir);
  855. if (TmpBString)
  856. {
  857. CVar v4(VT_BSTR,auto_bstr(TmpBString));
  858. hRes = SetPropValue(L"WorkingDirectory", &v4, CIM_STRING);
  859. if (hRes == WBEM_E_OUT_OF_MEMORY)
  860. throw CX_MemoryException();
  861. }
  862. else
  863. {
  864. throw CX_MemoryException();
  865. }
  866. }
  867. }
  868. void CCacheControlClass::Init()
  869. {
  870. CSystemClass System;
  871. System.Init();
  872. HRESULT hRes = CreateDerivedClass(&System);
  873. if (hRes == WBEM_E_OUT_OF_MEMORY)
  874. throw CX_MemoryException();
  875. CVar v(VT_BSTR, L"__CacheControl");
  876. hRes = SetPropValue(L"__CLASS", &v, 0);
  877. if (hRes == WBEM_E_OUT_OF_MEMORY)
  878. throw CX_MemoryException();
  879. CVar vk(VARIANT_TRUE, VT_BOOL);
  880. hRes = SetQualifier(L"abstract", &vk, ABSTRACT_FLAVOR);
  881. if (hRes == WBEM_E_OUT_OF_MEMORY)
  882. throw CX_MemoryException();
  883. }
  884. void CSpecificCacheControlClass::Init(LPCWSTR wszClassName)
  885. {
  886. CCacheControlClass CacheControl;
  887. CacheControl.Init();
  888. HRESULT hRes = CreateDerivedClass(&CacheControl);
  889. if (hRes == WBEM_E_OUT_OF_MEMORY)
  890. throw CX_MemoryException();
  891. CVar v(VT_BSTR, (LPWSTR)wszClassName);
  892. hRes = SetPropValue(L"__CLASS", &v, 0);
  893. if (hRes == WBEM_E_OUT_OF_MEMORY)
  894. throw CX_MemoryException();
  895. CVar vNull;
  896. vNull.SetAsNull();
  897. hRes = SetPropValue(L"ClearAfter", &vNull, CIM_DATETIME);
  898. if (hRes == WBEM_E_OUT_OF_MEMORY)
  899. throw CX_MemoryException();
  900. CVar vInterval(VT_BSTR, L"interval");
  901. hRes = SetPropQualifier(L"ClearAfter", L"SUBTYPE", SYNTAX_FLAVOR, &vInterval);
  902. if (hRes == WBEM_E_OUT_OF_MEMORY)
  903. throw CX_MemoryException();
  904. CVar vk(VARIANT_TRUE, VT_BOOL);
  905. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  906. if (hRes == WBEM_E_OUT_OF_MEMORY)
  907. throw CX_MemoryException();
  908. }
  909. void CCacheControlInstance::Init(CSpecificCacheControlClass* pClass,
  910. DWORD dwSeconds)
  911. {
  912. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  913. throw CX_MemoryException();
  914. DWORD dwDays = dwSeconds / (3600 * 24);
  915. dwSeconds -= dwDays * 3600 * 24;
  916. DWORD dwHours = dwSeconds / 3600;
  917. dwSeconds -= dwHours * 3600;
  918. DWORD dwMinutes = dwSeconds / 60;
  919. dwSeconds -= dwMinutes * 60;
  920. WCHAR wszBuffer[100];
  921. StringCchPrintfW(wszBuffer, 100, L"%04u%02u%02u%02u%02u%02u.%06u:000",
  922. 0, 0, dwDays, dwHours, dwMinutes, dwSeconds, 0);
  923. CVar v(VT_BSTR, wszBuffer);
  924. HRESULT hRes = SetPropValue(L"ClearAfter", &v, 0);
  925. if (hRes == WBEM_E_OUT_OF_MEMORY)
  926. throw CX_MemoryException();
  927. }
  928. void CActiveNamespacesClass::Init()
  929. {
  930. CSystemClass System;
  931. System.Init();
  932. HRESULT hRes = CreateDerivedClass(&System);
  933. if (hRes == WBEM_E_OUT_OF_MEMORY)
  934. throw CX_MemoryException();
  935. CVar v(VT_BSTR, L"__ListOfEventActiveNamespaces");
  936. hRes = SetPropValue(L"__CLASS", &v, 0);
  937. if (hRes == WBEM_E_OUT_OF_MEMORY)
  938. throw CX_MemoryException();
  939. CVar vNull;
  940. vNull.SetAsNull();
  941. hRes = SetPropValue(L"Namespaces", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  942. if (hRes == WBEM_E_OUT_OF_MEMORY)
  943. throw CX_MemoryException();
  944. CVar vk(VARIANT_TRUE, VT_BOOL);
  945. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  946. if (hRes == WBEM_E_OUT_OF_MEMORY)
  947. throw CX_MemoryException();
  948. }
  949. //******************************************************************************
  950. void CIndicationRelatedClass::Init()
  951. {
  952. CSystemClass System;
  953. System.Init();
  954. HRESULT hRes = CreateDerivedClass(&System);
  955. if (hRes == WBEM_E_OUT_OF_MEMORY)
  956. throw CX_MemoryException();
  957. CVar v(VT_BSTR, L"__IndicationRelated");
  958. hRes = SetPropValue(L"__CLASS", &v, 0);
  959. if (hRes == WBEM_E_OUT_OF_MEMORY)
  960. throw CX_MemoryException();
  961. CVar vk(VARIANT_TRUE, VT_BOOL);
  962. hRes = SetQualifier(L"abstract", &vk, ABSTRACT_FLAVOR);
  963. if (hRes == WBEM_E_OUT_OF_MEMORY)
  964. throw CX_MemoryException();
  965. }
  966. void CEventClass::Init()
  967. {
  968. CIndicationRelatedClass IndicationRelated;
  969. IndicationRelated.Init();
  970. HRESULT hRes = CreateDerivedClass(&IndicationRelated);
  971. if (hRes == WBEM_E_OUT_OF_MEMORY)
  972. throw CX_MemoryException();
  973. CVar v(VT_BSTR, L"__Event");
  974. hRes = SetPropValue(L"__CLASS", &v, 0);
  975. if (hRes == WBEM_E_OUT_OF_MEMORY)
  976. throw CX_MemoryException();
  977. CVar vEmpty;
  978. vEmpty.SetAsNull();
  979. hRes = SetPropValue(L"TIME_CREATED", &vEmpty, CIM_UINT64);
  980. if (hRes == WBEM_E_OUT_OF_MEMORY)
  981. throw CX_MemoryException();
  982. vEmpty.SetAsNull();
  983. hRes = SetPropValue(L"SECURITY_DESCRIPTOR", &vEmpty, CIM_FLAG_ARRAY | CIM_UINT8);
  984. if (hRes == WBEM_E_OUT_OF_MEMORY)
  985. throw CX_MemoryException();
  986. CVar vk(VARIANT_TRUE, VT_BOOL);
  987. // abstract forever --- all events are such.
  988. hRes = SetQualifier(L"abstract", &vk, WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
  989. WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS |
  990. WBEM_FLAVOR_NOT_OVERRIDABLE);
  991. if (hRes == WBEM_E_OUT_OF_MEMORY)
  992. throw CX_MemoryException();
  993. }
  994. void CEmptyEventClass::Init(LPWSTR wszName)
  995. {
  996. CEventClass EventClass;
  997. EventClass.Init();
  998. HRESULT hRes = CreateDerivedClass(&EventClass);
  999. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1000. throw CX_MemoryException();
  1001. CVar v(VT_BSTR, wszName);
  1002. hRes = SetPropValue(L"__CLASS", &v, 0);
  1003. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1004. throw CX_MemoryException();
  1005. }
  1006. void CGenericDataEventClass::Init(LPWSTR wszCimType, LPWSTR wszPropSuffix)
  1007. {
  1008. CEventClass EventClass;
  1009. EventClass.Init();
  1010. HRESULT hRes = CreateDerivedClass(&EventClass);
  1011. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1012. throw CX_MemoryException();
  1013. WString wsClassName = L"__";
  1014. wsClassName += wszPropSuffix;
  1015. wsClassName += L"OperationEvent";
  1016. CVar v(VT_BSTR, wsClassName);
  1017. hRes = SetPropValue(L"__CLASS", &v, 0);
  1018. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1019. throw CX_MemoryException();
  1020. CVar vCimType(VT_BSTR, wszCimType);
  1021. CVar vEmpty;
  1022. vEmpty.SetAsNull();
  1023. WString wsPropName = L"Target";
  1024. wsPropName += wszPropSuffix;
  1025. hRes = SetPropValue(wsPropName, &vEmpty, CIM_OBJECT);
  1026. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1027. throw CX_MemoryException();
  1028. hRes = SetPropQualifier(wsPropName, TYPEQUAL, SYNTAX_FLAVOR, &vCimType);
  1029. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1030. throw CX_MemoryException();
  1031. }
  1032. void CDataEventClass::Init(CWbemClass& Parent,
  1033. LPWSTR wszCimType, LPWSTR wszPropSuffix,
  1034. int nFlags)
  1035. {
  1036. HRESULT hRes = CreateDerivedClass(&Parent);
  1037. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1038. throw CX_MemoryException();
  1039. WString wsClassName = L"__";
  1040. wsClassName += wszPropSuffix;
  1041. if(nFlags == include_new)
  1042. wsClassName += L"Creation";
  1043. else if(nFlags == include_old)
  1044. wsClassName += L"Deletion";
  1045. else
  1046. wsClassName += L"Modification";
  1047. wsClassName += L"Event";
  1048. CVar v(VT_BSTR, wsClassName);
  1049. hRes = SetPropValue(L"__CLASS", &v, 0);
  1050. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1051. throw CX_MemoryException();
  1052. if(nFlags == (include_old | include_new))
  1053. {
  1054. CVar vCimType(VT_BSTR, wszCimType);
  1055. CVar vEmpty;
  1056. vEmpty.SetAsNull();
  1057. WString wsPropName = L"Previous";
  1058. wsPropName += wszPropSuffix;
  1059. hRes = SetPropValue(wsPropName, &vEmpty, CIM_OBJECT);
  1060. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1061. throw CX_MemoryException();
  1062. hRes = SetPropQualifier(wsPropName, TYPEQUAL, SYNTAX_FLAVOR, &vCimType);
  1063. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1064. throw CX_MemoryException();
  1065. }
  1066. }
  1067. void CMethodEventClass::Init()
  1068. {
  1069. CGenericDataEventClass InstanceOp;
  1070. InstanceOp.Init(L"object", L"Instance");
  1071. HRESULT hRes = CreateDerivedClass(&InstanceOp);
  1072. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1073. throw CX_MemoryException();
  1074. CVar v(VT_BSTR, L"__MethodInvocationEvent");
  1075. hRes = SetPropValue(L"__CLASS", &v, 0);
  1076. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1077. throw CX_MemoryException();
  1078. CVar vEmpty;
  1079. vEmpty.SetAsNull();
  1080. hRes= SetPropValue(L"Method", &vEmpty, CIM_STRING);
  1081. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1082. throw CX_MemoryException();
  1083. hRes = SetPropValue(L"PreCall", &vEmpty, CIM_BOOLEAN);
  1084. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1085. throw CX_MemoryException();
  1086. hRes = SetPropValue(L"Parameters", &vEmpty, CIM_OBJECT);
  1087. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1088. throw CX_MemoryException();
  1089. }
  1090. void CTimerEventClass::Init()
  1091. {
  1092. CEventClass EventClass;
  1093. EventClass.Init();
  1094. HRESULT hRes = CreateDerivedClass(&EventClass);
  1095. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1096. throw CX_MemoryException();
  1097. CVar v(VT_BSTR, L"__TimerEvent");
  1098. hRes = SetPropValue(L"__CLASS", &v, 0);
  1099. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1100. throw CX_MemoryException();
  1101. CVar vEmpty;
  1102. vEmpty.SetAsNull();
  1103. hRes= SetPropValue(L"TimerId", &vEmpty, CIM_STRING);
  1104. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1105. throw CX_MemoryException();
  1106. hRes = SetPropValue(L"NumFirings", &vEmpty, CIM_UINT32);
  1107. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1108. throw CX_MemoryException();
  1109. }
  1110. void CAggregateEventClass::Init()
  1111. {
  1112. CIndicationRelatedClass IndClass;
  1113. IndClass.Init();
  1114. HRESULT hRes = CreateDerivedClass(&IndClass);
  1115. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1116. throw CX_MemoryException();
  1117. CVar v(VT_BSTR, L"__AggregateEvent");
  1118. hRes = SetPropValue(L"__CLASS", &v, 0);
  1119. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1120. throw CX_MemoryException();
  1121. CVar vEmpty;
  1122. vEmpty.SetAsNull();
  1123. hRes = SetPropValue(L"NumberOfEvents", &vEmpty, CIM_UINT32);
  1124. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1125. throw CX_MemoryException();
  1126. hRes = SetPropValue(L"Representative", &vEmpty, CIM_OBJECT);
  1127. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1128. throw CX_MemoryException();
  1129. }
  1130. void CSystemEventClass::Init()
  1131. {
  1132. CEmptyEventClass ExtClass;
  1133. ExtClass.Init(L"__ExtrinsicEvent");
  1134. HRESULT hRes = CreateDerivedClass(&ExtClass);
  1135. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1136. throw CX_MemoryException();
  1137. CVar v(VT_BSTR, L"__SystemEvent");
  1138. hRes = SetPropValue(L"__CLASS", &v, 0);
  1139. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1140. throw CX_MemoryException();
  1141. }
  1142. void CEventDroppedEventClass::Init()
  1143. {
  1144. CSystemEventClass SysClass;
  1145. SysClass.Init();
  1146. HRESULT hRes = CreateDerivedClass(&SysClass);
  1147. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1148. throw CX_MemoryException();
  1149. CVar v(VT_BSTR, L"__EventDroppedEvent");
  1150. hRes = SetPropValue(L"__CLASS", &v, 0);
  1151. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1152. throw CX_MemoryException();
  1153. CVar vEmpty;
  1154. vEmpty.SetAsNull();
  1155. hRes = SetPropValue(L"Event", &vEmpty, CIM_OBJECT);
  1156. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1157. throw CX_MemoryException();
  1158. hRes = SetPropValue(L"IntendedConsumer", &vEmpty, CIM_REFERENCE);
  1159. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1160. throw CX_MemoryException();
  1161. CVar vEventType(VT_BSTR, L"object:__Event");
  1162. hRes = SetPropQualifier(L"Event", TYPEQUAL, SYNTAX_FLAVOR, &vEventType);
  1163. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1164. throw CX_MemoryException();
  1165. CVar vConsType(VT_BSTR, L"ref:__EventConsumer");
  1166. hRes = SetPropQualifier(L"IntendedConsumer", TYPEQUAL, SYNTAX_FLAVOR, &vConsType);
  1167. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1168. throw CX_MemoryException();
  1169. }
  1170. void CQueueOverflowEventClass::Init()
  1171. {
  1172. CEventDroppedEventClass DropClass;
  1173. DropClass.Init();
  1174. HRESULT hRes = CreateDerivedClass(&DropClass);
  1175. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1176. throw CX_MemoryException();
  1177. CVar v(VT_BSTR, L"__EventQueueOverflowEvent");
  1178. hRes = SetPropValue(L"__CLASS", &v, 0);
  1179. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1180. throw CX_MemoryException();
  1181. CVar vEmpty;
  1182. vEmpty.SetAsNull();
  1183. hRes = SetPropValue(L"CurrentQueueSize", &vEmpty, CIM_UINT32);
  1184. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1185. throw CX_MemoryException();
  1186. CVar vBytes(VT_BSTR, L"bytes");
  1187. hRes = SetPropQualifier(L"CurrentQueueSize", L"units", UNITS_FLAVOR, &vBytes);
  1188. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1189. throw CX_MemoryException();
  1190. }
  1191. void CConsumerFailureEventClass::Init()
  1192. {
  1193. CEventDroppedEventClass DropClass;
  1194. DropClass.Init();
  1195. HRESULT hRes = CreateDerivedClass(&DropClass);
  1196. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1197. throw CX_MemoryException();
  1198. CVar v(VT_BSTR, L"__ConsumerFailureEvent");
  1199. hRes = SetPropValue(L"__CLASS", &v, 0);
  1200. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1201. throw CX_MemoryException();
  1202. CVar vEmpty;
  1203. vEmpty.SetAsNull();
  1204. hRes = SetPropValue(L"ErrorCode", &vEmpty, CIM_UINT32);
  1205. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1206. throw CX_MemoryException();
  1207. hRes = SetPropValue(L"ErrorDescription", &vEmpty, CIM_STRING);
  1208. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1209. throw CX_MemoryException();
  1210. hRes = SetPropValue(L"ErrorObject", &vEmpty, CIM_OBJECT);
  1211. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1212. throw CX_MemoryException();
  1213. CVar vEmbType(VT_BSTR, L"object:__ExtendedStatus");
  1214. hRes = SetPropQualifier(L"ErrorObject", L"CIMTYPE", 0, &vEmbType);
  1215. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1216. throw CX_MemoryException();
  1217. }
  1218. void CQoSFailureEventClass::Init()
  1219. {
  1220. CEventDroppedEventClass DropClass;
  1221. DropClass.Init();
  1222. HRESULT hRes = CreateDerivedClass(&DropClass);
  1223. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1224. throw CX_MemoryException();
  1225. CVar v(VT_BSTR, L"__QOSFailureEvent");
  1226. hRes = SetPropValue(L"__CLASS", &v, 0);
  1227. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1228. throw CX_MemoryException();
  1229. CVar vEmpty;
  1230. vEmpty.SetAsNull();
  1231. hRes = SetPropValue(L"ErrorCode", &vEmpty, CIM_UINT32);
  1232. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1233. throw CX_MemoryException();
  1234. hRes = SetPropValue(L"ErrorDescription", &vEmpty, CIM_STRING);
  1235. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1236. throw CX_MemoryException();
  1237. }
  1238. //******************************************************************************
  1239. void CEventConsumerClass::Init()
  1240. {
  1241. CIndicationRelatedClass IndicationRelated;
  1242. IndicationRelated.Init();
  1243. HRESULT hRes = CreateDerivedClass(&IndicationRelated);
  1244. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1245. throw CX_MemoryException();
  1246. CVar v(VT_BSTR, L"__EventConsumer");
  1247. hRes = SetPropValue(L"__CLASS", &v, 0);
  1248. CVar vProp;
  1249. vProp.SetAsNull();
  1250. hRes = SetPropValue(L"MachineName", &vProp, CIM_STRING);
  1251. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1252. throw CX_MemoryException();
  1253. hRes = SetPropValue(L"MaximumQueueSize", &vProp, CIM_UINT32);
  1254. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1255. throw CX_MemoryException();
  1256. CVar vSid;
  1257. if(!GetLocalSystemSid(vSid))
  1258. throw CX_MemoryException();
  1259. hRes = SetPropValue(L"CreatorSID", &vSid, CIM_UINT8 | CIM_FLAG_ARRAY);
  1260. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1261. throw CX_MemoryException();
  1262. CVar vt(VARIANT_TRUE, VT_BOOL);
  1263. hRes = SetQualifier(L"abstract", &vt, ABSTRACT_FLAVOR);
  1264. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1265. throw CX_MemoryException();
  1266. hRes = SetPropQualifier(L"CreatorSID", L"read", READ_FLAVOR, &vt);
  1267. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1268. throw CX_MemoryException();
  1269. CVar vBytes(VT_BSTR, L"bytes");
  1270. hRes = SetPropQualifier(L"MaximumQueueSize", L"units", UNITS_FLAVOR, &vBytes);
  1271. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1272. throw CX_MemoryException();
  1273. }
  1274. //******************************************************************************
  1275. void CConditionalInstructionClass::Init()
  1276. {
  1277. CIndicationRelatedClass IndicationRelated;
  1278. IndicationRelated.Init();
  1279. HRESULT hRes = CreateDerivedClass(&IndicationRelated);
  1280. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1281. throw CX_MemoryException();
  1282. CVar v(VT_BSTR, L"__ConditionalInstruction");
  1283. hRes = SetPropValue(L"__CLASS", &v, 0);
  1284. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1285. throw CX_MemoryException();
  1286. CVar vEmpty;
  1287. vEmpty.SetAsNull();
  1288. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1289. hRes = SetPropValue(L"Name", &vEmpty, CIM_STRING);
  1290. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1291. throw CX_MemoryException();
  1292. hRes = SetPropValue(L"Condition", &vEmpty, CIM_STRING);
  1293. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1294. throw CX_MemoryException();
  1295. hRes = SetPropValue(L"ConditionNamespace", &vEmpty, CIM_STRING);
  1296. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1297. throw CX_MemoryException();
  1298. hRes = SetPropValue(L"ConditionLanguage", &vEmpty, CIM_STRING);
  1299. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1300. throw CX_MemoryException();
  1301. CVar vSid;
  1302. if(!GetLocalSystemSid(vSid))
  1303. throw CX_MemoryException();
  1304. hRes = SetPropValue(L"CreatorSID", &vSid, CIM_UINT8 | CIM_FLAG_ARRAY);
  1305. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1306. throw CX_MemoryException();
  1307. hRes = SetPropQualifier(L"CreatorSID", L"read", READ_FLAVOR, &vTrue);
  1308. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1309. throw CX_MemoryException();
  1310. }
  1311. void CEventFilterClass::Init()
  1312. {
  1313. #ifdef WHISTLER_UNCUT
  1314. CConditionalInstructionClass ConditionalInstruction;
  1315. #else
  1316. CIndicationRelatedClass ConditionalInstruction;
  1317. #endif
  1318. ConditionalInstruction.Init();
  1319. HRESULT hRes = CreateDerivedClass(&ConditionalInstruction);
  1320. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1321. throw CX_MemoryException();
  1322. CVar v(VT_BSTR, L"__EventFilter");
  1323. hRes = SetPropValue(L"__CLASS", &v, 0);
  1324. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1325. throw CX_MemoryException();
  1326. CVar vEmpty;
  1327. vEmpty.SetAsNull();
  1328. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1329. #ifdef WHISTLER_UNCUT
  1330. #else
  1331. hRes = SetPropValue(L"Name", &vEmpty, CIM_STRING);
  1332. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1333. throw CX_MemoryException();
  1334. CVar vSid;
  1335. if(!GetLocalSystemSid(vSid))
  1336. throw CX_MemoryException();
  1337. hRes = SetPropValue(L"CreatorSID", &vSid, CIM_UINT8 | CIM_FLAG_ARRAY);
  1338. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1339. throw CX_MemoryException();
  1340. hRes = SetPropQualifier(L"CreatorSID", L"read", READ_FLAVOR, &vTrue);
  1341. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1342. throw CX_MemoryException();
  1343. #endif
  1344. hRes = SetPropValue(L"QueryLanguage", &vEmpty, CIM_STRING);
  1345. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1346. throw CX_MemoryException();
  1347. hRes = SetPropValue(L"Query", &vEmpty, CIM_STRING);
  1348. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1349. throw CX_MemoryException();
  1350. hRes = SetPropValue(L"EventNamespace", &vEmpty, CIM_STRING);
  1351. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1352. throw CX_MemoryException();
  1353. hRes = SetPropValue(L"EventAccess", &vEmpty, CIM_STRING);
  1354. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1355. throw CX_MemoryException();
  1356. hRes = SetPropQualifier(L"Name", L"key", 0, &vTrue);
  1357. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1358. throw CX_MemoryException();
  1359. }
  1360. void CEventMonitorClass::Init()
  1361. {
  1362. CConditionalInstructionClass ConditionalInstruction;
  1363. ConditionalInstruction.Init();
  1364. HRESULT hRes = CreateDerivedClass(&ConditionalInstruction);
  1365. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1366. throw CX_MemoryException();
  1367. CVar v(VT_BSTR, L"__MonitorInstruction");
  1368. hRes = SetPropValue(L"__CLASS", &v, 0);
  1369. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1370. throw CX_MemoryException();
  1371. CVar vEmpty;
  1372. vEmpty.SetAsNull();
  1373. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1374. hRes = SetPropValue(L"QueryLanguage", &vEmpty, CIM_STRING);
  1375. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1376. throw CX_MemoryException();
  1377. hRes = SetPropValue(L"Query", &vEmpty, CIM_STRING);
  1378. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1379. throw CX_MemoryException();
  1380. hRes = SetPropValue(L"TargetNamespace", &vEmpty, CIM_STRING);
  1381. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1382. throw CX_MemoryException();
  1383. hRes = SetPropQualifier(L"Name", L"key", 0, &vTrue);
  1384. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1385. throw CX_MemoryException();
  1386. }
  1387. //******************************************************************************
  1388. void CFilterConsumerBindingClass::Init()
  1389. {
  1390. CIndicationRelatedClass IndicationRelated;
  1391. IndicationRelated.Init();
  1392. HRESULT hRes = CreateDerivedClass(&IndicationRelated);
  1393. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1394. throw CX_MemoryException();
  1395. CVar v(VT_BSTR, L"__FilterToConsumerBinding");
  1396. hRes = SetPropValue(L"__CLASS", &v, 0);
  1397. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1398. throw CX_MemoryException();
  1399. //CVar vEmpty(VT_BSTR, L"");
  1400. CVar vEmpty;
  1401. vEmpty.SetAsNull();
  1402. hRes = SetPropValue(L"Filter", &vEmpty, CIM_REFERENCE);
  1403. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1404. throw CX_MemoryException();
  1405. hRes = SetPropValue(L"Consumer", &vEmpty, CIM_REFERENCE);
  1406. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1407. throw CX_MemoryException();
  1408. CVar vFilterRef(VT_BSTR, L"ref:__EventFilter");
  1409. hRes = SetPropQualifier(L"Filter", TYPEQUAL, SYNTAX_FLAVOR, &vFilterRef);
  1410. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1411. throw CX_MemoryException();
  1412. CVar vConsumerRef(VT_BSTR, L"ref:__EventConsumer");
  1413. hRes = SetPropQualifier(L"Consumer", TYPEQUAL, SYNTAX_FLAVOR, &vConsumerRef);
  1414. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1415. throw CX_MemoryException();
  1416. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1417. hRes = SetPropQualifier(L"Filter", L"key", 0, &vTrue);
  1418. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1419. throw CX_MemoryException();
  1420. hRes = SetPropQualifier(L"Consumer", L"key", 0, &vTrue);
  1421. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1422. throw CX_MemoryException();
  1423. hRes = SetQualifier(L"Association", &vTrue, ASSOC_FLAVOR);
  1424. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1425. throw CX_MemoryException();
  1426. hRes = SetPropValue( L"DeliveryQoS", &vEmpty, CIM_UINT32 );
  1427. if ( hRes == WBEM_E_OUT_OF_MEMORY )
  1428. throw CX_MemoryException();
  1429. CVar vFalse(VARIANT_FALSE, VT_BOOL);
  1430. hRes = SetPropValue(L"DeliverSynchronously", &vFalse, CIM_BOOLEAN);
  1431. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1432. throw CX_MemoryException();
  1433. hRes = SetPropValue(L"MaintainSecurityContext", &vFalse, CIM_BOOLEAN);
  1434. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1435. throw CX_MemoryException();
  1436. hRes = SetPropValue(L"SlowDownProviders", &vFalse, CIM_BOOLEAN);
  1437. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1438. throw CX_MemoryException();
  1439. CVar vSid;
  1440. if(!GetLocalSystemSid(vSid))
  1441. throw CX_MemoryException();
  1442. hRes = SetPropValue(L"CreatorSID", &vSid, CIM_UINT8 | CIM_FLAG_ARRAY);
  1443. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1444. throw CX_MemoryException();
  1445. hRes = SetPropQualifier(L"DeliverSynchronously", L"not_null",
  1446. NOT_NULL_FLAVOR, &vTrue);
  1447. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1448. throw CX_MemoryException();
  1449. hRes = SetPropQualifier(L"CreatorSID", L"read", READ_FLAVOR, &vTrue);
  1450. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1451. throw CX_MemoryException();
  1452. }
  1453. void CMonitorEventClass::Init(CWbemClass& Parent, LPCWSTR wszClassName)
  1454. {
  1455. HRESULT hRes = CreateDerivedClass(&Parent);
  1456. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1457. throw CX_MemoryException();
  1458. CVar v(VT_BSTR, (LPWSTR)wszClassName);
  1459. hRes = SetPropValue(L"__CLASS", &v, 0);
  1460. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1461. throw CX_MemoryException();
  1462. CVar vEmpty;
  1463. vEmpty.SetAsNull();
  1464. hRes = SetPropValue(L"MonitorName", &vEmpty, CIM_STRING);
  1465. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1466. throw CX_MemoryException();
  1467. hRes = SetPropValue(L"TotalObjects", &vEmpty, CIM_UINT32);
  1468. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1469. throw CX_MemoryException();
  1470. };
  1471. void CMonitorDataEventClass::Init(CWbemClass& Parent, LPCWSTR wszClassName)
  1472. {
  1473. HRESULT hRes = CreateDerivedClass(&Parent);
  1474. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1475. throw CX_MemoryException();
  1476. CVar v(VT_BSTR, (LPWSTR)wszClassName);
  1477. hRes = SetPropValue(L"__CLASS", &v, 0);
  1478. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1479. throw CX_MemoryException();
  1480. CVar vEmpty;
  1481. vEmpty.SetAsNull();
  1482. hRes = SetPropValue(L"RowObject", &vEmpty, CIM_OBJECT);
  1483. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1484. throw CX_MemoryException();
  1485. hRes = SetPropValue(L"GuaranteedNew", &vEmpty, CIM_BOOLEAN);
  1486. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1487. throw CX_MemoryException();
  1488. };
  1489. //*****************************************************************************
  1490. void CEventGeneratorClass::Init()
  1491. {
  1492. CIndicationRelatedClass IndicationRelated;
  1493. IndicationRelated.Init();
  1494. HRESULT hRes = CreateDerivedClass(&IndicationRelated);
  1495. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1496. throw CX_MemoryException();
  1497. CVar v(VT_BSTR, L"__EventGenerator");
  1498. hRes = SetPropValue(L"__CLASS", &v, 0);
  1499. CVar vt(VARIANT_TRUE, VT_BOOL);
  1500. hRes = SetQualifier(L"abstract", &vt, ABSTRACT_FLAVOR);
  1501. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1502. throw CX_MemoryException();
  1503. }
  1504. void CTimerInstructionClass::Init()
  1505. {
  1506. CEventGeneratorClass EventGenerator;
  1507. EventGenerator.Init();
  1508. HRESULT hRes = CreateDerivedClass(&EventGenerator);
  1509. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1510. throw CX_MemoryException();
  1511. CVar v(VT_BSTR, L"__TimerInstruction");
  1512. hRes = SetPropValue(L"__CLASS", &v, 0);
  1513. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1514. throw CX_MemoryException();
  1515. //CVar vEmpty(VT_BSTR, L"");
  1516. CVar vEmpty;
  1517. vEmpty.SetAsNull();
  1518. hRes = SetPropValue(L"TimerId", &vEmpty, CIM_STRING);
  1519. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1520. throw CX_MemoryException();
  1521. CVar vFalse(VARIANT_FALSE, VT_BOOL);
  1522. hRes = SetPropValue(L"SkipIfPassed", &vFalse, CIM_BOOLEAN);
  1523. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1524. throw CX_MemoryException();
  1525. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1526. hRes = SetPropQualifier(L"TimerId", L"key", 0, &vTrue);
  1527. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1528. throw CX_MemoryException();
  1529. CVar vt(VARIANT_TRUE, VT_BOOL);
  1530. hRes = SetQualifier(L"abstract", &vt, ABSTRACT_FLAVOR);
  1531. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1532. throw CX_MemoryException();
  1533. }
  1534. void CAbsoluteTimerInstructionClass::Init()
  1535. {
  1536. CTimerInstructionClass TimerInstruction;
  1537. TimerInstruction.Init();
  1538. HRESULT hRes = CreateDerivedClass(&TimerInstruction);
  1539. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1540. throw CX_MemoryException();
  1541. CVar v(VT_BSTR, L"__AbsoluteTimerInstruction");
  1542. hRes = SetPropValue(L"__CLASS", &v, 0);
  1543. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1544. throw CX_MemoryException();
  1545. //CVar vEmpty(VT_BSTR, L"");
  1546. CVar vEmpty;
  1547. vEmpty.SetAsNull();
  1548. hRes = SetPropValue(L"EventDateTime", &vEmpty, CIM_DATETIME);
  1549. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1550. throw CX_MemoryException();
  1551. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1552. hRes = SetPropQualifier(L"EventDateTime", L"not_null", NOT_NULL_FLAVOR, &vTrue);
  1553. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1554. throw CX_MemoryException();
  1555. }
  1556. void CIntervalTimerInstructionClass::Init()
  1557. {
  1558. CTimerInstructionClass TimerInstruction;
  1559. TimerInstruction.Init();
  1560. HRESULT hRes = CreateDerivedClass(&TimerInstruction);
  1561. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1562. throw CX_MemoryException();
  1563. CVar v(VT_BSTR, L"__IntervalTimerInstruction");
  1564. hRes = SetPropValue(L"__CLASS", &v, 0);
  1565. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1566. throw CX_MemoryException();
  1567. //CVar vZero((LONG)0);
  1568. CVar vEmpty;
  1569. vEmpty.SetAsNull();
  1570. hRes = SetPropValue(L"IntervalBetweenEvents", &vEmpty, CIM_UINT32);
  1571. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1572. throw CX_MemoryException();
  1573. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1574. hRes = SetPropQualifier(L"IntervalBetweenEvents", L"not_null", NOT_NULL_FLAVOR,
  1575. &vTrue);
  1576. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1577. throw CX_MemoryException();
  1578. CVar vSeconds(VT_BSTR, L"milliseconds");
  1579. hRes = SetPropQualifier(L"IntervalBetweenEvents", L"units", UNITS_FLAVOR,
  1580. &vSeconds);
  1581. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1582. throw CX_MemoryException();
  1583. }
  1584. void CTimerNextFiringClass::Init()
  1585. {
  1586. CIndicationRelatedClass IndicationRelated;
  1587. IndicationRelated.Init();
  1588. HRESULT hRes = CreateDerivedClass(&IndicationRelated);
  1589. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1590. throw CX_MemoryException();
  1591. CVar v(VT_BSTR, L"__TimerNextFiring");
  1592. hRes = SetPropValue(L"__CLASS", &v, 0);
  1593. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1594. throw CX_MemoryException();
  1595. //CVar vEmpty(VT_BSTR, L"");
  1596. CVar vEmpty;
  1597. vEmpty.SetAsNull();
  1598. hRes = SetPropValue(L"TimerId", &vEmpty, CIM_STRING);
  1599. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1600. throw CX_MemoryException();
  1601. hRes = SetPropValue(L"NextEvent64BitTime", &vEmpty, CIM_SINT64);
  1602. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1603. throw CX_MemoryException();
  1604. CVar vTrue(VARIANT_TRUE, VT_BOOL);
  1605. hRes = SetPropQualifier(L"TimerId", L"key", 0, &vTrue);
  1606. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1607. throw CX_MemoryException();
  1608. hRes = SetPropQualifier(L"NextEvent64BitTime", L"not_null", NOT_NULL_FLAVOR, &vTrue);
  1609. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1610. throw CX_MemoryException();
  1611. }
  1612. //******************************************************************************
  1613. void CSecurityBaseClass::Init()
  1614. {
  1615. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  1616. {
  1617. throw CX_MemoryException();
  1618. }
  1619. CVar v(VT_BSTR, L"__SecurityRelatedClass");
  1620. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  1621. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1622. throw CX_MemoryException();
  1623. CVar vTrue;
  1624. vTrue.SetBool(VARIANT_TRUE);
  1625. hRes = SetQualifier(L"abstract", &vTrue, ABSTRACT_FLAVOR);
  1626. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1627. throw CX_MemoryException();
  1628. }
  1629. void CSubjectClass::Init()
  1630. {
  1631. CSecurityBaseClass Base;
  1632. Base.Init();
  1633. HRESULT hRes = CreateDerivedClass(&Base);
  1634. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1635. throw CX_MemoryException();
  1636. CVar v(VT_BSTR, L"__Subject");
  1637. hRes = SetPropValue(L"__CLASS", &v, 0);
  1638. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1639. throw CX_MemoryException();
  1640. CVar vEmpty;
  1641. vEmpty.SetAsNull();
  1642. hRes = SetPropValue(L"Name", &vEmpty, CIM_STRING);
  1643. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1644. throw CX_MemoryException();
  1645. CVar vDefAuth(VT_BSTR, L".");
  1646. hRes = SetPropValue(L"Authority", &vDefAuth, CIM_STRING);
  1647. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1648. throw CX_MemoryException();
  1649. CVar vFalse;
  1650. vFalse.SetBool(VARIANT_FALSE);
  1651. hRes = SetPropValue(L"Enabled", &vFalse, CIM_BOOLEAN);
  1652. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1653. throw CX_MemoryException();
  1654. hRes = SetPropValue(L"Permissions", &vEmpty, CIM_SINT32);
  1655. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1656. throw CX_MemoryException();
  1657. hRes = SetPropValue(L"ExecuteMethods", &vFalse, CIM_BOOLEAN);
  1658. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1659. throw CX_MemoryException();
  1660. hRes = SetPropValue(L"EditSecurity", &vFalse, CIM_BOOLEAN);
  1661. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1662. throw CX_MemoryException();
  1663. CVar vTrue;
  1664. vTrue.SetBool(VARIANT_TRUE);
  1665. hRes = SetPropQualifier(L"Name", L"key", 0, &vTrue);
  1666. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1667. throw CX_MemoryException();
  1668. hRes = SetPropQualifier(L"Authority", L"key", 0, &vTrue);
  1669. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1670. throw CX_MemoryException();
  1671. hRes = SetQualifier(L"abstract", &vTrue, ABSTRACT_FLAVOR);
  1672. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1673. throw CX_MemoryException();
  1674. }
  1675. void CUserClass::Init()
  1676. {
  1677. CSubjectClass SubjectClass;
  1678. SubjectClass.Init();
  1679. HRESULT hRes = CreateDerivedClass(&SubjectClass);
  1680. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1681. throw CX_MemoryException();
  1682. CVar v(VT_BSTR, L"__User");
  1683. hRes = SetPropValue(L"__CLASS", &v, 0);
  1684. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1685. throw CX_MemoryException();
  1686. CVar vTrue;
  1687. vTrue.SetBool(VARIANT_TRUE);
  1688. hRes = SetQualifier(L"abstract", &vTrue, ABSTRACT_FLAVOR);
  1689. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1690. throw CX_MemoryException();
  1691. }
  1692. void CNTLMUserClass::Init()
  1693. {
  1694. CUserClass UserClass;
  1695. UserClass.Init();
  1696. HRESULT hRes = CreateDerivedClass(&UserClass);
  1697. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1698. throw CX_MemoryException();
  1699. CVar v(VT_BSTR, L"__NTLMUser");
  1700. hRes = SetPropValue(L"__CLASS", &v, 0);
  1701. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1702. throw CX_MemoryException();
  1703. CVar vEmpty;
  1704. vEmpty.SetAsNull();
  1705. hRes = SetPropValue(L"GroupType", &vEmpty, CIM_SINT32);
  1706. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1707. throw CX_MemoryException();
  1708. }
  1709. void CGroupClass::Init()
  1710. {
  1711. CSubjectClass SubjectClass;
  1712. SubjectClass.Init();
  1713. HRESULT hRes = CreateDerivedClass(&SubjectClass);
  1714. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1715. throw CX_MemoryException();
  1716. CVar v(VT_BSTR, L"__Group");
  1717. hRes = SetPropValue(L"__CLASS", &v, 0);
  1718. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1719. throw CX_MemoryException();
  1720. CVar vTrue;
  1721. vTrue.SetBool(VARIANT_TRUE);
  1722. hRes = SetQualifier(L"abstract", &vTrue, ABSTRACT_FLAVOR);
  1723. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1724. throw CX_MemoryException();
  1725. }
  1726. void CNtlmGroupClass::Init()
  1727. {
  1728. CSubjectClass SubjectClass;
  1729. SubjectClass.Init();
  1730. HRESULT hRes = CreateDerivedClass(&SubjectClass);
  1731. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1732. throw CX_MemoryException();
  1733. CVar v(VT_BSTR, L"__NTLMGroup");
  1734. hRes = SetPropValue(L"__CLASS", &v, 0);
  1735. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1736. throw CX_MemoryException();
  1737. CVar vEmpty;
  1738. vEmpty.SetAsNull();
  1739. hRes = SetPropValue(L"GroupType", &vEmpty, CIM_SINT32);
  1740. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1741. throw CX_MemoryException();
  1742. }
  1743. void CNTLM9XUserClass::Init()
  1744. {
  1745. CSecurityBaseClass Base;
  1746. Base.Init();
  1747. HRESULT hRes = CreateDerivedClass(&Base);
  1748. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1749. throw CX_MemoryException();
  1750. CVar v(VT_BSTR, L"__NTLMUser9X");
  1751. hRes = SetPropValue(L"__CLASS", &v, 0);
  1752. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1753. throw CX_MemoryException();
  1754. CVar vEmpty;
  1755. vEmpty.SetAsNull();
  1756. hRes = SetPropValue(L"Name", &vEmpty, CIM_STRING);
  1757. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1758. throw CX_MemoryException();
  1759. CVar vDefAuth(VT_BSTR, L".");
  1760. hRes = SetPropValue(L"Authority", &vDefAuth, CIM_STRING);
  1761. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1762. throw CX_MemoryException();
  1763. hRes = SetPropValue(L"Flags", &vEmpty, CIM_SINT32);
  1764. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1765. throw CX_MemoryException();
  1766. hRes = SetPropValue(L"Mask", &vEmpty, CIM_SINT32);
  1767. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1768. throw CX_MemoryException();
  1769. hRes = SetPropValue(L"Type", &vEmpty, CIM_SINT32);
  1770. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1771. throw CX_MemoryException();
  1772. }
  1773. void CSystemConfigClass::AddStaticQual(LPWSTR pMethodName)
  1774. {
  1775. IWbemQualifierSet* pQualSet = NULL;
  1776. HRESULT hRes = GetMethodQualifierSet(pMethodName, &pQualSet);
  1777. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1778. throw CX_MemoryException();
  1779. if(pQualSet)
  1780. {
  1781. VARIANT var;
  1782. var.vt = VT_BOOL; var.boolVal = VARIANT_TRUE;
  1783. hRes = pQualSet->Put(L"Static", &var, 0);
  1784. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1785. throw CX_MemoryException();
  1786. pQualSet->Release();
  1787. }
  1788. }
  1789. void CSystemConfigClass::Init()
  1790. {
  1791. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  1792. {
  1793. throw CX_MemoryException();
  1794. }
  1795. CVar v(VT_BSTR, L"__SystemSecurity");
  1796. CVar vEmpty;
  1797. vEmpty.SetAsNull();
  1798. CVar vTrue;
  1799. vTrue.SetBool(VARIANT_TRUE);
  1800. CVar vID;
  1801. vID.SetLong(0);
  1802. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  1803. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1804. throw CX_MemoryException();
  1805. hRes = SetQualifier(L"singleton", &vTrue, SINGLETON_FLAVOR);
  1806. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1807. throw CX_MemoryException();
  1808. // Add the "uint32 GetSD([out, id(0)]uint8 sd[])" method
  1809. CParametersClass * pGetSDOutputArgs = new CParametersClass;
  1810. if(pGetSDOutputArgs == NULL)
  1811. throw CX_MemoryException();
  1812. pGetSDOutputArgs->Init();
  1813. CReleaseMe relMe((IWbemClassObject*)pGetSDOutputArgs);
  1814. hRes = pGetSDOutputArgs->SetPropValue(L"ReturnValue", &vEmpty, CIM_UINT32);
  1815. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1816. throw CX_MemoryException();
  1817. hRes = pGetSDOutputArgs->SetPropQualifier(L"ReturnValue", L"out", 0, &vTrue);
  1818. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1819. throw CX_MemoryException();
  1820. hRes = pGetSDOutputArgs->SetPropValue(L"SD", &vEmpty, CIM_UINT8 | CIM_FLAG_ARRAY);
  1821. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1822. throw CX_MemoryException();
  1823. hRes = pGetSDOutputArgs->SetPropQualifier(L"SD", L"out", 0, &vTrue);
  1824. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1825. throw CX_MemoryException();
  1826. hRes = pGetSDOutputArgs->SetPropQualifier(L"SD", L"ID", 0, &vID);
  1827. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1828. throw CX_MemoryException();
  1829. // Add the method and clean up
  1830. hRes = PutMethod(L"GetSD", 0, NULL, pGetSDOutputArgs);
  1831. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1832. throw CX_MemoryException();
  1833. AddStaticQual(L"GetSD");
  1834. // Add the "uint32 Get9XUserList([out, id(0)]instance of __NTLMUser9X ul[])" method
  1835. CParametersClass * pGet9XOutputArgs = new CParametersClass;
  1836. if(pGet9XOutputArgs == NULL)
  1837. throw CX_MemoryException();
  1838. pGet9XOutputArgs->Init();
  1839. CReleaseMe relMe1((IWbemClassObject*)pGet9XOutputArgs);
  1840. hRes = pGet9XOutputArgs->SetPropValue(L"ReturnValue", &vEmpty, CIM_UINT32);
  1841. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1842. throw CX_MemoryException();
  1843. hRes = pGet9XOutputArgs->SetPropQualifier(L"ReturnValue", L"out", 0, &vTrue);
  1844. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1845. throw CX_MemoryException();
  1846. hRes = pGet9XOutputArgs->SetPropValue(L"ul", &vEmpty, CIM_OBJECT | CIM_FLAG_ARRAY);
  1847. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1848. throw CX_MemoryException();
  1849. hRes = pGet9XOutputArgs->SetPropQualifier(L"ul", L"out", 0, &vTrue);
  1850. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1851. throw CX_MemoryException();
  1852. hRes = pGet9XOutputArgs->SetPropQualifier(L"ul", L"ID", 0, &vID);
  1853. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1854. throw CX_MemoryException();
  1855. CVar vType;
  1856. vType.SetBSTR(L"object:__ntlmuser9x");
  1857. hRes = pGet9XOutputArgs->SetPropQualifier(L"ul", L"CIMTYPE", 0, &vType);
  1858. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1859. throw CX_MemoryException();
  1860. // Add the method and clean up
  1861. hRes = PutMethod(L"Get9XUserList", 0, NULL, pGet9XOutputArgs);
  1862. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1863. throw CX_MemoryException();
  1864. AddStaticQual(L"Get9XUserList");
  1865. // Add the "uint32 SetSD([in, id(0)]uint8 sd[])" method
  1866. CParametersClass * pSetSDInputArgs = new CParametersClass;
  1867. if(pSetSDInputArgs == NULL)
  1868. throw CX_MemoryException();
  1869. pSetSDInputArgs->Init();
  1870. CParametersClass * pSetSDOutputArgs = new CParametersClass;
  1871. if(pSetSDOutputArgs == NULL)
  1872. throw CX_MemoryException();
  1873. pSetSDOutputArgs->Init();
  1874. CReleaseMe relMe2((IWbemClassObject*)pSetSDInputArgs);
  1875. CReleaseMe relMe3((IWbemClassObject*)pSetSDOutputArgs);
  1876. hRes = pSetSDInputArgs->SetPropValue(L"SD", &vEmpty, CIM_UINT8 | CIM_FLAG_ARRAY);
  1877. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1878. throw CX_MemoryException();
  1879. hRes = pSetSDInputArgs->SetPropQualifier(L"SD", L"in", 0, &vTrue);
  1880. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1881. throw CX_MemoryException();
  1882. hRes = pSetSDInputArgs->SetPropQualifier(L"SD", L"ID", 0, &vID);
  1883. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1884. throw CX_MemoryException();
  1885. hRes = pSetSDOutputArgs->SetPropValue(L"ReturnValue", &vEmpty, CIM_UINT32);
  1886. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1887. throw CX_MemoryException();
  1888. hRes = pSetSDOutputArgs->SetPropQualifier(L"ReturnValue", L"out", 0, &vTrue);
  1889. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1890. throw CX_MemoryException();
  1891. // Add the method
  1892. hRes = PutMethod(L"SetSD", 0, pSetSDInputArgs, pSetSDOutputArgs);
  1893. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1894. throw CX_MemoryException();
  1895. AddStaticQual(L"SetSD");
  1896. // Add the "uint32 Set9XUserList([in, id(0)]instance of __NTLMUser9X ul[])" method
  1897. CParametersClass * pSet9XInputArgs = new CParametersClass;
  1898. if(pSet9XInputArgs == NULL)
  1899. throw CX_MemoryException();
  1900. pSet9XInputArgs->Init();
  1901. CParametersClass * pSet9XOutputArgs = new CParametersClass;
  1902. if(pSet9XOutputArgs == NULL)
  1903. throw CX_MemoryException();
  1904. pSet9XOutputArgs->Init();
  1905. CReleaseMe relMe4((IWbemClassObject*)pSet9XInputArgs);
  1906. CReleaseMe relMe5((IWbemClassObject*)pSet9XOutputArgs);
  1907. hRes = pSet9XInputArgs->SetPropValue(L"ul", &vEmpty, CIM_OBJECT | CIM_FLAG_ARRAY);
  1908. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1909. throw CX_MemoryException();
  1910. hRes = pSet9XInputArgs->SetPropQualifier(L"ul", L"in", 0, &vTrue);
  1911. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1912. throw CX_MemoryException();
  1913. hRes = pSet9XInputArgs->SetPropQualifier(L"ul", L"ID", 0, &vID);
  1914. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1915. throw CX_MemoryException();
  1916. CVar vCimType;
  1917. vCimType.SetBSTR(L"object:__ntlmuser9x");
  1918. hRes = pSet9XInputArgs->SetPropQualifier(L"ul", L"CIMTYPE", 0, &vCimType);
  1919. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1920. throw CX_MemoryException();
  1921. hRes = pSet9XOutputArgs->SetPropValue(L"ReturnValue", &vEmpty, CIM_UINT32);
  1922. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1923. throw CX_MemoryException();
  1924. hRes = pSet9XOutputArgs->SetPropQualifier(L"ReturnValue", L"out", 0, &vTrue);
  1925. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1926. throw CX_MemoryException();
  1927. // Add the method
  1928. hRes = PutMethod(L"Set9XUserList", 0, pSet9XInputArgs, pSet9XOutputArgs);
  1929. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1930. throw CX_MemoryException();
  1931. AddStaticQual(L"Set9XUserList");
  1932. // Add the "uint32 GetCallerAccessRights([out, id(0)]sint32 rights)" method
  1933. CParametersClass * pGetCallerAccessOutputArgs = new CParametersClass;
  1934. if(pGetCallerAccessOutputArgs == NULL)
  1935. throw CX_MemoryException();
  1936. pGetCallerAccessOutputArgs->Init();
  1937. CReleaseMe relMe6((IWbemClassObject*)pGetCallerAccessOutputArgs);
  1938. hRes = pGetCallerAccessOutputArgs->SetPropValue(L"ReturnValue", &vEmpty, CIM_UINT32);
  1939. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1940. throw CX_MemoryException();
  1941. hRes = pGetCallerAccessOutputArgs->SetPropQualifier(L"ReturnValue", L"out", 0, &vTrue);
  1942. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1943. throw CX_MemoryException();
  1944. hRes = pGetCallerAccessOutputArgs->SetPropValue(L"rights", &vEmpty, CIM_SINT32);
  1945. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1946. throw CX_MemoryException();
  1947. hRes = pGetCallerAccessOutputArgs->SetPropQualifier(L"rights", L"out", 0, &vTrue);
  1948. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1949. throw CX_MemoryException();
  1950. hRes = pGetCallerAccessOutputArgs->SetPropQualifier(L"rights", L"ID", 0, &vID);
  1951. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1952. throw CX_MemoryException();
  1953. // Add the method and clean up
  1954. hRes = PutMethod(L"GetCallerAccessRights", 0, NULL, pGetCallerAccessOutputArgs);
  1955. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1956. throw CX_MemoryException();
  1957. AddStaticQual(L"GetCallerAccessRights");
  1958. }
  1959. void CSystemConfigInstance::Init(CSystemConfigClass* pClass)
  1960. {
  1961. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  1962. throw CX_MemoryException();
  1963. }
  1964. //******************************************************************************
  1965. void CErrorObjectClass::Init()
  1966. {
  1967. CNotifyStatusClass NotifyClass;
  1968. NotifyClass.Init();
  1969. HRESULT hRes = CreateDerivedClass(&NotifyClass);
  1970. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1971. throw CX_MemoryException();
  1972. CVar v(VT_BSTR, L"__ExtendedStatus");
  1973. hRes = SetPropValue(L"__CLASS", &v, 0);
  1974. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1975. throw CX_MemoryException();
  1976. CVar vEmpty;
  1977. vEmpty.SetAsNull();
  1978. hRes = SetPropValue(L"ProviderName", &vEmpty, CIM_STRING);
  1979. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1980. throw CX_MemoryException();
  1981. hRes = SetPropValue(L"Operation", &vEmpty, CIM_STRING);
  1982. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1983. throw CX_MemoryException();
  1984. hRes = SetPropValue(L"ParameterInfo", &vEmpty, CIM_STRING);
  1985. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1986. throw CX_MemoryException();
  1987. hRes = SetPropValue(L"Description", &vEmpty, CIM_STRING);
  1988. if (hRes == WBEM_E_OUT_OF_MEMORY)
  1989. throw CX_MemoryException();
  1990. }
  1991. CErrorObjectClass* CErrorObject::mstatic_pClass = NULL;
  1992. CStaticCritSec CErrorObject::mstatic_cs;
  1993. CErrorObject::__CleanUp CErrorObject::cleanup;
  1994. CErrorObject::CErrorObject(ADDREF IWbemClassObject* pObject)
  1995. {
  1996. // Check for proper inheritance if we have an object.
  1997. // Throw an OOM exception if we hit an OOM error condition.
  1998. HRESULT hres = ( NULL != pObject ?
  1999. pObject->InheritsFrom( L"__ExtendedStatus" ) :
  2000. WBEM_E_FAILED );
  2001. if( S_OK == hres )
  2002. {
  2003. m_pObject = (CWbemInstance*)pObject;
  2004. m_pObject->AddRef();
  2005. }
  2006. else if ( WBEM_E_OUT_OF_MEMORY == hres )
  2007. {
  2008. throw CX_MemoryException();
  2009. }
  2010. else
  2011. {
  2012. CInCritSec local_lock (&mstatic_cs); // SEC:REVIEWED 2002-03-22 : Assumes entry
  2013. if(mstatic_pClass == NULL)
  2014. {
  2015. wmilib::auto_ptr<CErrorObjectClass> p(new CErrorObjectClass);
  2016. if (p.get() == 0)
  2017. {
  2018. throw CX_MemoryException();
  2019. }
  2020. p->Init();
  2021. mstatic_pClass = p.release();
  2022. }
  2023. m_pObject = new CWbemInstance;
  2024. if (m_pObject == 0)
  2025. throw CX_MemoryException();
  2026. // Only reason this fails is OOM
  2027. if ( FAILED( m_pObject->InitNew(mstatic_pClass, NEW_INSTANCE_PRECREATE_SIZE) ) )
  2028. {
  2029. throw CX_MemoryException();
  2030. }
  2031. }
  2032. }
  2033. CErrorObject::~CErrorObject()
  2034. {
  2035. m_pObject->Release();
  2036. }
  2037. RELEASE_ME IWbemClassObject* CErrorObject::GetObject()
  2038. {
  2039. m_pObject->AddRef();
  2040. return (IWbemClassObject*)m_pObject;
  2041. }
  2042. BOOL CErrorObject::SetStatusCode(SCODE sRes)
  2043. {
  2044. CVar v((LONG)sRes);
  2045. HRESULT hRes = m_pObject->SetPropValue(L"StatusCode", &v, 0);
  2046. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2047. throw CX_MemoryException();
  2048. return SUCCEEDED(hRes);
  2049. }
  2050. BOOL CErrorObject::SetOperation(COPY LPWSTR wszOperation)
  2051. {
  2052. CVar vOldOperation;
  2053. HRESULT hRes = m_pObject->GetProperty(L"Operation", &vOldOperation);
  2054. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2055. throw CX_MemoryException();
  2056. if(vOldOperation.IsNull())
  2057. {
  2058. CVar v(VT_BSTR, wszOperation);
  2059. hRes = m_pObject->SetPropValue(L"Operation", &v, 0);
  2060. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2061. throw CX_MemoryException();
  2062. return SUCCEEDED(hRes);
  2063. }
  2064. else return FALSE;
  2065. }
  2066. BOOL CErrorObject::SetParamInformation(COPY LPWSTR wszExtraInfo)
  2067. {
  2068. CVar vOldInfo;
  2069. HRESULT hRes = m_pObject->GetProperty(L"ParameterInfo", &vOldInfo);
  2070. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2071. throw CX_MemoryException();
  2072. if(vOldInfo.IsNull())
  2073. {
  2074. CVar v(VT_BSTR, wszExtraInfo);
  2075. hRes = m_pObject->SetPropValue(L"ParameterInfo", &v, 0);
  2076. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2077. throw CX_MemoryException();
  2078. return SUCCEEDED(hRes);
  2079. }
  2080. else return FALSE;
  2081. }
  2082. BOOL CErrorObject::SetProviderName(COPY LPWSTR wszName)
  2083. {
  2084. // Check if already set
  2085. // ====================
  2086. CVar vOldName;
  2087. HRESULT hRes = m_pObject->GetProperty(L"ProviderName", &vOldName);
  2088. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2089. throw CX_MemoryException();
  2090. if(vOldName.IsNull() || vOldName.GetType() == VT_EMPTY ||
  2091. !wbem_wcsicmp(vOldName.GetLPWSTR(), L"WinMgmt"))
  2092. {
  2093. CVar v(VT_BSTR, wszName);
  2094. hRes = m_pObject->SetPropValue(L"ProviderName", &v, 0);
  2095. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2096. throw CX_MemoryException();
  2097. return SUCCEEDED(hRes);
  2098. }
  2099. else return WBEM_S_NO_ERROR;
  2100. }
  2101. BOOL CErrorObject::MarkAsInternal()
  2102. {
  2103. return SetProviderName(L"WinMgmt");
  2104. }
  2105. BOOL CErrorObject::ContainsOperationInfo()
  2106. {
  2107. CVar v;
  2108. HRESULT hRes = m_pObject->GetProperty(L"Operation", &v);
  2109. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2110. throw CX_MemoryException();
  2111. if(FAILED(hRes))
  2112. return FALSE;
  2113. return !v.IsNull();
  2114. }
  2115. BOOL CErrorObject::ContainsStatusCode()
  2116. {
  2117. CVar v;
  2118. HRESULT hRes = m_pObject->GetProperty(L"StatusCode", &v);
  2119. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2120. throw CX_MemoryException();
  2121. if(FAILED(hRes))
  2122. return FALSE;
  2123. return !v.IsNull();
  2124. }
  2125. //******************************************************************************
  2126. /*
  2127. Blackcomb only
  2128. LPCWSTR g_awszTxnClass[] = { L"Prestart", L"Pending", L"Precommit", L"Commit", L"EventPlayback", L"Completed", L"RolledBack",
  2129. L"Cleanup", L"Fatal" };
  2130. void CTransactionClass::Init()
  2131. {
  2132. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2133. CVar v(VT_BSTR, L"__Transaction");
  2134. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2135. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2136. throw CX_MemoryException();
  2137. CVar vNull;
  2138. vNull.SetAsNull();
  2139. hRes = SetPropValue(L"GUID", &vNull, CIM_STRING);
  2140. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2141. throw CX_MemoryException();
  2142. // Mark GUID as key
  2143. // ================
  2144. CVar vb(VARIANT_TRUE, VT_BOOL);
  2145. hRes = SetPropQualifier(L"GUID", L"key", 0, &vb);
  2146. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2147. throw CX_MemoryException();
  2148. hRes = SetPropValue(L"ClientComment", &vNull, CIM_STRING);
  2149. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2150. throw CX_MemoryException();
  2151. hRes = SetPropValue(L"ClientID", &vNull, CIM_STRING);
  2152. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2153. throw CX_MemoryException();
  2154. hRes = SetPropValue(L"State", &vNull, CIM_UINT32);
  2155. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2156. throw CX_MemoryException();
  2157. SAFEARRAY *pArray = NULL;
  2158. SAFEARRAYBOUND aBounds[1];
  2159. long lLBound = 0, lUBound = 9;
  2160. aBounds[0].cElements = lUBound;
  2161. aBounds[0].lLbound = 0;
  2162. pArray = SafeArrayCreate(VT_BSTR, 1, aBounds);
  2163. if (pArray)
  2164. {
  2165. long lNumElements = sizeof(g_awszTxnClass)/sizeof(LPCWSTR);
  2166. for ( long lCtr = 0; lCtr < lNumElements; lCtr++ )
  2167. {
  2168. BSTR bstrTemp = SysAllocString( g_awszTxnClass[lCtr] );
  2169. if ( NULL == bstrTemp )
  2170. {
  2171. throw CX_MemoryException();
  2172. }
  2173. // SafeArrayPutElement copies the BSTR so we still have to free it
  2174. CSysFreeMe sfm( bstrTemp );
  2175. long lTemp[1];
  2176. lTemp[0] = lCtr;
  2177. if ( FAILED( SafeArrayPutElement(pArray, lTemp, bstrTemp) ) )
  2178. {
  2179. throw CX_MemoryException();
  2180. }
  2181. }
  2182. CVar vc(VT_BSTR, pArray);
  2183. hRes = SetPropQualifier(L"State", L"values", VALUES_FLAVOR, &vc);
  2184. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2185. throw CX_MemoryException();
  2186. // We won't need the safe array anymore, so go ahead and destroy it
  2187. SafeArrayDestroy( pArray );
  2188. }
  2189. hRes = SetPropValue(L"Start", &vNull, CIM_DATETIME);
  2190. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2191. throw CX_MemoryException();
  2192. hRes = SetPropValue(L"LastUpdate", &vNull, CIM_DATETIME);
  2193. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2194. throw CX_MemoryException();
  2195. }
  2196. void CUncommittedEventClass::Init()
  2197. {
  2198. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2199. CVar v(VT_BSTR, L"__UncommittedEvent");
  2200. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2201. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2202. throw CX_MemoryException();
  2203. CVar vNull;
  2204. vNull.SetAsNull();
  2205. hRes = SetPropValue(L"EventID", &vNull, CIM_UINT32);
  2206. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2207. throw CX_MemoryException();
  2208. // Mark EventID as key, keyhole.
  2209. // =============================
  2210. CVar vb(VARIANT_TRUE, VT_BOOL);
  2211. hRes = SetPropQualifier(L"EventID", L"key", 0, &vb);
  2212. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2213. throw CX_MemoryException();
  2214. hRes = SetPropQualifier(L"EventID", L"keyhole", 0, &vb);
  2215. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2216. throw CX_MemoryException();
  2217. // Transaction GUID is indexed
  2218. // ===========================
  2219. hRes = SetPropValue(L"TransactionGUID", &vNull, CIM_STRING);
  2220. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2221. throw CX_MemoryException();
  2222. hRes = SetPropQualifier(L"TransactionGUID", L"indexed", 0, &vb);
  2223. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2224. throw CX_MemoryException();
  2225. hRes = SetPropValue(L"NamespaceName", &vNull, CIM_STRING);
  2226. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2227. throw CX_MemoryException();
  2228. hRes = SetPropValue(L"ClassName", &vNull, CIM_STRING);
  2229. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2230. throw CX_MemoryException();
  2231. hRes = SetPropValue(L"OldObject", &vNull, CIM_OBJECT);
  2232. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2233. throw CX_MemoryException();
  2234. hRes = SetPropValue(L"NewObject", &vNull, CIM_OBJECT);
  2235. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2236. throw CX_MemoryException();
  2237. hRes = SetPropValue(L"Transacted", &vNull, CIM_BOOLEAN);
  2238. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2239. throw CX_MemoryException();
  2240. }
  2241. */
  2242. //******************************************************************************
  2243. /*
  2244. void CNamespaceMapClass::Init()
  2245. {
  2246. CNamespaceClass NsBase;
  2247. NsBase.Init();
  2248. HRESULT hRes = CreateDerivedClass(&NsBase);
  2249. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2250. throw CX_MemoryException();
  2251. CVar v(VT_BSTR, L"__WmiMappedDriverNamespace");
  2252. hRes = SetPropValue(L"__CLASS", &v, 0);
  2253. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2254. throw CX_MemoryException();
  2255. CVar vNull;
  2256. vNull.SetAsNull();
  2257. hRes = SetPropValue(L"CLSID", &vNull, CIM_STRING);
  2258. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2259. throw CX_MemoryException();
  2260. hRes = SetPropValue(L"Server", &vNull, CIM_STRING);
  2261. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2262. throw CX_MemoryException();
  2263. hRes = SetPropValue(L"Database", &vNull, CIM_STRING);
  2264. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2265. throw CX_MemoryException();
  2266. hRes = SetPropValue(L"UserID", &vNull, CIM_STRING);
  2267. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2268. throw CX_MemoryException();
  2269. hRes = SetPropValue(L"Password", &vNull, CIM_STRING);
  2270. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2271. throw CX_MemoryException();
  2272. hRes = SetPropValue(L"Config", &vNull, CIM_STRING);
  2273. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2274. throw CX_MemoryException();
  2275. }
  2276. */
  2277. //******************************************************************************
  2278. /* The following system classes were removed for Whistler, but may
  2279. be reintroduced for Blackcomb
  2280. void CClassInstanceSecurity::Init()
  2281. {
  2282. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2283. CVar v(VT_BSTR, L"__ClassInstancesSecurity");
  2284. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2285. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2286. throw CX_MemoryException();
  2287. CVar vNull;
  2288. vNull.SetAsNull();
  2289. hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  2290. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2291. throw CX_MemoryException();
  2292. CVar vb(VARIANT_TRUE, VT_BOOL);
  2293. hRes = SetPropQualifier(L"Name", L"key", 0, &vb);
  2294. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2295. throw CX_MemoryException();
  2296. }
  2297. void CClassSecurity::Init()
  2298. {
  2299. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2300. CVar v(VT_BSTR, L"__ClassSecurity");
  2301. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2302. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2303. throw CX_MemoryException();
  2304. CVar vNull;
  2305. vNull.SetAsNull();
  2306. hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  2307. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2308. throw CX_MemoryException();
  2309. CVar vb(VARIANT_TRUE, VT_BOOL);
  2310. hRes = SetPropQualifier(L"Name", L"key", 0, &vb);
  2311. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2312. throw CX_MemoryException();
  2313. }
  2314. */
  2315. void CClasses::Init()
  2316. {
  2317. if ( FAILED( InitEmpty(NEW_CLASS_PRECREATE_SIZE) ) )
  2318. {
  2319. throw CX_MemoryException();
  2320. }
  2321. CVar v(VT_BSTR, L"__Classes");
  2322. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2323. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2324. throw CX_MemoryException();
  2325. CVar vb(VARIANT_TRUE, VT_BOOL);
  2326. hRes = SetQualifier(L"singleton", &vb, SINGLETON_FLAVOR);
  2327. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2328. throw CX_MemoryException();
  2329. }
  2330. //================================================================
  2331. struct { const wchar_t *wszPropName; DWORD dwPropValue; } g_arbitratorConfigurationDefaults[] =
  2332. {
  2333. { L"OutstandingTasksTotal", 3000 }, //Total
  2334. { L"OutstandingTasksPerUser", 30 }, //Total
  2335. { L"TaskThreadsTotal", 30 }, //Total
  2336. { L"TaskThreadsPerUser", 3 }, //Total
  2337. { L"QuotaRetryCount", 10 }, //Total
  2338. { L"QuotaRetryWaitInterval", 15000 }, //Milliseconds
  2339. { L"TotalUsers", 50 }, //Total
  2340. { L"TotalCacheMemoryPerTask", 1024 }, //1 MB
  2341. { L"TotalCacheMemoryPerUser", 2048 }, //2 MB
  2342. { L"TotalCacheMemory", 10240 }, //10 MB
  2343. { L"TotalCacheDiskPerTask", 51250 }, //50 MB
  2344. { L"TotalCacheDiskPerUser", 102500 }, //100 MB
  2345. { L"TotalCacheDisk", 1048576 }, //1 GB
  2346. { L"TemporarySubscriptionsPerUser", 1000 }, //Total
  2347. { L"PermanentSubscriptionsPerUser", 1000 }, //Total
  2348. { L"PollingInstructionsPerUser", 1000 }, //Total
  2349. { L"PollingMemoryPerUser", 5000000 }, //Total
  2350. { L"TemporarySubscriptionsTotal", 10000 }, //Total
  2351. { L"PermanentSubscriptionsTotal", 10000 }, //Total
  2352. { L"PollingInstructionsTotal", 10000 }, //Total
  2353. { L"PollingMemoryTotal", 10000000 }, //Total
  2354. { NULL, 0 }
  2355. };
  2356. void CArbitratorConfiguration::Init()
  2357. {
  2358. //This is derived from __SystemClass
  2359. CSystemClass System;
  2360. System.Init();
  2361. HRESULT hRes = CreateDerivedClass(&System);
  2362. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2363. throw CX_MemoryException();
  2364. //Set class name
  2365. {
  2366. CVar v(VT_BSTR, L"__ArbitratorConfiguration");
  2367. hRes = SetPropValue(L"__CLASS", &v, 0);
  2368. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2369. throw CX_MemoryException();
  2370. }
  2371. //Singleton object
  2372. {
  2373. CVar vk(VARIANT_TRUE, VT_BOOL);
  2374. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  2375. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2376. throw CX_MemoryException();
  2377. }
  2378. //Add properties
  2379. CVar vs;
  2380. vs.SetAsNull();
  2381. for (int i = 0; g_arbitratorConfigurationDefaults[i].wszPropName != NULL; i++)
  2382. {
  2383. hRes = SetPropValue(g_arbitratorConfigurationDefaults[i].wszPropName, &vs, CIM_UINT32);
  2384. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2385. throw CX_MemoryException();
  2386. }
  2387. }
  2388. void CArbitratorConfigurationInstance::Init(CArbitratorConfiguration* pClass)
  2389. {
  2390. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  2391. throw CX_MemoryException();
  2392. //Set propery values
  2393. for (int i = 0; g_arbitratorConfigurationDefaults[i].wszPropName != NULL; i++)
  2394. {
  2395. CVar var;
  2396. var.SetLong(g_arbitratorConfigurationDefaults[i].dwPropValue);
  2397. HRESULT hRes = SetPropValue(g_arbitratorConfigurationDefaults[i].wszPropName, &var, 0);
  2398. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2399. throw CX_MemoryException();
  2400. }
  2401. }
  2402. /******************************************************************************
  2403. *
  2404. * Name:
  2405. *
  2406. *
  2407. * Description:
  2408. *
  2409. *
  2410. *****************************************************************************/
  2411. struct { const wchar_t *wszPropName; UINT32 dwPropValue; } g_ProviderHostQuotaConfigurationDefaultsUint32[] =
  2412. {
  2413. { L"ThreadsPerHost", 0x00000100 },
  2414. { L"HandlesPerHost", 0x00001000 },
  2415. { L"ProcessLimitAllHosts", 0x00000020 },
  2416. { NULL, 0 }
  2417. } ;
  2418. struct { const wchar_t *wszPropName; UINT64 dwPropValue; } g_ProviderHostQuotaConfigurationDefaultsUint64[] =
  2419. {
  2420. { L"MemoryPerHost", 0x0000000008000000 },
  2421. { L"MemoryAllHosts", 0x0000000040000000 },
  2422. { NULL, 0 }
  2423. } ;
  2424. /******************************************************************************
  2425. *
  2426. * Name:
  2427. *
  2428. *
  2429. * Description:
  2430. *
  2431. *
  2432. *****************************************************************************/
  2433. void CProviderHostQuotaConfiguration::Init()
  2434. {
  2435. //This is derived from __SystemClass
  2436. CSystemClass System;
  2437. System.Init();
  2438. HRESULT hRes = CreateDerivedClass(&System);
  2439. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2440. throw CX_MemoryException();
  2441. //Set class name
  2442. {
  2443. CVar v(VT_BSTR, L"__ProviderHostQuotaConfiguration");
  2444. hRes = SetPropValue(L"__CLASS", &v, 0);
  2445. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2446. throw CX_MemoryException();
  2447. }
  2448. //Singleton object
  2449. {
  2450. CVar vk(VARIANT_TRUE, VT_BOOL);
  2451. hRes = SetQualifier(L"singleton", &vk, SINGLETON_FLAVOR);
  2452. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2453. throw CX_MemoryException();
  2454. }
  2455. //Add properties
  2456. CVar vs;
  2457. vs.SetAsNull();
  2458. for (int i = 0; g_ProviderHostQuotaConfigurationDefaultsUint32[i].wszPropName != NULL; i++)
  2459. {
  2460. hRes = SetPropValue(g_ProviderHostQuotaConfigurationDefaultsUint32[i].wszPropName, &vs, CIM_UINT32);
  2461. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2462. throw CX_MemoryException();
  2463. }
  2464. for (i = 0; g_ProviderHostQuotaConfigurationDefaultsUint64[i].wszPropName != NULL; i++)
  2465. {
  2466. hRes = SetPropValue(g_ProviderHostQuotaConfigurationDefaultsUint64[i].wszPropName, &vs, CIM_UINT64);
  2467. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2468. throw CX_MemoryException();
  2469. }
  2470. }
  2471. /******************************************************************************
  2472. *
  2473. * Name:
  2474. *
  2475. *
  2476. * Description:
  2477. *
  2478. *
  2479. *****************************************************************************/
  2480. void CProviderHostQuotaConfigurationInstance::Init(CProviderHostQuotaConfiguration* pClass)
  2481. {
  2482. if (FAILED(InitNew(pClass, NEW_INSTANCE_PRECREATE_SIZE)))
  2483. throw CX_MemoryException();
  2484. //Set propery values
  2485. for (int i = 0; g_ProviderHostQuotaConfigurationDefaultsUint32[i].wszPropName != NULL; i++)
  2486. {
  2487. CVar var;
  2488. var.SetLong(g_ProviderHostQuotaConfigurationDefaultsUint32[i].dwPropValue);
  2489. HRESULT hRes = SetPropValue(g_ProviderHostQuotaConfigurationDefaultsUint32[i].wszPropName, &var, 0);
  2490. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2491. throw CX_MemoryException();
  2492. }
  2493. _IWmiObject *t_FastThis = NULL ;
  2494. HRESULT hRes = QueryInterface ( IID__IWmiObject , ( void ** ) & t_FastThis ) ;
  2495. if ( SUCCEEDED ( hRes ) )
  2496. {
  2497. for (i = 0; g_ProviderHostQuotaConfigurationDefaultsUint64[i].wszPropName != NULL; i++)
  2498. {
  2499. hRes = t_FastThis->WriteProp (
  2500. g_ProviderHostQuotaConfigurationDefaultsUint64[i].wszPropName,
  2501. 0 ,
  2502. sizeof ( UINT64 ) ,
  2503. 1 ,
  2504. CIM_UINT64 ,
  2505. & g_ProviderHostQuotaConfigurationDefaultsUint64[i].dwPropValue
  2506. ) ;
  2507. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2508. throw CX_MemoryException();
  2509. }
  2510. t_FastThis->Release () ;
  2511. }
  2512. }
  2513. /*
  2514. Removed for Whistler
  2515. void CComTaxonomyClass::Init()
  2516. {
  2517. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2518. CVar v(VT_BSTR, L"__COMTaxonomy");
  2519. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2520. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2521. throw CX_MemoryException();
  2522. CVar vk(VARIANT_TRUE, VT_BOOL);
  2523. hRes = SetQualifier(L"abstract", &vk, ABSTRACT_FLAVOR);
  2524. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2525. throw CX_MemoryException();
  2526. }
  2527. void CComInterfaceSetClass::Init()
  2528. {
  2529. CComTaxonomyClass ComTaxonomy;
  2530. ComTaxonomy.Init();
  2531. HRESULT hRes = CreateDerivedClass(&ComTaxonomy);
  2532. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2533. throw CX_MemoryException();
  2534. CVar v(VT_BSTR, L"__COMInterfaceSet");
  2535. hRes = SetPropValue(L"__CLASS", &v, 0);
  2536. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2537. throw CX_MemoryException();
  2538. CVar vNull;
  2539. vNull.SetAsNull();
  2540. hRes = SetPropValue(L"CLSID", &vNull, CIM_STRING);
  2541. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2542. throw CX_MemoryException();
  2543. // Mark CLSID as 'key'.
  2544. // ===================
  2545. CVar vb(VARIANT_TRUE, VT_BOOL);
  2546. hRes = SetPropQualifier(L"CLSID", L"key", 0, &vb);
  2547. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2548. throw CX_MemoryException();
  2549. hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  2550. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2551. throw CX_MemoryException();
  2552. hRes = SetPropValue(L"IID", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  2553. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2554. throw CX_MemoryException();
  2555. hRes = SetPropValue(L"IIDNames", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  2556. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2557. throw CX_MemoryException();
  2558. }
  2559. void CComDispatchElementClass::Init()
  2560. {
  2561. CComTaxonomyClass ComTaxonomy;
  2562. ComTaxonomy.Init();
  2563. HRESULT hRes = CreateDerivedClass(&ComTaxonomy);
  2564. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2565. throw CX_MemoryException();
  2566. CVar v(VT_BSTR, L"__COMDispatchElement");
  2567. hRes = SetPropValue(L"__CLASS", &v, 0);
  2568. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2569. throw CX_MemoryException();
  2570. CVar vNull;
  2571. vNull.SetAsNull();
  2572. hRes = SetPropValue(L"CLSID", &vNull, CIM_STRING);
  2573. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2574. throw CX_MemoryException();
  2575. hRes = SetPropValue(L"DISPID", &vNull, CIM_SINT32);
  2576. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2577. throw CX_MemoryException();
  2578. // Mark CLSID and DispId as 'key'.
  2579. // ===================
  2580. CVar vb(VARIANT_TRUE, VT_BOOL);
  2581. hRes = SetPropQualifier(L"CLSID", L"key", 0, &vb);
  2582. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2583. throw CX_MemoryException();
  2584. hRes = SetPropQualifier(L"DISPID", L"key", 0, &vb);
  2585. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2586. throw CX_MemoryException();
  2587. hRes = SetPropValue(L"Name", &vNull, CIM_STRING);
  2588. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2589. throw CX_MemoryException();
  2590. hRes = SetPropValue(L"NamedArguments", &vNull, CIM_STRING | CIM_FLAG_ARRAY );
  2591. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2592. throw CX_MemoryException();
  2593. hRes = SetPropValue(L"NamedArgumentDISPIDs", &vNull, CIM_SINT32 | CIM_FLAG_ARRAY);
  2594. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2595. throw CX_MemoryException();
  2596. hRes = SetPropValue(L"NamedArgumentTypes", &vNull, CIM_STRING | CIM_FLAG_ARRAY);
  2597. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2598. throw CX_MemoryException();
  2599. }
  2600. void CComDispatchInfoClass::Init()
  2601. {
  2602. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2603. CVar v(VT_BSTR, L"__COMDispatchInfo");
  2604. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2605. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2606. throw CX_MemoryException();
  2607. CVar vNull;
  2608. vNull.SetAsNull();
  2609. hRes = SetPropValue(L"CLSID", &vNull, CIM_STRING);
  2610. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2611. throw CX_MemoryException();
  2612. hRes = SetPropValue(L"DISPID", &vNull, CIM_SINT32);
  2613. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2614. throw CX_MemoryException();
  2615. hRes = SetPropValue(L"NamedArgumentDISPIDs", &vNull, CIM_SINT32 | CIM_FLAG_ARRAY );
  2616. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2617. throw CX_MemoryException();
  2618. }
  2619. void CComBindingClass::Init()
  2620. {
  2621. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2622. CVar v(VT_BSTR, L"__COMBinding");
  2623. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2624. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2625. throw CX_MemoryException();
  2626. CVar vt(VARIANT_TRUE, VT_BOOL);
  2627. hRes = SetQualifier(L"abstract", &vt, ABSTRACT_FLAVOR);
  2628. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2629. throw CX_MemoryException();
  2630. }
  2631. void CComInterfaceSetBindingClass::Init()
  2632. {
  2633. CComBindingClass ComBinding;
  2634. ComBinding.Init();
  2635. HRESULT hRes = CreateDerivedClass(&ComBinding);
  2636. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2637. throw CX_MemoryException();
  2638. CVar v(VT_BSTR, L"__COMInterfaceSetToClassBinding");
  2639. hRes = SetPropValue(L"__CLASS", &v, 0);
  2640. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2641. throw CX_MemoryException();
  2642. // Association
  2643. CVar vt(VARIANT_TRUE, VT_BOOL);
  2644. hRes = SetQualifier(L"association", &vt, ASSOC_FLAVOR);
  2645. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2646. throw CX_MemoryException();
  2647. // HasClassRefs
  2648. hRes = SetQualifier(L"HasClassRefs", &vt, ASSOC_FLAVOR);
  2649. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2650. throw CX_MemoryException();
  2651. CVar vNull;
  2652. vNull.SetAsNull();
  2653. hRes = SetPropValue(L"InterfaceSet", &vNull, CIM_REFERENCE);
  2654. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2655. throw CX_MemoryException();
  2656. hRes = SetPropValue(L"TargetClass", &vNull, CIM_REFERENCE);
  2657. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2658. throw CX_MemoryException();
  2659. // Mark proeprties as 'key'.
  2660. // ===================
  2661. CVar vb(VARIANT_TRUE, VT_BOOL);
  2662. hRes = SetPropQualifier(L"InterfaceSet", L"key", 0, &vb);
  2663. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2664. throw CX_MemoryException();
  2665. hRes = SetPropQualifier(L"TargetClass", L"key", 0, &vb);
  2666. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2667. throw CX_MemoryException();
  2668. // Both properties are strongly typed references.
  2669. v.Empty();
  2670. v.SetBSTR( L"ref:__COMInterfaceSet" );
  2671. hRes = SetPropQualifier(L"InterfaceSet", L"CIMTYPE", 0, &v);
  2672. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2673. throw CX_MemoryException();
  2674. v.Empty();
  2675. v.SetBSTR( L"ref:__ClassVector" );
  2676. hRes = SetPropQualifier(L"TargetClass", L"CIMTYPE", 0, &v);
  2677. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2678. throw CX_MemoryException();
  2679. }
  2680. void CComDispatchElementBindingClass::Init()
  2681. {
  2682. CComBindingClass ComBinding;
  2683. ComBinding.Init();
  2684. HRESULT hRes = CreateDerivedClass(&ComBinding);
  2685. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2686. throw CX_MemoryException();
  2687. CVar v(VT_BSTR, L"__COMDispatchElementToClassBinding");
  2688. hRes = SetPropValue(L"__CLASS", &v, 0);
  2689. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2690. throw CX_MemoryException();
  2691. // Association
  2692. CVar vt(VARIANT_TRUE, VT_BOOL);
  2693. hRes = SetQualifier(L"association", &vt, ASSOC_FLAVOR);
  2694. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2695. throw CX_MemoryException();
  2696. // HasClassRefs
  2697. hRes = SetQualifier(L"HasClassRefs", &vt, ASSOC_FLAVOR);
  2698. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2699. throw CX_MemoryException();
  2700. CVar vNull;
  2701. vNull.SetAsNull();
  2702. hRes = SetPropValue(L"DispatchElement", &vNull, CIM_REFERENCE);
  2703. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2704. throw CX_MemoryException();
  2705. hRes = SetPropValue(L"TargetClass", &vNull, CIM_REFERENCE);
  2706. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2707. throw CX_MemoryException();
  2708. // Mark proeprties as 'key'.
  2709. // ===================
  2710. CVar vb(VARIANT_TRUE, VT_BOOL);
  2711. hRes = SetPropQualifier(L"DispatchElement", L"key", 0, &vb);
  2712. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2713. throw CX_MemoryException();
  2714. hRes = SetPropQualifier(L"TargetClass", L"key", 0, &vb);
  2715. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2716. throw CX_MemoryException();
  2717. // Both properties are strongly typed references.
  2718. v.Empty();
  2719. v.SetBSTR( L"ref:__COMDispatchElement" );
  2720. hRes = SetPropQualifier(L"DispatchElement", L"CIMTYPE", 0, &v);
  2721. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2722. throw CX_MemoryException();
  2723. v.Empty();
  2724. v.SetBSTR( L"ref:__ClassVector" );
  2725. hRes = SetPropQualifier(L"TargetClass", L"CIMTYPE", 0, &v);
  2726. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2727. throw CX_MemoryException();
  2728. }
  2729. void CClassVectorClass::Init()
  2730. {
  2731. InitEmpty(NEW_CLASS_PRECREATE_SIZE);
  2732. CVar v(VT_BSTR, L"__ClassVector");
  2733. HRESULT hRes = SetPropValue(L"__CLASS", &v, 0);
  2734. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2735. throw CX_MemoryException();
  2736. CVar vt(VARIANT_TRUE, VT_BOOL);
  2737. hRes = SetQualifier(L"vector", &vt, ABSTRACT_FLAVOR);
  2738. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2739. throw CX_MemoryException();
  2740. CVar vNull;
  2741. vNull.SetAsNull();
  2742. hRes = SetPropValue(L"ClassPath", &vNull, CIM_REFERENCE);
  2743. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2744. throw CX_MemoryException();
  2745. CVar vb(VARIANT_TRUE, VT_BOOL);
  2746. hRes = SetPropQualifier(L"ClassPath", L"key", 0, &vb);
  2747. if (hRes == WBEM_E_OUT_OF_MEMORY)
  2748. throw CX_MemoryException();
  2749. }
  2750. */