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.

634 lines
14 KiB

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