Source code of Windows XP (NT5)
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.

572 lines
11 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. Wmium.h
  5. Abstract:
  6. Public headers for WMI data consumers and providers
  7. Author:
  8. 16-Jan-1997 AlanWar
  9. Revision History:
  10. --*/
  11. #ifndef _WMIUM_
  12. #define _WMIUM_
  13. #ifndef MIDL_PASS
  14. #ifdef _WMI_SOURCE_
  15. #define WMIAPI __stdcall
  16. #else
  17. #define WMIAPI DECLSPEC_IMPORT __stdcall
  18. #endif
  19. #endif
  20. #include <guiddef.h>
  21. #include <basetsd.h>
  22. #include <wmistr.h>
  23. typedef PVOID WMIHANDLE, *PWMIHANDLE, MOFHANDLE, *PMOFHANDLE;
  24. //
  25. // When set the guid can be opened and accessed
  26. #define MOFCI_RESERVED0 0x00000001
  27. #define MOFCI_RESERVED1 0x00000002
  28. #define MOFCI_RESERVED2 0x00000004
  29. typedef struct
  30. {
  31. #ifdef MIDL_PASS
  32. [string] PDFTCHAR
  33. #else
  34. LPWSTR
  35. #endif
  36. ImagePath; // Path to image containing MOF resource
  37. #ifdef MIDL_PASS
  38. [string] PDFTCHAR
  39. #else
  40. LPWSTR
  41. #endif
  42. ResourceName; // Name of resource in image
  43. ULONG ResourceSize; // Number of bytes in resource
  44. #ifdef MIDL_PASS
  45. [size_is(0)] PDFBYTE
  46. #else
  47. PUCHAR
  48. #endif
  49. ResourceBuffer; // Reserved
  50. } MOFRESOURCEINFOW, *PMOFRESOURCEINFOW;
  51. typedef struct
  52. {
  53. LPSTR
  54. ImagePath; // Path to image containing MOF resource
  55. LPSTR
  56. ResourceName; // Name of resource in image
  57. ULONG ResourceSize; // Number of bytes in resource
  58. UCHAR
  59. *ResourceBuffer; // Reserved
  60. } MOFRESOURCEINFOA, *PMOFRESOURCEINFOA;
  61. #ifdef UNICODE
  62. typedef MOFRESOURCEINFOW MOFRESOURCEINFO;
  63. typedef PMOFRESOURCEINFOW PMOFRESOURCEINFO;
  64. #else
  65. typedef MOFRESOURCEINFOA MOFRESOURCEINFO;
  66. typedef PMOFRESOURCEINFOA PMOFRESOURCEINFO;
  67. #endif
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71. //
  72. // Data consumer apis
  73. ULONG
  74. WMIAPI
  75. WmiOpenBlock(
  76. IN GUID *Guid,
  77. IN ULONG DesiredAccess,
  78. OUT WMIHANDLE *DataBlockHandle
  79. );
  80. ULONG
  81. WMIAPI
  82. WmiCloseBlock(
  83. IN WMIHANDLE DataBlockHandle
  84. );
  85. ULONG
  86. WMIAPI
  87. WmiQueryAllDataA(
  88. IN WMIHANDLE DataBlockHandle,
  89. IN OUT ULONG *BufferSize,
  90. OUT PVOID Buffer
  91. );
  92. ULONG
  93. WMIAPI
  94. WmiQueryAllDataW(
  95. IN WMIHANDLE DataBlockHandle,
  96. IN OUT ULONG *BufferSize,
  97. OUT PVOID Buffer
  98. );
  99. #ifdef UNICODE
  100. #define WmiQueryAllData WmiQueryAllDataW
  101. #else
  102. #define WmiQueryAllData WmiQueryAllDataA
  103. #endif
  104. ULONG
  105. WMIAPI
  106. WmiQueryAllDataMultipleA(
  107. IN WMIHANDLE *HandleList,
  108. IN ULONG HandleCount,
  109. IN OUT ULONG *InOutBufferSize,
  110. OUT LPVOID OutBuffer
  111. );
  112. ULONG
  113. WMIAPI
  114. WmiQueryAllDataMultipleW(
  115. IN WMIHANDLE *HandleList,
  116. IN ULONG HandleCount,
  117. IN OUT ULONG *InOutBufferSize,
  118. OUT LPVOID OutBuffer
  119. );
  120. #ifdef UNICODE
  121. #define WmiQueryAllDataMultiple WmiQueryAllDataMultipleW
  122. #else
  123. #define WmiQueryAllDataMultiple WmiQueryAllDataMultipleA
  124. #endif
  125. ULONG
  126. WMIAPI
  127. WmiQuerySingleInstanceA(
  128. IN WMIHANDLE DataBlockHandle,
  129. IN LPCSTR InstanceName,
  130. IN OUT ULONG *BufferSize,
  131. OUT PVOID Buffer
  132. );
  133. ULONG
  134. WMIAPI
  135. WmiQuerySingleInstanceW(
  136. IN WMIHANDLE DataBlockHandle,
  137. IN LPCWSTR InstanceName,
  138. IN OUT ULONG *BufferSize,
  139. OUT PVOID Buffer
  140. );
  141. #ifdef UNICODE
  142. #define WmiQuerySingleInstance WmiQuerySingleInstanceW
  143. #else
  144. #define WmiQuerySingleInstance WmiQuerySingleInstanceA
  145. #endif
  146. ULONG
  147. WMIAPI
  148. WmiQuerySingleInstanceMultipleW(
  149. IN WMIHANDLE *HandleList,
  150. IN LPCWSTR *InstanceNames,
  151. IN ULONG HandleCount,
  152. IN OUT ULONG *InOutBufferSize,
  153. OUT LPVOID OutBuffer
  154. );
  155. ULONG
  156. WMIAPI
  157. WmiQuerySingleInstanceMultipleA(
  158. IN WMIHANDLE *HandleList,
  159. IN LPCSTR *InstanceNames,
  160. IN ULONG HandleCount,
  161. IN OUT ULONG *InOutBufferSize,
  162. OUT LPVOID OutBuffer
  163. );
  164. #ifdef UNICODE
  165. #define WmiQuerySingleInstanceMultiple WmiQuerySingleInstanceMultipleW
  166. #else
  167. #define WmiQuerySingleInstanceMultiple WmiQuerySingleInstanceMultipleA
  168. #endif
  169. ULONG
  170. WMIAPI
  171. WmiSetSingleInstanceA(
  172. IN WMIHANDLE DataBlockHandle,
  173. IN LPCSTR InstanceName,
  174. IN ULONG Reserved,
  175. IN ULONG ValueBufferSize,
  176. IN PVOID ValueBuffer
  177. );
  178. ULONG
  179. WMIAPI
  180. WmiSetSingleInstanceW(
  181. IN WMIHANDLE DataBlockHandle,
  182. IN LPCWSTR InstanceName,
  183. IN ULONG Reserved,
  184. IN ULONG ValueBufferSize,
  185. IN PVOID ValueBuffer
  186. );
  187. #ifdef UNICODE
  188. #define WmiSetSingleInstance WmiSetSingleInstanceW
  189. #else
  190. #define WmiSetSingleInstance WmiSetSingleInstanceA
  191. #endif
  192. ULONG
  193. WMIAPI
  194. WmiSetSingleItemA(
  195. IN WMIHANDLE DataBlockHandle,
  196. IN LPCSTR InstanceName,
  197. IN ULONG DataItemId,
  198. IN ULONG Reserved,
  199. IN ULONG ValueBufferSize,
  200. IN PVOID ValueBuffer
  201. );
  202. ULONG
  203. WMIAPI
  204. WmiSetSingleItemW(
  205. IN WMIHANDLE DataBlockHandle,
  206. IN LPCWSTR InstanceName,
  207. IN ULONG DataItemId,
  208. IN ULONG Reserved,
  209. IN ULONG ValueBufferSize,
  210. IN PVOID ValueBuffer
  211. );
  212. #ifdef UNICODE
  213. #define WmiSetSingleItem WmiSetSingleItemW
  214. #else
  215. #define WmiSetSingleItem WmiSetSingleItemA
  216. #endif
  217. ULONG
  218. WMIAPI
  219. WmiExecuteMethodA(
  220. IN WMIHANDLE MethodDataBlockHandle,
  221. IN LPCSTR MethodInstanceName,
  222. IN ULONG MethodId,
  223. IN ULONG InputValueBufferSize,
  224. IN PVOID InputValueBuffer,
  225. IN OUT ULONG *OutputBufferSize,
  226. OUT PVOID OutputBuffer
  227. );
  228. ULONG
  229. WMIAPI
  230. WmiExecuteMethodW(
  231. IN WMIHANDLE MethodDataBlockHandle,
  232. IN LPCWSTR MethodInstanceName,
  233. IN ULONG MethodId,
  234. IN ULONG InputValueBufferSize,
  235. IN PVOID InputValueBuffer,
  236. IN OUT ULONG *OutputBufferSize,
  237. OUT PVOID OutputBuffer
  238. );
  239. #ifdef UNICODE
  240. #define WmiExecuteMethod WmiExecuteMethodW
  241. #else
  242. #define WmiExecuteMethod WmiExecuteMethodA
  243. #endif
  244. // Set this Flag when calling NotficationRegistration to enable or
  245. // disable a trace logging guid
  246. #define NOTIFICATION_TRACE_FLAG 0x00010000
  247. // Set this flag when enabling a notification that should be delivered via
  248. // a direct callback. Any notifications received will be given their own
  249. // thread and the callback function called immediately.
  250. #define NOTIFICATION_CALLBACK_DIRECT 0x00000004
  251. //
  252. // Set this flag (and only this flag) when you want to only check if the
  253. // caller has permission to receive events for the guid
  254. //
  255. #define NOTIFICATION_CHECK_ACCESS 0x00000008
  256. //
  257. // Event notification callback function prototype
  258. typedef void (
  259. #ifndef MIDL_PASS
  260. WINAPI
  261. #endif
  262. *NOTIFICATIONCALLBACK)(
  263. PWNODE_HEADER Wnode,
  264. UINT_PTR NotificationContext
  265. );
  266. #ifndef MIDL_PASS
  267. //
  268. // This guid is for notifications of changes to registration
  269. // {B48D49A1-E777-11d0-A50C-00A0C9062910}
  270. DEFINE_GUID(GUID_REGISTRATION_CHANGE_NOTIFICATION,
  271. 0xb48d49a1, 0xe777, 0x11d0, 0xa5, 0xc, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10);
  272. //
  273. // This guid id for notifications of new mof resources being added
  274. // {B48D49A2-E777-11d0-A50C-00A0C9062910}
  275. DEFINE_GUID(GUID_MOF_RESOURCE_ADDED_NOTIFICATION,
  276. 0xb48d49a2, 0xe777, 0x11d0, 0xa5, 0xc, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10);
  277. //
  278. // This guid id for notifications of new mof resources being added
  279. // {B48D49A3-E777-11d0-A50C-00A0C9062910}
  280. DEFINE_GUID(GUID_MOF_RESOURCE_REMOVED_NOTIFICATION,
  281. 0xb48d49a3, 0xe777, 0x11d0, 0xa5, 0xc, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10);
  282. #endif
  283. ULONG
  284. WMIAPI
  285. WmiNotificationRegistrationA(
  286. IN LPGUID Guid,
  287. IN BOOLEAN Enable,
  288. IN PVOID DeliveryInfo,
  289. IN ULONG_PTR DeliveryContext,
  290. IN ULONG Flags
  291. );
  292. ULONG
  293. WMIAPI
  294. WmiNotificationRegistrationW(
  295. IN LPGUID Guid,
  296. IN BOOLEAN Enable,
  297. IN PVOID DeliveryInfo,
  298. IN ULONG_PTR DeliveryContext,
  299. IN ULONG Flags
  300. );
  301. #ifdef UNICODE
  302. #define WmiNotificationRegistration WmiNotificationRegistrationW
  303. #else
  304. #define WmiNotificationRegistration WmiNotificationRegistrationA
  305. #endif
  306. void
  307. WMIAPI
  308. WmiFreeBuffer(
  309. IN PVOID Buffer
  310. );
  311. ULONG
  312. WMIAPI
  313. WmiEnumerateGuids(
  314. OUT LPGUID GuidList,
  315. IN OUT ULONG *GuidCount
  316. );
  317. ULONG
  318. WMIAPI
  319. WmiMofEnumerateResourcesW(
  320. IN MOFHANDLE MofResourceHandle,
  321. OUT ULONG *MofResourceCount,
  322. OUT PMOFRESOURCEINFOW *MofResourceInfo
  323. );
  324. ULONG
  325. WMIAPI
  326. WmiMofEnumerateResourcesA(
  327. IN MOFHANDLE MofResourceHandle,
  328. OUT ULONG *MofResourceCount,
  329. OUT PMOFRESOURCEINFOA *MofResourceInfo
  330. );
  331. #ifdef UNICODE
  332. #define WmiMofEnumerateResources WmiMofEnumerateResourcesW
  333. #else
  334. #define WmiMofEnumerateResources WmiMofEnumerateResourcesA
  335. #endif
  336. ULONG
  337. WMIAPI
  338. WmiFileHandleToInstanceNameA(
  339. IN WMIHANDLE DataBlockHandle,
  340. IN HANDLE FileHandle,
  341. IN OUT ULONG *NumberCharacters,
  342. OUT CHAR *InstanceNames
  343. );
  344. ULONG
  345. WMIAPI
  346. WmiFileHandleToInstanceNameW(
  347. IN WMIHANDLE DataBlockHandle,
  348. IN HANDLE FileHandle,
  349. IN OUT ULONG *NumberCharacters,
  350. OUT WCHAR *InstanceNames
  351. );
  352. #ifdef UNICODE
  353. #define WmiFileHandleToInstanceName WmiFileHandleToInstanceNameW
  354. #else
  355. #define WmiFileHandleToInstanceName WmiFileHandleToInstanceNameA
  356. #endif
  357. #define WmiInsertTimestamp(WnodeHeader) \
  358. GetSystemTimeAsFileTime((FILETIME *)&((PWNODE_HEADER)WnodeHeader)->TimeStamp)
  359. ULONG
  360. WMIAPI
  361. WmiDevInstToInstanceNameA(
  362. OUT CHAR *InstanceName,
  363. IN ULONG InstanceNameLength,
  364. IN CHAR *DevInst,
  365. IN ULONG InstanceIndex
  366. );
  367. ULONG
  368. WMIAPI
  369. WmiDevInstToInstanceNameW(
  370. OUT WCHAR *InstanceName,
  371. IN ULONG InstanceNameLength,
  372. IN WCHAR *DevInst,
  373. IN ULONG InstanceIndex
  374. );
  375. #ifdef UNICODE
  376. #define WmiDevInstToInstanceName WmiDevInstToInstanceNameW
  377. #else
  378. #define WmiDevInstToInstanceName WmiDevInstToInstanceNameA
  379. #endif
  380. typedef struct _WMIGUIDINFORMATION
  381. {
  382. ULONG Size;
  383. BOOLEAN IsExpensive;
  384. BOOLEAN IsEventOnly;
  385. } WMIGUIDINFORMATION, *PWMIGUIDINFORMATION;
  386. ULONG
  387. WMIAPI
  388. WmiQueryGuidInformation(
  389. IN WMIHANDLE GuidHandle,
  390. OUT PWMIGUIDINFORMATION GuidInfo
  391. );
  392. ULONG
  393. WMIAPI
  394. WmiReceiveNotificationsW(
  395. IN ULONG HandleCount,
  396. IN HANDLE *HandleList,
  397. IN NOTIFICATIONCALLBACK Callback,
  398. IN ULONG_PTR DeliveryContext
  399. );
  400. ULONG
  401. WMIAPI
  402. WmiReceiveNotificationsA(
  403. IN ULONG HandleCount,
  404. IN HANDLE *HandleList,
  405. IN NOTIFICATIONCALLBACK Callback,
  406. IN ULONG_PTR DeliveryContext
  407. );
  408. #ifdef UNICODE
  409. #define WmiReceiveNotifications WmiReceiveNotificationsW
  410. #else
  411. #define WmiReceiveNotifications WmiReceiveNotificationsA
  412. #endif
  413. //
  414. // Internal Flags for different processing modes.
  415. // Applies to the TRACE_LOGFILE_HEADER ReservedFlags field.
  416. //
  417. #define EVENT_TRACE_USE_RAWTIMESTAMP 2 // Used with OpenTrace(), prevents
  418. // conversion of TimeStamps to UTC
  419. //
  420. // Low level trace consumer routines
  421. //
  422. typedef enum tagWMI_HEADER_TYPE {
  423. WMIHT_NONE,
  424. WMIHT_UNKNOWN,
  425. WMIHT_SYSTEM32,
  426. WMIHT_SYSTEM64,
  427. WMIHT_EVENT_TRACE,
  428. WMIHT_EVENT_INSTANCE,
  429. WMIHT_TIMED,
  430. WMIHT_ULONG32,
  431. WMIHT_WNODE,
  432. WMIHT_MESSAGE,
  433. WMIHT_PERFINFO32,
  434. WMIHT_PERFINFO64
  435. } WMI_HEADER_TYPE;
  436. typedef enum tagWMI_BUFFER_SOURCE {
  437. WMIBS_FLUSH_LIST,
  438. WMIBS_FREE_LIST,
  439. WMIBS_TRANSITION_LIST,
  440. WMIBS_CURRENT_LIST,
  441. WMIBS_LOG_FILE
  442. } WMI_BUFFER_SOURCE;
  443. typedef struct {
  444. WMI_BUFFER_SOURCE BufferSource;
  445. ULONG BufferSize; // Size of the Buffer
  446. ULONG ProcessorNumber;
  447. ULONG Alignment; // Alignment
  448. PVOID Buffer; // Pointer to the raw buffer
  449. } WMIBUFFERINFO, *PWMIBUFFERINFO;
  450. //
  451. // Get buffer offset to first event only. Returns Size.
  452. // Fix up the Buffer for proper termination and alignment.
  453. //
  454. ULONG
  455. WMIAPI
  456. WmiGetFirstTraceOffset(
  457. IN PWMIBUFFERINFO BufferInfo
  458. );
  459. //
  460. // Get the next event, size and type. Caller must advance offset with Size
  461. //
  462. WMI_HEADER_TYPE
  463. WMIAPI
  464. WmiGetTraceHeader(
  465. IN PVOID Buffer,
  466. IN ULONG Offset,
  467. OUT ULONG *Size
  468. );
  469. //
  470. // Returns a EVENT_TRACE / (new Structure Ian will define)
  471. // in the Buffer provided
  472. ULONG
  473. WMIAPI
  474. WmiParseTraceEvent(
  475. IN PVOID Buffer,
  476. IN ULONG Offset,
  477. IN WMI_HEADER_TYPE HeaderType,
  478. IN OUT PVOID EventInfo,
  479. IN ULONG EventInfoSize
  480. );
  481. #ifdef __cplusplus
  482. }
  483. #endif
  484. #endif // _WMIUM_