Wmistr.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:17k
源码类别:

模拟服务器

开发平台:

C/C++

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