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.

289 lines
6.6 KiB

  1. //=================================================================
  2. //
  3. // WmiApi.h
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #ifndef _WMIAPI_H_
  9. #define _WMIAPI_H_
  10. /**********************************************************************************************************
  11. * #includes to Register this class with the CResourceManager.
  12. **********************************************************************************************************/
  13. #include "DllWrapperBase.h"
  14. #include "wmium.h"
  15. #include "wbemcli.h"
  16. /******************************************************************************
  17. * Register this class with the CResourceManager.
  18. *****************************************************************************/
  19. extern const GUID g_guidWmiApi;
  20. extern const TCHAR g_tstrWmi[];
  21. /******************************************************************************
  22. * Function pointer typedefs. Add new functions here as required.
  23. *****************************************************************************/
  24. typedef ULONG (WINAPI* PFN_WMI_QUERY_ALL_DATA)
  25. (
  26. IN WMIHANDLE,
  27. IN OUT ULONG*,
  28. OUT PVOID
  29. );
  30. typedef ULONG (WINAPI* PFN_WMI_QUERY_SINGLE_INSTANCE)
  31. (
  32. IN WMIHANDLE DataBlockHandle,
  33. IN LPCTSTR InstanceName,
  34. IN OUT ULONG *BufferSize,
  35. OUT PVOID Buffer
  36. );
  37. typedef ULONG (WINAPI* PFN_WMI_SET_SINGLE_ITEM)
  38. (
  39. IN WMIHANDLE DataBlockHandle,
  40. IN LPCTSTR InstanceName,
  41. IN ULONG DataItemId,
  42. IN ULONG Reserved,
  43. IN ULONG ValueBufferSize,
  44. IN PVOID ValueBuffer
  45. );
  46. typedef ULONG (WINAPI* PFN_WMI_SET_SINGLE_INSTANCE)
  47. (
  48. IN WMIHANDLE DataBlockHandle,
  49. IN LPCTSTR InstanceName,
  50. IN ULONG Reserved,
  51. IN ULONG ValueBufferSize,
  52. IN PVOID ValueBuffer
  53. );
  54. typedef ULONG (WINAPI* PFN_WMI_EXECUTE_METHOD)
  55. (
  56. IN WMIHANDLE MethodDataBlockHandle,
  57. IN LPCTSTR MethodInstanceName,
  58. IN ULONG MethodId,
  59. IN ULONG InputValueBufferSize,
  60. IN PVOID InputValueBuffer,
  61. IN OUT ULONG *OutputBufferSize,
  62. OUT PVOID OutputBuffer
  63. );
  64. typedef ULONG (WINAPI* PFN_WMI_NOTIFICATION_REGRISTRATION)
  65. (
  66. IN LPGUID Guid,
  67. IN BOOLEAN Enable,
  68. IN PVOID DeliveryInfo,
  69. IN ULONG_PTR DeliveryContext,
  70. IN ULONG Flags
  71. );
  72. typedef ULONG (WINAPI* PFN_WMI_MOF_ENUMERATE_RESOURCES)
  73. (
  74. IN MOFHANDLE MofResourceHandle,
  75. OUT ULONG *MofResourceCount,
  76. OUT PMOFRESOURCEINFO *MofResourceInfo
  77. );
  78. typedef ULONG (WINAPI* PFN_WMI_FILE_HANDLE_TO_INSTANCE_NAME)
  79. (
  80. IN WMIHANDLE DataBlockHandle,
  81. IN HANDLE FileHandle,
  82. IN OUT ULONG *NumberCharacters,
  83. OUT TCHAR *InstanceNames
  84. );
  85. typedef ULONG (WINAPI* PFN_WMI_DEV_INST_TO_INSTANCE_NAME)
  86. (
  87. OUT TCHAR *InstanceName,
  88. IN ULONG InstanceNameLength,
  89. IN TCHAR *DevInst,
  90. IN ULONG InstanceIndex
  91. );
  92. typedef ULONG (WINAPI* PFN_WMI_OPEN_BLOCK)
  93. (
  94. IN GUID*,
  95. IN ULONG,
  96. OUT WMIHANDLE
  97. );
  98. typedef ULONG (WINAPI* PFN_WMI_CLOSE_BLOCK)
  99. (
  100. IN WMIHANDLE
  101. );
  102. typedef void (WINAPI* PNF_WMI_FREE_BUFFER)
  103. (
  104. IN PVOID Buffer
  105. );
  106. typedef ULONG (WINAPI* PFN_WMI_ENUMERATE_GUIDS)
  107. (
  108. OUT LPGUID GuidList,
  109. IN OUT ULONG *GuidCount
  110. );
  111. typedef ULONG (WINAPI* PFN_WMI_QUERY_GUID_INFORMATION)
  112. (
  113. IN WMIHANDLE GuidHandle,
  114. OUT PWMIGUIDINFORMATION GuidInfo
  115. );
  116. /******************************************************************************
  117. * Wrapper class for Wmi load/unload, for registration with CResourceManager.
  118. ******************************************************************************/
  119. class CWmiApi : public CDllWrapperBase
  120. {
  121. private:
  122. // Member variables (function pointers) pointing to Wmi functions.
  123. // Add new functions here as required.
  124. PFN_WMI_QUERY_ALL_DATA m_pfnWmiQueryAllData;
  125. PFN_WMI_OPEN_BLOCK m_pfnWmiOpenBlock;
  126. PFN_WMI_CLOSE_BLOCK m_pfnWmiCloseBlock;
  127. PFN_WMI_QUERY_SINGLE_INSTANCE m_pfnWmiQuerySingleInstance;
  128. PFN_WMI_SET_SINGLE_ITEM m_pfnWmiSetSingleItem;
  129. PFN_WMI_SET_SINGLE_INSTANCE m_pfnWmiSetSingleInstance;
  130. PFN_WMI_EXECUTE_METHOD m_pfnWmiExecuteMethod;
  131. PFN_WMI_NOTIFICATION_REGRISTRATION m_pfnWmiNotificationRegistraton;
  132. PNF_WMI_FREE_BUFFER m_pfnWmiFreeBuffer;
  133. PFN_WMI_ENUMERATE_GUIDS m_pfnWmiEnumerateGuids;
  134. PFN_WMI_MOF_ENUMERATE_RESOURCES m_pfnWmiMofEnumerateResources;
  135. PFN_WMI_FILE_HANDLE_TO_INSTANCE_NAME m_pfnWmiFileHandleToInstanceName;
  136. PFN_WMI_DEV_INST_TO_INSTANCE_NAME m_pfnWmiDevInstToInstanceName;
  137. PFN_WMI_QUERY_GUID_INFORMATION m_pfnWmiQueryGuidInformation;
  138. public:
  139. // Constructor and destructor:
  140. CWmiApi(LPCTSTR a_tstrWrappedDllName);
  141. ~CWmiApi();
  142. // Initialization function to check function pointers.
  143. virtual bool Init();
  144. // Member functions wrapping Wmi functions.
  145. // Add new functions here as required:
  146. ULONG WmiQueryAllData
  147. (
  148. IN WMIHANDLE,
  149. IN OUT ULONG*,
  150. OUT PVOID
  151. );
  152. ULONG WmiOpenBlock
  153. (
  154. IN GUID*,
  155. IN ULONG,
  156. OUT WMIHANDLE
  157. );
  158. ULONG WmiCloseBlock
  159. (
  160. IN WMIHANDLE
  161. );
  162. ULONG WmiQuerySingleInstance
  163. (
  164. IN WMIHANDLE,
  165. IN LPCTSTR,
  166. IN OUT ULONG*,
  167. OUT PVOID
  168. );
  169. ULONG WmiSetSingleItem
  170. (
  171. IN WMIHANDLE,
  172. IN LPCTSTR,
  173. IN ULONG,
  174. IN ULONG,
  175. IN ULONG,
  176. IN PVOID
  177. );
  178. ULONG WmiSetSingleInstance
  179. (
  180. IN WMIHANDLE,
  181. IN LPCTSTR,
  182. IN ULONG,
  183. IN ULONG,
  184. IN PVOID
  185. );
  186. ULONG WmiExecuteMethod
  187. (
  188. IN WMIHANDLE,
  189. IN LPCTSTR,
  190. IN ULONG,
  191. IN ULONG,
  192. IN PVOID,
  193. IN OUT ULONG*,
  194. OUT PVOID
  195. );
  196. ULONG WmiNotificationRegistration
  197. (
  198. IN LPGUID,
  199. IN BOOLEAN,
  200. IN PVOID,
  201. IN ULONG_PTR,
  202. IN ULONG
  203. );
  204. ULONG WmiMofEnumerateResources
  205. (
  206. IN MOFHANDLE,
  207. OUT ULONG*,
  208. OUT PMOFRESOURCEINFO*
  209. );
  210. ULONG WmiFileHandleToInstanceName
  211. (
  212. IN WMIHANDLE,
  213. IN HANDLE,
  214. IN OUT ULONG*,
  215. OUT TCHAR*
  216. );
  217. ULONG WmiDevInstToInstanceName
  218. (
  219. OUT TCHAR*,
  220. IN ULONG,
  221. IN TCHAR*,
  222. IN ULONG
  223. );
  224. void WmiFreeBuffer
  225. (
  226. IN PVOID
  227. );
  228. ULONG WmiEnumerateGuids
  229. (
  230. OUT LPGUID,
  231. IN OUT ULONG*
  232. );
  233. ULONG WmiQueryGuidInformation
  234. (
  235. IN WMIHANDLE,
  236. OUT PWMIGUIDINFORMATION
  237. );
  238. };
  239. #endif