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.

473 lines
17 KiB

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