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.

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