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.

388 lines
13 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Common.h
  7. //
  8. // Description:
  9. // Definition of common type, constant and header files.
  10. //
  11. // Maintained by:
  12. // Ozan Ozhan (OzanO) 26-NOV-2002
  13. // Henry Wang (HenryWa) 24-AUG-1999
  14. //
  15. // Notes:
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. #pragma once
  19. #pragma warning( disable : 4786 )
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Include Files
  22. //////////////////////////////////////////////////////////////////////////////
  23. using namespace std;
  24. class CProvBase;
  25. class CObjPath;
  26. class CWbemClassObject;
  27. extern long g_cObj;
  28. extern long g_cLock;
  29. typedef LPVOID * PPVOID;
  30. typedef CProvBase * ( * FPNEW )(
  31. IN LPCWSTR pwszName,
  32. IN CWbemServices * pNamespace,
  33. DWORD dwEnumType
  34. );
  35. typedef void ( * FPFILLWMI )(
  36. IN PVOID phCluster,
  37. IN PVOID phClusterObj,
  38. IN LPCWSTR pwszName,
  39. IN IWbemClassObject * pClass,
  40. IN IWbemServices * pServices,
  41. IN IWbemObjectSink * pHandler
  42. );
  43. LPWSTR PwszSpaceReplace(
  44. LPWSTR pwszTrgInout,
  45. LPCWSTR pwszSrcIn,
  46. WCHAR wchArgIn
  47. );
  48. enum PROP_TYPE
  49. {
  50. DWORD_TYPE,
  51. SZ_TYPE,
  52. MULTI_SZ_TYPE
  53. };
  54. enum ACCESS_TYPE
  55. {
  56. READONLY,
  57. READWRITE
  58. };
  59. //////////////////////////////////////////////////////////////////////////////
  60. //++
  61. //
  62. // typedef struct SPropMapEntry
  63. //
  64. // Description:
  65. // structure to map property name defined in mof
  66. // to the property name defined in wolfpack header.
  67. // PropertyType indicate the type of wolfpack properties.
  68. // Mof property is always in VARIANT format and it's type
  69. // is in vt field
  70. //
  71. //--
  72. //////////////////////////////////////////////////////////////////////////////
  73. struct SPropMapEntry
  74. {
  75. LPCWSTR mofName;
  76. LPCWSTR clstName;
  77. PROP_TYPE PropertyType;
  78. ACCESS_TYPE Access;
  79. };
  80. //////////////////////////////////////////////////////////////////////////////
  81. //++
  82. //
  83. // struct SPropMapEntryArray
  84. //
  85. // Description:
  86. // Array of SPropMapEntry
  87. //
  88. //--
  89. //////////////////////////////////////////////////////////////////////////////
  90. struct SPropMapEntryArray
  91. {
  92. SPropMapEntryArray(
  93. DWORD dwSizeIn,
  94. SPropMapEntry * pArrayIn
  95. )
  96. : m_dwSize( dwSizeIn )
  97. , m_pArray( pArrayIn )
  98. {
  99. }
  100. LPCWSTR PwszLookup( LPCWSTR pwszIn ) const;
  101. DWORD m_dwSize;
  102. SPropMapEntry * m_pArray;
  103. };
  104. struct SGetSetControl
  105. {
  106. DWORD dwGetControl;
  107. DWORD dwSetControl;
  108. BOOL fPrivate;
  109. };
  110. struct SGetControl
  111. {
  112. DWORD dwControl;
  113. BOOL fPrivate;
  114. };
  115. void CreateClass(
  116. const WCHAR * pwszClassNameIn,
  117. CWbemServices * pNamespaceIn,
  118. auto_ptr<CProvBase>& rNewClassInout
  119. );
  120. // CLUSTER
  121. extern const WCHAR * const PVD_CLASS_CLUSTER;
  122. extern const WCHAR * const PVD_CLASS_CLUSTERTONETWORK;
  123. extern const WCHAR * const PVD_CLASS_CLUSTERTONETINTERFACE;
  124. extern const WCHAR * const PVD_CLASS_CLUSTERTONODE;
  125. extern const WCHAR * const PVD_CLASS_CLUSTERTOQUORUMRES;
  126. extern const WCHAR * const PVD_CLASS_CLUSTERTORES;
  127. extern const WCHAR * const PVD_CLASS_CLUSTERTORESTYPE;
  128. extern const WCHAR * const PVD_CLASS_CLUSTERTOGROUP;
  129. extern const WCHAR * const PVD_PROP_CLUSTER_SECURITY;
  130. extern const WCHAR * const PVD_PROP_CLUSTER_SECURITYDESCRIPTOR;
  131. extern const WCHAR * const PVD_PROP_CLUSTER_NAME;
  132. extern const WCHAR * const PVD_PROP_CLUSTER_GROUPADMIN;
  133. extern const WCHAR * const PVD_PROP_CLUSTER_NODEADMIN;
  134. extern const WCHAR * const PVD_PROP_CLUSTER_RESADMIN;
  135. extern const WCHAR * const PVD_PROP_CLUSTER_RESTYPEADMIN;
  136. extern const WCHAR * const PVD_PROP_CLUSTER_NETWORKADMIN;
  137. extern const WCHAR * const PVD_PROP_CLUSTER_NETINTFACEADMIN;
  138. extern const WCHAR * const PVD_PROP_CLUSTER_FILE;
  139. extern const WCHAR * const PVD_PROP_CLUSTER_LOGSIZE;
  140. extern const WCHAR * const PVD_PROP_CLUSTER_NETWORK;
  141. extern const WCHAR * const PVD_PROP_CLUSTER_MAX_NODES;
  142. extern const WCHAR * const CLUS_CLUS_GROUPADMIN;
  143. extern const WCHAR * const CLUS_CLUS_NETWORKADMIN;
  144. extern const WCHAR * const CLUS_CLUS_NETINTERFACEADMIN;
  145. extern const WCHAR * const CLUS_CLUS_NODEADMIN;
  146. extern const WCHAR * const CLUS_CLUS_RESADMIN;
  147. extern const WCHAR * const CLUS_CLUS_RESTYPEADMIN;
  148. extern const WCHAR * const PVD_MTH_CLUSTER_RENAME;
  149. extern const WCHAR * const PVD_MTH_CLUSTER_SETQUORUM;
  150. extern const WCHAR * const PVD_MTH_CLUSTER_GETNODECLUSTERSTATE;
  151. extern const WCHAR * const PVD_MTH_CLUSTER_PARM_NEWNAME;
  152. extern const WCHAR * const PVD_MTH_CLUSTER_PARM_RESOURCE;
  153. extern const WCHAR * const PVD_MTH_CLUSTER_PARM_CLUSTERSTATE;
  154. // NODE
  155. extern const WCHAR * const PVD_CLASS_NODE;
  156. extern const WCHAR * const PVD_CLASS_NODETOACTIVEGROUP;
  157. extern const WCHAR * const PVD_CLASS_NODETONETINTERFACE;
  158. extern const WCHAR * const PVD_CLASS_NODETOACTIVERES;
  159. extern const WCHAR * const PVD_PROP_NODE_NAME;
  160. // RESOURCE
  161. extern const WCHAR * const PVD_CLASS_RESOURCE;
  162. extern const WCHAR * const PVD_CLASS_RESDEPRES;
  163. extern const WCHAR * const PVD_CLASS_RESTYPERESOURCE;
  164. extern const WCHAR * const PVD_CLASS_RESOURCENODE;
  165. extern const WCHAR * const PVD_PROP_RES_NAME;
  166. extern const WCHAR * const PVD_PROP_RES_STATE;
  167. extern const WCHAR * const PVD_PROP_RES_PRIVATE;
  168. extern const WCHAR * const PVD_PROP_RES_CHECKPOINTS;
  169. extern const WCHAR * const PVD_PROP_RES_CRYPTO_CHECKPOINTS;
  170. extern const WCHAR * const PVD_PROP_RES_CORE_RESOURCE;
  171. extern const WCHAR * const PVD_MTH_RES_ONLINE;
  172. extern const WCHAR * const PVD_MTH_RES_OFFLINE;
  173. extern const WCHAR * const PVD_MTH_RES_ADD_DEPENDENCY;
  174. extern const WCHAR * const PVD_MTH_RES_CHANGE_GROUP;
  175. extern const WCHAR * const PVD_MTH_RES_CREATE_RESOURCE;
  176. extern const WCHAR * const PVD_MTH_RES_FAIL_RESOURCE;
  177. extern const WCHAR * const PVD_MTH_RES_REMOVE_DEPENDENCY;
  178. extern const WCHAR * const PVD_MTH_RES_RENAME;
  179. extern const WCHAR * const PVD_MTH_RES_DELETE_RESOURCE;
  180. extern const WCHAR * const PVD_MTH_RES_ADD_REG_CHECKPOINT;
  181. extern const WCHAR * const PVD_MTH_RES_DEL_REG_CHECKPOINT;
  182. extern const WCHAR * const PVD_MTH_RES_ADD_CRYPTO_CHECKPOINT;
  183. extern const WCHAR * const PVD_MTH_RES_DEL_CRYPTO_CHECKPOINT;
  184. extern const WCHAR * const PVD_MTH_PARM_RESOURCE;
  185. extern const WCHAR * const PVD_MTH_PARM_GROUP;
  186. extern const WCHAR * const PVD_MTH_PARM_NEWNAME;
  187. extern const WCHAR * const PVD_MTH_PARM_RES_NAME;
  188. extern const WCHAR * const PVD_MTH_PARM_RES_TYPE;
  189. extern const WCHAR * const PVD_MTH_PARM_SEP_MONITOR;
  190. extern const WCHAR * const PVD_MTH_PARM_RES_CHECKPOINT_NAME;
  191. extern const WCHAR * const PVD_MTH_PARM_RES_TIMEOUT;
  192. // RESOURCETYPE
  193. extern const WCHAR * const PVD_CLASS_RESOURCETYPE;
  194. extern const WCHAR * const PVD_PROP_RESTYPE_NAME;
  195. extern const WCHAR * const PVD_PROP_RESTYPE_DLLNAME;
  196. extern const WCHAR * const PVD_PROP_RESTYPE_ADMINEXTENSIONS;
  197. extern const WCHAR * const PVD_PROP_RESTYPE_ISALIVE;
  198. extern const WCHAR * const PVD_PROP_RESTYPE_LOOKSALIVE;
  199. extern const WCHAR * const PVD_PROP_RESTYPE_DESCRIPTION;
  200. extern const WCHAR * const PVD_PROP_RESTYPE_QUORUM_CAPABLE;
  201. extern const WCHAR * const PVD_PROP_RESTYPE_LOCALQUORUM_CAPABLE;
  202. extern const WCHAR * const PVD_PROP_RESTYPE_DELETE_REQUIRES_ALL_NODES;
  203. extern const WCHAR * const PVD_MTH_RESTYPE_CREATE_RESOURCETYPE;
  204. extern const WCHAR * const PVD_MTH_RESTYPE_DELETE_RESOURCETYPE;
  205. extern const WCHAR * const PVD_MTH_RESTYPE_PARM_RESTYPE_NAME;
  206. extern const WCHAR * const PVD_MTH_RESTYPE_PARM_RESTYPE_DISPLAYNAME;
  207. extern const WCHAR * const PVD_MTH_RESTYPE_PARM_RESTYPE_DLLNAME;
  208. extern const WCHAR * const PVD_MTH_RESTYPE_PARM_RESTYPE_LOOKSALIVE;
  209. extern const WCHAR * const PVD_MTH_RESTYPE_PARM_RESTYPE_ISALIVE;
  210. // GROUP
  211. extern const WCHAR * const PVD_CLASS_GROUP;
  212. extern const WCHAR * const PVD_CLASS_GROUPTORES;
  213. extern const WCHAR * const PVD_CLASS_GROUPNODE;
  214. extern const WCHAR * const PVD_PROP_GROUP_NAME;
  215. extern const WCHAR * const PVD_PROP_GROUP_STATE;
  216. extern const WCHAR* const PVD_PROP_NODELIST;
  217. extern const WCHAR * const PVD_MTH_GROUP_CREATEGROUP;
  218. extern const WCHAR * const PVD_MTH_GROUP_DELETEGROUP;
  219. extern const WCHAR * const PVD_MTH_GROUP_TAKEOFFLINE;
  220. extern const WCHAR * const PVD_MTH_GROUP_BRINGONLINE;
  221. extern const WCHAR * const PVD_MTH_GROUP_MOVETONEWNODE;
  222. extern const WCHAR * const PVD_MTH_GROUP_DELETE;
  223. extern const WCHAR * const PVD_MTH_GROUP_RENAME;
  224. extern const WCHAR * const PVD_MTH_GROUP_PARM_GROUPNAME;
  225. extern const WCHAR * const PVD_MTH_GROUP_PARM_NODENAME;
  226. extern const WCHAR * const PVD_MTH_GROUP_PARM_NEWNAME;
  227. extern const WCHAR * const PVD_MTH_GROUP_PARM_TIMEOUT;
  228. // NetworkInterface
  229. extern const WCHAR * const PVD_CLASS_NETWORKINTERFACE;
  230. extern const WCHAR * const PVD_PROP_NETINTERFACE_DEVICEID;
  231. extern const WCHAR * const PVD_PROP_NETINTERFACE_SYSTEMNAME;
  232. extern const WCHAR * const PVD_PROP_NETINTERFACE_STATE;
  233. // NetworkName
  234. extern const WCHAR * const PVD_CLASS_NETWORKNAME;
  235. // networks
  236. extern const WCHAR * const PVD_CLASS_NETWORK;
  237. extern const WCHAR * const PVD_CLASS_NETTONETINTERFACE;
  238. extern const WCHAR * const PVD_PROP_NETINTERFACE_NAME;
  239. extern const WCHAR * const PVD_PROP_NETWORK_STATE;
  240. extern const WCHAR * const PVD_MTH_NETWORK_RENAME;
  241. extern const WCHAR * const PVD_MTH_NETWORK_PARM_NEWNAME;
  242. // service
  243. extern const WCHAR * const PVD_CLASS_SERVICES;
  244. extern const WCHAR * const PVD_CLASS_HOSTEDSERVICES;
  245. extern const WCHAR * const PVD_PROP_SERVICE_NAME;
  246. extern const WCHAR * const PVD_PROP_SERVICE_SYSTEMNAME;
  247. extern const WCHAR * const PVD_MTH_SERVICE_PAUSE;
  248. extern const WCHAR * const PVD_MTH_SERVICE_RESUME;
  249. // event
  250. extern const WCHAR * const PVD_CLASS_EVENT;
  251. extern const WCHAR * const PVD_PROP_EVENT_NAME;
  252. extern const WCHAR * const PVD_PROP_EVENT_PATH;
  253. extern const WCHAR * const PVD_PROP_EVENT_TYPE;
  254. extern const WCHAR * const PVD_PROP_EVENT_TYPEMAJOR;
  255. extern const WCHAR * const PVD_PROP_EVENT_TYPEMINOR;
  256. extern const WCHAR * const PVD_PROP_EVENT_NEWSTATE;
  257. extern const WCHAR * const PVD_PROP_EVENT_NODE;
  258. extern const WCHAR * const PVD_PROP_EVENT_GROUP;
  259. extern const WCHAR * const PVD_CLASS_EVENT_ADD;
  260. extern const WCHAR * const PVD_CLASS_EVENT_REMOVE;
  261. extern const WCHAR * const PVD_CLASS_EVENT_STATECHANGE;
  262. extern const WCHAR * const PVD_CLASS_EVENT_GROUPSTATECHANGE;
  263. extern const WCHAR * const PVD_CLASS_EVENT_RESOURCESTATECHANGE;
  264. extern const WCHAR * const PVD_CLASS_EVENT_PROP;
  265. extern const WCHAR * const PVD_CLASS_PROPERTY;
  266. extern const WCHAR * const PVD_PROP_NAME;
  267. extern const WCHAR * const PVD_PROP_STATE;
  268. extern const WCHAR * const PVD_PROP_GROUPCOMPONENT;
  269. extern const WCHAR * const PVD_PROP_PARTCOMPONENT;
  270. extern const WCHAR * const PVD_PROP_CHARACTERISTIC;
  271. extern const WCHAR * const PVD_PROP_FLAGS;
  272. extern const WCHAR * const PVD_WBEM_EXTENDEDSTATUS;
  273. extern const WCHAR * const PVD_WBEM_DESCRIPTION;
  274. extern const WCHAR * const PVD_WBEM_STATUSCODE;
  275. extern const WCHAR * const PVD_WBEM_STATUS;
  276. extern const WCHAR * const PVD_WBEM_CLASS;
  277. extern const WCHAR * const PVD_WBEM_RELPATH;
  278. extern const WCHAR * const PVD_WBEM_PROP_ANTECEDENT;
  279. extern const WCHAR * const PVD_WBEM_PROP_DEPENDENT;
  280. extern const WCHAR * const PVD_WBEM_PROP_DEVICEID;
  281. extern const WCHAR * const PVD_WBEM_QUA_DYNAMIC;
  282. extern const WCHAR * const PVD_WBEM_QUA_CIMTYPE;
  283. extern const WCHAR * const PVD_WBEM_QUA_PROV_VALUE;
  284. extern const WCHAR * const PVD_WBEM_QUA_PROV_NAME;
  285. class CClassData
  286. {
  287. public:
  288. const WCHAR * wszClassName;
  289. FPNEW pfConstruct;
  290. const char * szType;
  291. }; // *** class CClassData
  292. class CClassCreator
  293. {
  294. public:
  295. CClassCreator( void )
  296. : m_pfnConstructor( NULL )
  297. , m_pbstrClassName( L"" )
  298. { };
  299. CClassCreator(
  300. FPNEW pfnIn,
  301. const WCHAR * pwszClassNameIn,
  302. DWORD dwEnumTypeIn
  303. )
  304. : m_pfnConstructor( pfnIn )
  305. , m_pbstrClassName( pwszClassNameIn )
  306. , m_dwEnumType( dwEnumTypeIn )
  307. { };
  308. FPNEW m_pfnConstructor;
  309. _bstr_t m_pbstrClassName;
  310. DWORD m_dwEnumType;
  311. }; //*** class CClassCreator
  312. template< class _Ty >
  313. struct strLessThan : binary_function< _Ty, _Ty, bool >
  314. {
  315. bool operator()( const _Ty& _X, const _Ty& _Y ) const
  316. {
  317. return ( _wcsicmp( _X, _Y ) < 0 );
  318. }
  319. }; //*** struct strLessThan
  320. typedef map< _bstr_t, CClassCreator, strLessThan< _bstr_t > > ClassMap;
  321. typedef map< _bstr_t, _bstr_t, strLessThan< _bstr_t > > TypeNameToClass;
  322. extern TypeNameToClass g_TypeNameToClass;
  323. extern ClassMap g_ClassMap;