home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / wmistr.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  16.4 KB  |  462 lines

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