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.

827 lines
24 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. wmiumkm.h
  5. Abstract:
  6. Private definitions for WMI communications between user and kernel modes
  7. Author:
  8. AlanWar
  9. Environment:
  10. Kernel and User modes
  11. Revision History:
  12. --*/
  13. #ifndef _WMIUMKM_
  14. #define _WMIUMKM_
  15. #if _MSC_VER >= 1200
  16. #pragma warning(push)
  17. #endif
  18. #pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union
  19. //
  20. // This defines the guid under which the default WMI security descriptor
  21. // is maintained.
  22. DEFINE_GUID(DefaultSecurityGuid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  23. #define DefaultSecurityGuidName L"00000000-0000-0000-0000-000000000000"
  24. #ifndef _WMIKM_
  25. //
  26. // This defines the codes used to define what a request must do. These
  27. // definitions must match the same in wmium.h
  28. //
  29. typedef enum tagWMIACTIONCODE
  30. {
  31. WmiGetAllData = 0,
  32. WmiGetSingleInstance = 1,
  33. WmiChangeSingleInstance = 2,
  34. WmiChangeSingleItem = 3,
  35. WmiEnableEvents = 4,
  36. WmiDisableEvents = 5,
  37. WmiEnableCollection = 6,
  38. WmiDisableCollection = 7,
  39. WmiRegisterInfo = 8,
  40. WmiExecuteMethodCall = 9,
  41. WmiSetTraceNotify = 10
  42. } WMIACTIONCODE;
  43. #endif
  44. #if defined(_WINNT_) || defined(WINNT)
  45. typedef enum
  46. {
  47. WmiStartLoggerCode = 32,
  48. WmiStopLoggerCode = 33,
  49. WmiQueryLoggerCode = 34,
  50. WmiTraceEventCode = 35,
  51. WmiUpdateLoggerCode = 36,
  52. WmiFlushLoggerCode = 37,
  53. WmiMBRequest = 38,
  54. WmiRequestDied = 39,
  55. WmiTraceMessageCode = 40,
  56. WmiSetMarkCode = 41,
  57. WmiNtdllLoggerCode = 42,
  58. WmiClockTypeCode = 43
  59. #ifdef NTPERF
  60. ,
  61. WmiSwitchBufferCode = 63
  62. #endif
  63. } WMITRACECODE;
  64. #endif
  65. typedef enum
  66. {
  67. WmiReadNotifications = 64,
  68. WmiGetNextRegistrant = 65,
  69. #ifndef MEMPHIS
  70. WmiOpenGuid = 66,
  71. #endif
  72. WmiNotifyUser = 67,
  73. WmiGetAllRegistrant = 68,
  74. WmiGenerateEvent = 69,
  75. WmiTranslateFileHandle = 71,
  76. WmiGetVersion = 73,
  77. WmiCheckAccess = 74,
  78. WmiQueryAllMultiple = 75,
  79. WmiQuerySingleMultiple = 76,
  80. WmiEnumerateGuidList = 77,
  81. WmiQueryDataBlockInformation = 78,
  82. WmiOpenGuidForQuerySet = 79,
  83. WmiOpenGuidForEvents = 80,
  84. WmiReceiveNotif = 81,
  85. WmiEnableDisableTracelogProvider = 82,
  86. WmiRegisterGuids = 83,
  87. WmiCreateUMLogger = 84,
  88. WmiMBReply = 85,
  89. WmiEnumerateMofResouces = 86,
  90. WmiUnregisterDP = 87,
  91. WmiEnumerateGuidListAndProperties = 88,
  92. WmiNotifyLanguageChange = 89,
  93. WmiMarkHandleAsClosed = 90
  94. } WMISERVICECODES;
  95. //
  96. // This defines the name of the WMI device that manages service IOCTLS
  97. #define WMIServiceDeviceObjectName L"\\Device\\WMIDataDevice"
  98. #define WMIServiceDeviceName TEXT("\\\\.\\WMIDataDevice")
  99. #define WMIServiceSymbolicLinkName TEXT("\\DosDevices\\WMIDataDevice")
  100. #ifdef MEMPHIS
  101. //
  102. // This id the name of the device that handles query/set IOCTLS. On memphis
  103. // it is the same as the service device name.
  104. #define WMIDataDeviceObjectName L"\\Device\\WMIDevice"
  105. #define WMIDataDeviceName TEXT("\\\\.\\WMIServiceDevice")
  106. #define WMIDataSymbolicLinkName TEXT("\\DosDevices\\WMIServiceDevice")
  107. #else
  108. #define WMIDataDeviceObjectName WMIServiceDeviceObjectName
  109. #define WMIDataDeviceName WMIServiceDeviceName
  110. #define WMIDataSymbolicLinkName WMIServiceSymbolicLinkName
  111. #endif
  112. //
  113. // This defines the data structure that is used to pass a handle from
  114. // um to km. In 32bit code a handle has 32bits and in 64bit code a handle
  115. // has 64 bits and both call into the kernel which is 64bits. In order to
  116. // insure that the data structures compile to the same size on 32 and 64
  117. // bit systems we define the union with a dummy 64bit value so the field is
  118. // forced to be 64 bits in all code. Note that the object manager always
  119. // ignores the top 32bits of the handle in order to support 32 bit code
  120. // that only maintains 32 bit handles
  121. //
  122. typedef union
  123. {
  124. HANDLE Handle;
  125. ULONG64 Handle64;
  126. ULONG32 Handle32;
  127. } HANDLE3264, *PHANDLE3264;
  128. typedef HANDLE3264 PVOID3264;
  129. #ifdef _WIN64
  130. #define WmipSetHandle3264(Handle3264, XHandle) \
  131. (Handle3264).Handle = XHandle
  132. #else
  133. #define WmipSetHandle3264(Handle3264, XHandle) \
  134. { (Handle3264).Handle64 = 0; (Handle3264).Handle32 = (ULONG32)XHandle; }
  135. #endif
  136. #define WmipSetPVoid3264 WmipSetHandle3264
  137. //
  138. // This IOCTL will return when a KM notification has been generated that
  139. // requires user mode attention.
  140. // BufferIn - Not used
  141. // BufferOut - Buffer to return notification information
  142. #define IOCTL_WMI_READ_NOTIFICATIONS \
  143. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiReadNotifications, METHOD_BUFFERED, FILE_READ_ACCESS)
  144. //
  145. // This IOCTL will return with the next set of unprocessed registration info
  146. // BufferIn - Not used
  147. // BufferOut - Buffer to return registration information
  148. #define IOCTL_WMI_GET_NEXT_REGISTRANT \
  149. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiGetNextRegistrant, METHOD_BUFFERED, FILE_READ_ACCESS)
  150. #ifndef MEMPHIS
  151. //
  152. // This IOCTL will return a handle to a guid
  153. // BufferIn - WMIOPENGUIDBLOCK
  154. // BufferOut - WMIOPENGUIDBLOCK
  155. #define IOCTL_WMI_OPEN_GUID \
  156. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiOpenGuid, METHOD_BUFFERED, FILE_READ_ACCESS)
  157. #define IOCTL_WMI_OPEN_GUID_FOR_QUERYSET \
  158. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiOpenGuidForQuerySet, METHOD_BUFFERED, FILE_READ_ACCESS)
  159. #define IOCTL_WMI_OPEN_GUID_FOR_EVENTS \
  160. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiOpenGuidForEvents, METHOD_BUFFERED, FILE_READ_ACCESS)
  161. #endif
  162. // This IOCTL will perform a query for all data items of a data block
  163. // BufferIn - Incoming WNODE describing query. This gets filled in by driver
  164. #define IOCTL_WMI_QUERY_ALL_DATA \
  165. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiGetAllData, METHOD_BUFFERED, FILE_READ_ACCESS)
  166. // This IOCTL will query for a single instance
  167. // BufferIn - Incoming WNODE describing query. This gets filled in by driver
  168. #define IOCTL_WMI_QUERY_SINGLE_INSTANCE \
  169. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiGetSingleInstance, METHOD_BUFFERED, FILE_READ_ACCESS)
  170. // This IOCTL will set a single instance
  171. // BufferIn - Incoming WNODE describing set.
  172. #define IOCTL_WMI_SET_SINGLE_INSTANCE \
  173. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiChangeSingleInstance, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  174. // This IOCTL will set a single item
  175. // BufferIn - Incoming WNODE describing set.
  176. #define IOCTL_WMI_SET_SINGLE_ITEM \
  177. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiChangeSingleItem, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  178. // This IOCTL will enable an event
  179. // BufferIn - Incoming WNODE event item to enable
  180. #define IOCTL_WMI_ENABLE_EVENT \
  181. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiEnableEvents, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  182. // This IOCTL will disable an event
  183. // BufferIn - Incoming WNODE event item to disable
  184. #define IOCTL_WMI_DISABLE_EVENT \
  185. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiDisableEvents, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  186. // This IOCTL will enable collection
  187. // BufferIn - Incoming WNODE describing what to enable for collection
  188. #define IOCTL_WMI_ENABLE_COLLECTION \
  189. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiEnableCollection, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  190. // This IOCTL will disable collection
  191. // BufferIn - Incoming WNODE describing what to disable for collection
  192. #define IOCTL_WMI_DISABLE_COLLECTION \
  193. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiDisableCollection, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  194. // This IOCTL will return the registration information for a specific provider
  195. // BufferIn - Provider handle
  196. // BufferOut - Buffer to return WMI information
  197. #define IOCTL_WMI_GET_REGINFO \
  198. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiRegisterInfo, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  199. // This IOCTL will execute a method on a device
  200. // BufferIn - WNODE_METHOD_ITEM
  201. // BufferOut - WNODE_METHOD_ITEM
  202. #define IOCTL_WMI_EXECUTE_METHOD \
  203. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiExecuteMethodCall, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  204. // This IOCTL will do a query all data multiple
  205. // BufferIn - WMIQADMULTIPLE
  206. // BufferOut - Linked WNODE_ALL_DATA with results
  207. #define IOCTL_WMI_QAD_MULTIPLE \
  208. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiQueryAllMultiple, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  209. //
  210. // This specifies the maxiumum number of handles that can be passed to
  211. // query all data multiple and query single instance multiple
  212. //
  213. #define QUERYMULIPLEHANDLELIMIT 0x1000
  214. typedef struct
  215. {
  216. ULONG HandleCount;
  217. HANDLE3264 Handles[1];
  218. } WMIQADMULTIPLE, *PWMIQADMULTIPLE;
  219. // This IOCTL will do a query single instance multiple
  220. // BufferIn - WMIQSIMULTIPLE
  221. // BufferOut - Linked WNODE_SINGLE_INSTANCE with results
  222. #define IOCTL_WMI_QSI_MULTIPLE \
  223. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiQuerySingleMultiple, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  224. #ifndef MEMPHIS
  225. typedef struct
  226. {
  227. USHORT Length;
  228. USHORT MaximumLength;
  229. union
  230. {
  231. PWSTR Buffer;
  232. ULONG64 Dummy;
  233. };
  234. } UNICODE_STRING3264, *PUNICODE_STRING3264;
  235. typedef struct
  236. {
  237. HANDLE3264 Handle;
  238. UNICODE_STRING3264 InstanceName;
  239. } WMIQSIINFO, *PWMIQSIINFO;
  240. typedef struct
  241. {
  242. ULONG QueryCount;
  243. WMIQSIINFO QsiInfo[1];
  244. } WMIQSIMULTIPLE, *PWMIQSIMULTIPLE;
  245. #endif
  246. // This IOCTL will mark the object as not longer able to receive events
  247. // BufferIn - WMIMARKASCLOSED
  248. // BufferOut -
  249. #define IOCTL_WMI_MARK_HANDLE_AS_CLOSED \
  250. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiMarkHandleAsClosed, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  251. typedef struct
  252. {
  253. HANDLE3264 Handle;
  254. } WMIMARKASCLOSED, *PWMIMARKASCLOSED;
  255. // This IOCTL will register for receiving an event
  256. // BufferIn - WMIRECEIVENOTIFICATIONS
  257. // BufferOut - WMIRECEIVENOTIFICATIONS
  258. #define IOCTL_WMI_RECEIVE_NOTIFICATIONS \
  259. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiReceiveNotif, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  260. //
  261. // WmiReceiveNotification
  262. //
  263. #define RECEIVE_ACTION_NONE 1 // No special action required
  264. #define RECEIVE_ACTION_CREATE_THREAD 2 // Mark guid objects as requiring
  265. // a new thread to be
  266. // created
  267. typedef struct
  268. {
  269. //
  270. // List of guid notification handles
  271. //
  272. ULONG HandleCount;
  273. ULONG Action;
  274. PVOID3264 /* PUSER_THREAD_START_ROUTINE */ UserModeCallback;
  275. HANDLE3264 UserModeProcess;
  276. HANDLE3264 Handles[1];
  277. } WMIRECEIVENOTIFICATION, *PWMIRECEIVENOTIFICATION;
  278. // This IOCTL will cause a registration notification to be generated
  279. // BufferIn - Not used
  280. // BufferOut - Not used
  281. #define IOCTL_WMI_NOTIFY_USER \
  282. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiNotifyUser, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  283. //
  284. // This IOCTL will return with the all registration info
  285. // BufferIn - Not used
  286. // BufferOut - Buffer to return all registration information
  287. #define IOCTL_WMI_GET_ALL_REGISTRANT \
  288. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiGetAllRegistrant, METHOD_BUFFERED, FILE_READ_ACCESS)
  289. //
  290. // This IOCTL will cause certain data providers to generate events
  291. // BufferIn - WnodeEventItem to use in firing event
  292. // BufferOut - Not Used
  293. #define IOCTL_WMI_GENERATE_EVENT \
  294. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiGenerateEvent, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  295. // This IOCTL will translate a File Object into a device object
  296. // BufferIn - pointer to incoming WMIFILETODEVICE structure
  297. // BufferOut - outgoing WMIFILETODEVICE structure
  298. #define IOCTL_WMI_TRANSLATE_FILE_HANDLE \
  299. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiTranslateFileHandle, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  300. //
  301. // This IOCTL will check if the caller has desired access to the guid
  302. // BufferIn - WMIOPENGUIDBLOCK
  303. // BufferOut - WMIOPENGUIDBLOCK
  304. #define IOCTL_WMI_CHECK_ACCESS \
  305. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiCheckAccess, METHOD_BUFFERED, FILE_READ_ACCESS)
  306. //
  307. // This IOCTL will determine the version of WMI
  308. // BufferIn - Not used
  309. // BufferOut - WMIVERSIONINFO
  310. #define IOCTL_WMI_GET_VERSION \
  311. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiGetVersion, METHOD_BUFFERED, FILE_READ_ACCESS)
  312. //
  313. // This IOCTL will return a list of guids registered with WMI
  314. // BufferIn - Not used
  315. // BufferOut - WMIGUIDLISTINFO
  316. //
  317. #define IOCTL_WMI_ENUMERATE_GUIDS \
  318. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiEnumerateGuidList, METHOD_BUFFERED, FILE_READ_ACCESS)
  319. //
  320. // This IOCTL will return a list of guids registered with WMI
  321. // BufferIn - Not used
  322. // BufferOut - WMIGUIDLISTINFO
  323. //
  324. #define IOCTL_WMI_ENUMERATE_GUIDS_AND_PROPERTIES \
  325. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiEnumerateGuidListAndProperties, METHOD_BUFFERED, FILE_READ_ACCESS)
  326. //
  327. // WmiEnumerateGuidList - Enumerate guids
  328. //
  329. // WMIGUIDPROPERTIES structure is used to return the properties of
  330. // all the registered guids in the EnumerateGuids call. The properties
  331. // GuidType - ( 0-TraceControlGuid, 1-TraceGuid, 2-DataGuid, 3-EventGuid )
  332. // LoggerId - If Trace guid and enabled, indicates the LoggerId to which this
  333. // Guid is currently logging data
  334. // EnableLevel - If Trace guid and enabled, indicates the level of logging
  335. // EnableFlags - If Trace guid and enabled, indicates the flags used in logging.
  336. // IsEnabled - Indicates whether this Guid is enabled currently. For data
  337. // guids this means if collection is enabled,
  338. // For event guids this means if events are enabled,
  339. // For trace guids this means trace logging is enabled.
  340. //
  341. typedef struct
  342. {
  343. GUID Guid;
  344. ULONG GuidType; // 0-TraceControlGuid, 1-TraceGuid, 2-DataGuid, 3-EventGuid
  345. ULONG LoggerId;
  346. ULONG EnableLevel;
  347. ULONG EnableFlags;
  348. BOOLEAN IsEnabled;
  349. } WMIGUIDPROPERTIES, *PWMIGUIDPROPERTIES;
  350. typedef struct
  351. {
  352. ULONG TotalGuidCount;
  353. ULONG ReturnedGuidCount;
  354. WMIGUIDPROPERTIES GuidList[1];
  355. } WMIGUIDLISTINFO, *PWMIGUIDLISTINFO;
  356. //
  357. // This IOCTL will return a list of guids registered with WMI
  358. // BufferIn - WMIGUIDINFO
  359. // BufferOut - WMIGUIDINFO
  360. //
  361. #define IOCTL_WMI_QUERY_GUID_INFO \
  362. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiQueryDataBlockInformation, METHOD_BUFFERED, FILE_READ_ACCESS)
  363. //
  364. // This IOCTL will return the list of mof resources registered
  365. //
  366. // BufferIn - not used
  367. // BufferOut - WMIMOFLIST
  368. #define IOCTL_WMI_ENUMERATE_MOF_RESOURCES \
  369. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiEnumerateMofResouces, METHOD_BUFFERED, FILE_READ_ACCESS)
  370. typedef struct
  371. {
  372. ULONG RegPathOffset;
  373. ULONG ResourceOffset;
  374. ULONG Flags;
  375. } WMIMOFENTRY, *PWMIMOFENTRY;
  376. #define WMIMOFENTRY_FLAG_USERMODE 0x00000001
  377. typedef struct
  378. {
  379. ULONG MofListCount;
  380. WMIMOFENTRY MofEntry[1];
  381. } WMIMOFLIST, *PWMIMOFLIST;
  382. //
  383. // This IOCTL notifies the kernel that a language has been added or
  384. // removed on a MUI system
  385. //
  386. // BufferIn - WMILANGUAGECHANGE
  387. // BufferOut - not used
  388. #define IOCTL_WMI_NOTIFY_LANGUAGE_CHANGE \
  389. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiNotifyLanguageChange, METHOD_BUFFERED, FILE_READ_ACCESS)
  390. #define MAX_LANGUAGE_SIZE 0x100
  391. typedef struct
  392. {
  393. WCHAR Language[MAX_LANGUAGE_SIZE];
  394. ULONG Flags;
  395. } WMILANGUAGECHANGE, *PWMILANGUAGECHANGE;
  396. #define WMILANGUAGECHANGE_FLAG_ADDED 0x00000001
  397. #define WMILANGUAGECHANGE_FLAG_REMOVED 0x00000002
  398. #define MOFEVENT_ACTION_IMAGE_PATH 0
  399. #define MOFEVENT_ACTION_REGISTRY_PATH 1
  400. #define MOFEVENT_ACTION_LANGUAGE_CHANGE 2
  401. #define MOFEVENT_ACTION_BINARY_MOF 3
  402. #if defined(_WINNT_) || defined(WINNT)
  403. #ifndef MEMPHIS
  404. #define WMIMAXREGGUIDCOUNT 65536
  405. //
  406. // This IOCTL will Register a set of guids with WMI
  407. //
  408. // BufferIn - WMIREGREQUEST followed by WMIREGINFOW
  409. // BufferOut - TRACEGUIDMAP[GuidCount] followed by WMIUMREGRESULTS.
  410. //
  411. #define IOCTL_WMI_REGISTER_GUIDS CTL_CODE(FILE_DEVICE_UNKNOWN, WmiRegisterGuids, METHOD_BUFFERED, FILE_READ_ACCESS)
  412. typedef struct
  413. {
  414. union {
  415. POBJECT_ATTRIBUTES ObjectAttributes;
  416. ULONG64 Dummy;
  417. };
  418. ULONG Cookie;
  419. ULONG GuidCount;
  420. ULONG WmiRegInfo32Size;
  421. ULONG WmiRegGuid32Size;
  422. } WMIREGREQUEST, *PWMIREGREQUEST;
  423. typedef struct
  424. {
  425. HANDLE3264 RequestHandle;
  426. ULONG64 LoggerContext;
  427. } WMIREGRESULTS, *PWMIREGRESULTS;
  428. //
  429. // This IOCTL will unregister a data provider
  430. //
  431. // BufferIn - WMIUNREGGUIDS
  432. // BufferOut - WMIUNREGGUIDS
  433. //
  434. #define IOCTL_WMI_UNREGISTER_GUIDS CTL_CODE(FILE_DEVICE_UNKNOWN, WmiUnregisterDP, METHOD_BUFFERED, FILE_READ_ACCESS)
  435. typedef struct
  436. {
  437. IN GUID Guid;
  438. IN HANDLE3264 RequestHandle;
  439. OUT ULONG64 LoggerContext;
  440. } WMIUNREGGUIDS, *PWMIUNREGGUIDS;
  441. //
  442. // This IOCTL will Create a user mode logger
  443. //
  444. // BufferIn - PWMICREATEUMLOGGER
  445. // BufferOut - PWMICREATEUMLOGGER
  446. typedef struct
  447. {
  448. IN POBJECT_ATTRIBUTES ObjectAttributes;
  449. IN GUID ControlGuid;
  450. OUT HANDLE3264 ReplyHandle;
  451. OUT ULONG ReplyCount;
  452. } WMICREATEUMLOGGER, *PWMICREATEUMLOGGER;
  453. typedef struct
  454. {
  455. IN ULONG ObjectAttributes;
  456. IN GUID ControlGuid;
  457. OUT HANDLE3264 ReplyHandle;
  458. OUT ULONG ReplyCount;
  459. } WMICREATEUMLOGGER32, *PWMICREATEUMLOGGER32;
  460. #define IOCTL_WMI_CREATE_UM_LOGGER CTL_CODE(FILE_DEVICE_UNKNOWN, WmiCreateUMLogger, METHOD_BUFFERED, FILE_READ_ACCESS)
  461. //
  462. // This IOCTL will reply to a MB request
  463. //
  464. // BufferIn - WMIMBREPLY
  465. // BufferOut - not used
  466. typedef struct
  467. {
  468. HANDLE3264 Handle;
  469. ULONG ReplyIndex;
  470. UCHAR Message[1];
  471. } WMIMBREPLY, *PWMIMBREPLY;
  472. #define IOCTL_WMI_MB_REPLY CTL_CODE(FILE_DEVICE_UNKNOWN, WmiMBReply, METHOD_BUFFERED, FILE_READ_ACCESS)
  473. //
  474. // This IOCTL will start an instance of a logger
  475. // BufferIn - Logger configuration information
  476. // BufferOut - Updated logger information when logger is started
  477. #define IOCTL_WMI_START_LOGGER \
  478. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiStartLoggerCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  479. //
  480. // This IOCTL will stop an instance of a logger
  481. // BufferIn - Logger information structure with Handle set
  482. // BufferOut - Updated logger information when logger is stopped
  483. #define IOCTL_WMI_STOP_LOGGER \
  484. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiStopLoggerCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  485. //
  486. // This IOCTL will update an existing logger attributes
  487. // BufferIn - Logger information structure with Handle set
  488. // BufferOut - Updated logger information
  489. #define IOCTL_WMI_UPDATE_LOGGER \
  490. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiUpdateLoggerCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  491. //
  492. // This IOCTL will flush all buffers of a logger
  493. // BufferIn - Logger configuration information
  494. // BufferOut - Updated logger information when logger is flushed
  495. #define IOCTL_WMI_FLUSH_LOGGER \
  496. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiFlushLoggerCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  497. //
  498. // This IOCTL will query a logger for its information
  499. // BufferIn - Logger information structure with Handle set
  500. // BufferOut - Updated logger information
  501. #define IOCTL_WMI_QUERY_LOGGER \
  502. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiQueryLoggerCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  503. //
  504. // This IOCTL will synchronize a trace record to the logger
  505. // BufferIn - Trace record, with handle set
  506. // BufferOut - Not used
  507. #define IOCTL_WMI_TRACE_EVENT \
  508. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiTraceEventCode, METHOD_NEITHER, FILE_WRITE_ACCESS)
  509. //
  510. // This IOCTL will synchronize a trace Message to the logger
  511. // BufferIn - Trace record, with handle
  512. // BufferOut - Not used
  513. #define IOCTL_WMI_TRACE_MESSAGE \
  514. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiTraceMessageCode, METHOD_NEITHER, FILE_WRITE_ACCESS)
  515. //
  516. // This IOCTL will set a mark in kernel logger
  517. // BufferIn - Logger information structure with Handle set
  518. // BufferOut - Not used
  519. #define IOCTL_WMI_SET_MARK \
  520. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiSetMarkCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  521. //
  522. // This IOCTL will set/get the logger information in the GuidEntry
  523. // in case we are starting NTDLL heap or crit sec tracing
  524. // BufferIn - WMINTDLLLOGGERINFO structure
  525. // BufferOut - updated WMINTDLLLOGGERINFO in case of Get.
  526. #define IOCTL_WMI_NTDLL_LOGGERINFO \
  527. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiNtdllLoggerCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  528. #define IOCTL_WMI_CLOCK_TYPE \
  529. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiClockTypeCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  530. #ifdef NTPERF
  531. //
  532. // This IOCTL will switch a buffer for UserMode Logging
  533. // BufferIn - WMI_SWITCH_PERFMEM_BUFFER_INFORMATION structure
  534. // BufferOut - Not used
  535. #define IOCTL_WMI_SWITCH_BUFFER \
  536. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiSwitchBufferCode, METHOD_BUFFERED, FILE_ANY_ACCESS)
  537. #endif //NTPERF
  538. #endif
  539. #endif // WINNT
  540. //
  541. // Notifications from kernel mode WMI to user mode WMI
  542. //
  543. #define NOTIFICATIONTYPES ULONG
  544. // A new data provider is being registered
  545. #define RegistrationAdd 0x00000001
  546. // A data provider is being removed
  547. #define RegistrationDelete 0x00000002
  548. // A data provider is being updated
  549. #define RegistrationUpdate 0x00000004
  550. // An event is fired by a data provider
  551. #define EventNotification 0x00000008
  552. #define NOTIFICATIONSLOT_MASK_NOTIFICATIONTYPES (RegistrationAdd | \
  553. RegistrationDelete | \
  554. RegistrationUpdate)
  555. #define INTERNALNOTIFICATIONSIZE (sizeof(WNODE_HEADER) + sizeof(KMREGINFO))
  556. //
  557. // This is used in IOCTL_WMI_GET_ALL_REGISTRANT to report the list of
  558. // registered KM data providers to the WMI service
  559. typedef struct
  560. {
  561. OUT ULONG ProviderId; // Provider Id (or device object pointer)
  562. OUT ULONG Flags; // REGENTRY_FLAG_*
  563. } KMREGINFO, *PKMREGINFO;
  564. #define REGENTRY_FLAG_NEWREGINFO 0x00000004 // Entry has new registration info
  565. #define REGENTRY_FLAG_UPDREGINFO 0x00000008 // Entry has updated registration info
  566. //
  567. // This structure is used in IOCTL_WMI_TRANSLATE_FILE_HANDLE
  568. typedef struct
  569. {
  570. union
  571. {
  572. IN HANDLE3264 FileHandle; // File handle whose instance name is needed
  573. OUT ULONG SizeNeeded; // If incoming buffer too small then this
  574. // returns with number bytes needed.
  575. };
  576. IN HANDLE3264 KernelHandle; // Kernel handle for data block
  577. OUT ULONG BaseIndex; //
  578. OUT USHORT InstanceNameLength; // Length of instance name in bytes
  579. OUT WCHAR InstanceNames[1]; // Instance name in unicode
  580. } WMIFHTOINSTANCENAME, *PWMIFHTOINSTANCENAME;
  581. #ifndef MEMPHIS
  582. //
  583. // This is used in IOCTL_WMI_OPEN_GUID
  584. // Guid must be in the form \WmiGuid\00000000-0000-0000-0000-000000000000
  585. #define WmiGuidObjectNameLength 45
  586. #define WmiGuidObjectDirectory L"\\WmiGuid\\"
  587. #define WmiGuidObjectDirectoryLength (sizeof(WmiGuidObjectDirectory) / sizeof(WCHAR))
  588. typedef struct
  589. {
  590. IN POBJECT_ATTRIBUTES ObjectAttributes;
  591. IN ACCESS_MASK DesiredAccess;
  592. OUT HANDLE3264 Handle;
  593. } WMIOPENGUIDBLOCK, *PWMIOPENGUIDBLOCK;
  594. typedef struct
  595. {
  596. IN UINT32 /* POBJECT_ATTRIBUTES32 */ ObjectAttributes;
  597. IN ACCESS_MASK DesiredAccess;
  598. OUT HANDLE3264 Handle;
  599. } WMIOPENGUIDBLOCK32, *PWMIOPENGUIDBLOCK32;
  600. typedef struct
  601. {
  602. GUID Guid;
  603. ACCESS_MASK DesiredAccess;
  604. } WMICHECKGUIDACCESS, *PWMICHECKGUIDACCESS;
  605. #endif
  606. //
  607. // This is the header in front of a WNODE request
  608. typedef struct
  609. {
  610. ULONG ProviderId; // Provider Id of target device
  611. } WMITARGET, *PWMITARGET;
  612. typedef struct
  613. {
  614. ULONG Length; // Length of this header
  615. ULONG Count; // Count of device object to target
  616. UCHAR Template[sizeof(WNODE_ALL_DATA)]; // Template WNODE_ALL_DATA
  617. WMITARGET Target[1]; // Provider ids for device object targets
  618. } WMITARGETHEADER, *PWMITARGETHEADER;
  619. //
  620. // This is used to retrieve the internal version of WMI in IOCTL_WMI_GET_VERSION
  621. #define WMI_CURRENT_VERSION 1
  622. typedef struct
  623. {
  624. ULONG32 Version;
  625. } WMIVERSIONINFO, *PWMIVERSIONINFO;
  626. //
  627. // WmiQueryGuidInfo
  628. typedef struct
  629. {
  630. HANDLE3264 KernelHandle;
  631. BOOLEAN IsExpensive;
  632. } WMIQUERYGUIDINFO, *PWMIQUERYGUIDINFO;
  633. #if defined(_WINNT_) || defined(WINNT)
  634. //
  635. // Used to enable and disable a tracelog provider
  636. //
  637. // BufferIn - WmiTraceEnableDisableInfo
  638. // BufferOut -
  639. #define IOCTL_WMI_ENABLE_DISABLE_TRACELOG \
  640. CTL_CODE(FILE_DEVICE_UNKNOWN, WmiEnableDisableTracelogProvider, METHOD_BUFFERED, FILE_READ_ACCESS)
  641. typedef struct
  642. {
  643. GUID Guid;
  644. ULONG64 LoggerContext;
  645. BOOLEAN Enable;
  646. } WMITRACEENABLEDISABLEINFO, *PWMITRACEENABLEDISABLEINFO;
  647. #define EVENT_TRACE_INTERNAL_FLAG_PRIVATE 0x01
  648. #endif // WINNT
  649. typedef struct
  650. {
  651. ULONGLONG GuidMapHandle;
  652. GUID Guid;
  653. ULONGLONG SystemTime;
  654. } TRACEGUIDMAP, *PTRACEGUIDMAP;
  655. typedef struct
  656. {
  657. WNODE_HEADER Wnode;
  658. ULONG64 LoggerContext;
  659. ULONG64 SecurityToken;
  660. } WMITRACE_NOTIFY_HEADER, *PWMITRACE_NOTIFY_HEADER;
  661. #ifndef MEMPHIS
  662. #define ENABLECRITSECTRACE 0x1
  663. #define DISABLECRITSECTRACE 0xFFFFFFFE
  664. #define ENABLEHEAPTRACE 0x2
  665. #define DISABLEHEAPTRACE 0xFFFFFFFD
  666. #define DISABLENTDLLTRACE 0xFFFFFFFC
  667. #endif
  668. #if _MSC_VER >= 1200
  669. #pragma warning(pop)
  670. #else
  671. #pragma warning( default: 4200 )
  672. #endif
  673. #endif // _WMIUMKM_