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.

462 lines
16 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. Wmistr.h
  5. Abstract:
  6. WMI structure definitions
  7. --*/
  8. #ifndef _WMISTR_
  9. #define _WMISTR_
  10. #pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union
  11. //
  12. // WNODE definition
  13. typedef struct _WNODE_HEADER
  14. {
  15. ULONG BufferSize; // Size of entire buffer inclusive of this ULONG
  16. ULONG ProviderId; // Provider Id of driver returning this buffer
  17. union
  18. {
  19. ULONG64 HistoricalContext; // Logger use
  20. struct
  21. {
  22. ULONG Version; // Reserved
  23. ULONG Linkage; // Linkage field reserved for WMI
  24. };
  25. };
  26. union
  27. {
  28. ULONG CountLost; // Reserved
  29. HANDLE KernelHandle; // Kernel handle for data block
  30. LARGE_INTEGER TimeStamp; // Timestamp as returned in units of 100ns
  31. // since 1/1/1601
  32. };
  33. GUID Guid; // Guid for data block returned with results
  34. ULONG ClientContext;
  35. ULONG Flags; // Flags, see below
  36. } WNODE_HEADER, *PWNODE_HEADER;
  37. //
  38. // WNODE_HEADER flags are defined as follows
  39. #define WNODE_FLAG_ALL_DATA 0x00000001 // set for WNODE_ALL_DATA
  40. #define WNODE_FLAG_SINGLE_INSTANCE 0x00000002 // set for WNODE_SINGLE_INSTANCE
  41. #define WNODE_FLAG_SINGLE_ITEM 0x00000004 // set for WNODE_SINGLE_ITEM
  42. #define WNODE_FLAG_EVENT_ITEM 0x00000008 // set for WNODE_EVENT_ITEM
  43. // Set if data block size is
  44. // identical for all instances
  45. // (used with WNODE_ALL_DATA
  46. // only)
  47. #define WNODE_FLAG_FIXED_INSTANCE_SIZE 0x00000010
  48. #define WNODE_FLAG_TOO_SMALL 0x00000020 // set for WNODE_TOO_SMALL
  49. // Set when a data provider returns a
  50. // WNODE_ALL_DATA in which the number of
  51. // instances and their names returned
  52. // are identical to those returned from the
  53. // previous WNODE_ALL_DATA query. Only data
  54. // blocks registered with dynamic instance
  55. // names should use this flag.
  56. #define WNODE_FLAG_INSTANCES_SAME 0x00000040
  57. // Instance names are not specified in
  58. // WNODE_ALL_DATA; values specified at
  59. // registration are used instead. Always
  60. // set for guids registered with static
  61. // instance names
  62. #define WNODE_FLAG_STATIC_INSTANCE_NAMES 0x00000080
  63. #define WNODE_FLAG_INTERNAL 0x00000100 // Used internally by WMI
  64. // timestamp should not be modified by
  65. // a historical logger
  66. #define WNODE_FLAG_USE_TIMESTAMP 0x00000200
  67. #define WNODE_FLAG_PERSIST_EVENT 0x00000400
  68. #define WNODE_FLAG_EVENT_REFERENCE 0x00002000
  69. // Set if Instance names are ansi. Only set when returning from
  70. // WMIQuerySingleInstanceA and WMIQueryAllDataA
  71. #define WNODE_FLAG_ANSI_INSTANCENAMES 0x00004000
  72. // Set if WNODE is a method call
  73. #define WNODE_FLAG_METHOD_ITEM 0x00008000
  74. // Set if instance names originated from a PDO
  75. #define WNODE_FLAG_PDO_INSTANCE_NAMES 0x00010000
  76. // The second byte, except the first bit is used exclusively for tracing
  77. #define WNODE_FLAG_TRACED_GUID 0x00020000 // denotes a trace
  78. #define WNODE_FLAG_LOG_WNODE 0x00040000 // request to log Wnode
  79. #define WNODE_FLAG_USE_GUID_PTR 0x00080000 // Guid is actually a pointer
  80. #define WNODE_FLAG_USE_MOF_PTR 0x00100000 // MOF data are dereferenced
  81. #define WNODE_FLAG_INTERNAL2 0x00200000 // Used internally by WMI
  82. // Set for events that are WNODE_EVENT_REFERENCE
  83. // Mask for event severity level. Level 0xff is the most severe type of event
  84. #define WNODE_FLAG_SEVERITY_MASK 0xff000000
  85. //
  86. // This structure is used within the WNODE_ALL_DATA when the data blocks
  87. // for the different instances are different lengths. If the data blocks
  88. // for the different instances are identical lengths then
  89. // WNODE_FLAG_FIXED_INSTANCE_SIZE should be set and FixedInstanceSize
  90. // set to the common data block size.
  91. typedef struct
  92. {
  93. ULONG OffsetInstanceData; // Offset from beginning of WNODE_ALL_DATA
  94. // to Data block for instance
  95. ULONG LengthInstanceData; // Length of data block for instance
  96. } OFFSETINSTANCEDATAANDLENGTH, *POFFSETINSTANCEDATAANDLENGTH;
  97. typedef struct tagWNODE_ALL_DATA
  98. {
  99. struct _WNODE_HEADER WnodeHeader;
  100. ULONG DataBlockOffset;// Offset from begin of WNODE to first data block
  101. ULONG InstanceCount; // Count of instances whose data follows.
  102. // Offset to an array of offsets to the instance names
  103. ULONG OffsetInstanceNameOffsets;
  104. // If WNODE_FLAG_FIXED_INSTANCE_SIZE is set in Flags then
  105. // FixedInstanceSize specifies the size of each data block. In this case
  106. // there is one ULONG followed by the data blocks.
  107. // If WNODE_FLAG_FIXED_INSTANCE_SIZE is not set
  108. // then OffsetInstanceDataAndLength
  109. // is an array of OFFSETINSTANCEDATAANDLENGTH that specifies the
  110. // offsets and lengths of the data blocks for each instance.
  111. union
  112. {
  113. ULONG FixedInstanceSize;
  114. OFFSETINSTANCEDATAANDLENGTH OffsetInstanceDataAndLength[];
  115. /* [InstanceCount] */
  116. };
  117. // padding so that first data block begins on a 8 byte boundry
  118. // data blocks and instance names for all instances
  119. } WNODE_ALL_DATA, *PWNODE_ALL_DATA;
  120. typedef struct tagWNODE_SINGLE_INSTANCE
  121. {
  122. struct _WNODE_HEADER WnodeHeader;
  123. // Offset from beginning of WNODE_SINGLE_INSTANCE
  124. // to instance name. Use when
  125. // WNODE_FLAG_STATIC_INSTANCE_NAMES is reset
  126. // (Dynamic instance names)
  127. ULONG OffsetInstanceName;
  128. // Instance index when
  129. // WNODE_FLAG_STATIC_INSTANCE_NAME is set
  130. ULONG InstanceIndex; // (Static Instance Names)
  131. ULONG DataBlockOffset; // offset from beginning of WNODE to data block
  132. ULONG SizeDataBlock; // Size of data block for instance
  133. UCHAR VariableData[];
  134. // instance names and padding so data block begins on 8 byte boundry
  135. // data block
  136. } WNODE_SINGLE_INSTANCE, *PWNODE_SINGLE_INSTANCE;
  137. typedef struct tagWNODE_SINGLE_ITEM
  138. {
  139. struct _WNODE_HEADER WnodeHeader;
  140. // Offset from beginning of WNODE_SINGLE_INSTANCE
  141. // to instance name. Examine when
  142. // WNODE_FLAG_STATIC_INSTANCE_NAME is reset
  143. // (Dynamic instance names)
  144. ULONG OffsetInstanceName;
  145. // Instance index when
  146. // WNODE_FLAG_STATIC_INSTANCE_NAME
  147. ULONG InstanceIndex; // set (Static Instance Names)
  148. ULONG ItemId; // Item Id for data item being set
  149. ULONG DataBlockOffset; // offset from WNODE begin to data item value
  150. ULONG SizeDataItem; // Size of data item
  151. UCHAR VariableData[];
  152. // instance names and padding so data value begins on 8 byte boundry
  153. // data item value
  154. } WNODE_SINGLE_ITEM, *PWNODE_SINGLE_ITEM;
  155. typedef struct tagWNODE_METHOD_ITEM
  156. {
  157. struct _WNODE_HEADER WnodeHeader;
  158. // Offset from beginning of WNODE_METHOD_ITEM
  159. // to instance name. Examine when
  160. // WNODE_FLAG_STATIC_INSTANCE_NAME is reset
  161. // (Dynamic instance names)
  162. ULONG OffsetInstanceName;
  163. // Instance index when
  164. // WNODE_FLAG_STATIC_INSTANCE_NAME
  165. ULONG InstanceIndex; // set (Static Instance Names)
  166. ULONG MethodId; // Method id of method being called
  167. ULONG DataBlockOffset; // On Entry: offset from WNODE to input data
  168. // On Return: offset from WNODE to input and
  169. // output data blocks
  170. ULONG SizeDataBlock; // On Entry: Size of input data, 0 if no input
  171. // data
  172. // On Return: Size of output data, 0 if no output
  173. // data
  174. UCHAR VariableData[];
  175. // instance names and padding so data value begins on 8 byte boundry
  176. // data item value
  177. } WNODE_METHOD_ITEM, *PWNODE_METHOD_ITEM;
  178. typedef struct tagWNODE_EVENT_ITEM
  179. {
  180. struct _WNODE_HEADER WnodeHeader;
  181. // Different data could be here depending upon the flags set in the
  182. // WNODE_HEADER above. If the WNODE_FLAG_ALL_DATA flag is set then the
  183. // contents of a WNODE_ALL_DATA (excluding WNODE_HEADER) is here. If the
  184. // WNODE_FLAG_SINGLE_INSTANCE flag is set then a WNODE_SINGLE_INSTANCE
  185. // (excluding WNODE_HEADER) is here. Lastly if the WNODE_FLAG_SINGLE_ITEM
  186. // flag is set then a WNODE_SINGLE_ITEM (excluding WNODE_HEADER) is here.
  187. } WNODE_EVENT_ITEM, *PWNODE_EVENT_ITEM;
  188. //
  189. // If a KM data provider needs to fire an event that is larger than the
  190. // maximum size that WMI allows then it should fire a WNODE_EVENT_REFERENCE
  191. // that specifies which guid and instance name to query for the actual data
  192. // that should be part of the event.
  193. typedef struct tagWNODE_EVENT_REFERENCE
  194. {
  195. struct _WNODE_HEADER WnodeHeader;
  196. GUID TargetGuid;
  197. ULONG TargetDataBlockSize;
  198. union
  199. {
  200. ULONG TargetInstanceIndex;
  201. WCHAR TargetInstanceName[];
  202. };
  203. } WNODE_EVENT_REFERENCE, *PWNODE_EVENT_REFERENCE;
  204. typedef struct tagWNODE_TOO_SMALL
  205. {
  206. struct _WNODE_HEADER WnodeHeader;
  207. ULONG SizeNeeded; // Size needed to build WNODE result
  208. } WNODE_TOO_SMALL, *PWNODE_TOO_SMALL;
  209. typedef struct
  210. {
  211. GUID Guid; // Guid of data block being registered or updated
  212. ULONG Flags; // Flags
  213. ULONG InstanceCount; // Count of static instances names for the guid
  214. union
  215. {
  216. // If WMIREG_FLAG_INSTANCE_LIST then this has the offset
  217. // to a list of InstanceCount counted UNICODE
  218. // strings placed end to end.
  219. ULONG InstanceNameList;
  220. // If WMIREG_FLAG_INSTANCE_BASENAME then this has the
  221. // offset to a single counted UNICODE string that
  222. // has the basename for the instance names.
  223. ULONG BaseNameOffset;
  224. // If WMIREG_FLAG_INSTANCE_PDO is set then InstanceInfo
  225. // has the PDO whose device instance path will
  226. // become the instance name
  227. ULONG_PTR Pdo;
  228. // If WMIREG_FLAG_INSTANCE_REFERENCE then this points to
  229. // a WMIREGINSTANCEREF structure.
  230. ULONG_PTR InstanceInfo;// Offset from beginning of the WMIREGINFO structure to
  231. };
  232. } WMIREGGUIDW, *PWMIREGGUIDW;
  233. typedef WMIREGGUIDW WMIREGGUID;
  234. typedef PWMIREGGUIDW PWMIREGGUID;
  235. // Set if collection must be enabled for the guid before the data provider
  236. // can be queried for data.
  237. #define WMIREG_FLAG_EXPENSIVE 0x00000001
  238. // Set if instance names for this guid are specified in a static list within
  239. // the WMIREGINFO
  240. #define WMIREG_FLAG_INSTANCE_LIST 0x00000004
  241. // Set if instance names are to be static and generated by WMI using a
  242. // base name in the WMIREGINFO and an index
  243. #define WMIREG_FLAG_INSTANCE_BASENAME 0x00000008
  244. // Set if WMI should do automatic mapping of a PDO to device instance name
  245. // as the instance name for the guid. This flag should only be used by
  246. // kernel mode data providers.
  247. #define WMIREG_FLAG_INSTANCE_PDO 0x00000020
  248. // Note the flags WMIREG_FLAG_INSTANCE_LIST, WMIREG_FLAG_INSTANCE_BASENAME,
  249. // WMIREG_FLAG_INSTANCE_REFERENCE and WMIREG_FLAG_INSTANCE_PDO are mutually
  250. // exclusive.
  251. //
  252. // These flags are only valid in a response to WMI_GUID_REGUPDATE
  253. #define WMIREG_FLAG_REMOVE_GUID 0x00010000 // Remove support for guid
  254. #define WMIREG_FLAG_RESERVED1 0x00020000 // Reserved by WMI
  255. #define WMIREG_FLAG_RESERVED2 0x00040000 // Reserved by WMI
  256. // Set if guid is one that is written to trace log.
  257. // This guid cannot be queried directly via WMI, but must be read using
  258. // logger apis.
  259. #define WMIREG_FLAG_TRACED_GUID 0x00080000
  260. //
  261. // Only those Trace Guids that have this bit set can receive
  262. // Enable/Disable Notifications.
  263. //
  264. #define WMIREG_FLAG_TRACE_CONTROL_GUID 0x00001000
  265. //
  266. // Set if the guid is only used for firing events. Guids that can be queried
  267. // and that fire events should not have this bit set.
  268. #define WMIREG_FLAG_EVENT_ONLY_GUID 0x00000040
  269. typedef struct
  270. {
  271. // Size of entire WMIREGINFO structure including this ULONG
  272. // and any static instance names that follow
  273. ULONG BufferSize;
  274. ULONG NextWmiRegInfo; // Offset to next WMIREGINFO structure
  275. ULONG RegistryPath; // Offset from beginning of WMIREGINFO structure to a
  276. // counted Unicode string containing
  277. // the driver registry path (under HKLM\CCS\Services)
  278. // This must be filled only by kernel mode data
  279. // providers
  280. // Offset from beginning of WMIREGINFO structure to a
  281. // counted Unicode string containing
  282. // the name of resource in driver file containing MOF info
  283. ULONG MofResourceName;
  284. // Count of WMIREGGUID structures immediately following
  285. ULONG GuidCount;
  286. WMIREGGUIDW WmiRegGuid[]; // array of GuidCount WMIREGGUID structures
  287. // Variable length data including :
  288. // Instance Names
  289. } WMIREGINFOW, *PWMIREGINFOW;
  290. typedef WMIREGINFOW WMIREGINFO;
  291. typedef PWMIREGINFOW PWMIREGINFO;
  292. //
  293. // WMI request codes
  294. typedef enum
  295. {
  296. #ifndef _WMIKM_
  297. WMI_GET_ALL_DATA = 0,
  298. WMI_GET_SINGLE_INSTANCE = 1,
  299. WMI_SET_SINGLE_INSTANCE = 2,
  300. WMI_SET_SINGLE_ITEM = 3,
  301. WMI_ENABLE_EVENTS = 4,
  302. WMI_DISABLE_EVENTS = 5,
  303. WMI_ENABLE_COLLECTION = 6,
  304. WMI_DISABLE_COLLECTION = 7,
  305. WMI_REGINFO = 8,
  306. WMI_EXECUTE_METHOD = 9
  307. #endif
  308. } WMIDPREQUESTCODE;
  309. #if defined(_WINNT_) || defined(WINNT)
  310. //
  311. // WMI guid objects have the following rights
  312. // WMIGUID_QUERY
  313. // WMIGUID_SET
  314. // WMIGUID_NOTIFICATION
  315. // WMIGUID_READ_DESCRIPTION
  316. // WMIGUID_EXECUTE
  317. // TRACELOG_CREATE_REALTIME
  318. // TRACELOG_CREATE_ONDISK
  319. // TRACELOG_GUID_ENABLE
  320. // TRACELOG_ACCESS_KERNEL_LOGGER
  321. // TRACELOG_CREATE_INPROC
  322. // TRACELOG_ACCESS_REALTIME
  323. //
  324. // GuidTypes
  325. //
  326. //#ifndef _WMIKM_
  327. #define WMI_GUIDTYPE_TRACECONTROL 0
  328. #define WMI_GUIDTYPE_TRACE 1
  329. #define WMI_GUIDTYPE_DATA 2
  330. #define WMI_GUIDTYPE_EVENT 3
  331. //#endif
  332. //
  333. // Specific rights for WMI guid objects. These are available from 0x0001 to
  334. // 0xffff (ie up to 16 rights)
  335. //
  336. #define WMIGUID_QUERY 0x0001
  337. #define WMIGUID_SET 0x0002
  338. #define WMIGUID_NOTIFICATION 0x0004
  339. #define WMIGUID_READ_DESCRIPTION 0x0008
  340. #define WMIGUID_EXECUTE 0x0010
  341. #define TRACELOG_CREATE_REALTIME 0x0020
  342. #define TRACELOG_CREATE_ONDISK 0x0040
  343. #define TRACELOG_GUID_ENABLE 0x0080
  344. #define TRACELOG_ACCESS_KERNEL_LOGGER 0x0100
  345. #define TRACELOG_CREATE_INPROC 0x0200
  346. #define TRACELOG_ACCESS_REALTIME 0x0400
  347. #define TRACELOG_REGISTER_GUIDS 0x0800
  348. #define WMIGUID_ALL_ACCESS (STANDARD_RIGHTS_READ | \
  349. SYNCHRONIZE | \
  350. WMIGUID_QUERY | \
  351. WMIGUID_SET | \
  352. WMIGUID_NOTIFICATION | \
  353. WMIGUID_READ_DESCRIPTION | \
  354. WMIGUID_EXECUTE | \
  355. TRACELOG_CREATE_REALTIME | \
  356. TRACELOG_CREATE_ONDISK | \
  357. TRACELOG_GUID_ENABLE | \
  358. TRACELOG_ACCESS_KERNEL_LOGGER |\
  359. TRACELOG_CREATE_INPROC | \
  360. TRACELOG_ACCESS_REALTIME | \
  361. TRACELOG_REGISTER_GUIDS )
  362. #define WMI_GLOBAL_LOGGER_ID 0x0001
  363. #endif
  364. #endif