1 /* Copyright (c) 2015 Goldstein Lyor, All Rights Reserved
2  *
3  * The contents of this file is dual-licensed under 2
4  * alternative Open Source/Free licenses: LGPL 2.1 or later and
5  * Apache License 2.0. (starting with JNA version 4.0.0).
6  *
7  * You can freely decide which license you want to apply to
8  * the project.
9  *
10  * You may obtain a copy of the LGPL License at:
11  *
12  * http://www.gnu.org/licenses/licenses.html
13  *
14  * A copy is also included in the downloadable source code package
15  * containing JNA, in file "LGPL2.1".
16  *
17  * You may obtain a copy of the Apache License at:
18  *
19  * http://www.apache.org/licenses/
20  *
21  * A copy is also included in the downloadable source code package
22  * containing JNA, in file "AL2.0".
23  */
24 package com.sun.jna.platform.win32;
25 
26 import com.sun.jna.NativeLong;
27 import com.sun.jna.Pointer;
28 import com.sun.jna.Structure;
29 import com.sun.jna.Structure.FieldOrder;
30 import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
31 import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
32 
33 /**
34  * Various performance counters structures and definitions
35  * @author Lyor Goldstein
36  * @see <A HREF="https://msdn.microsoft.com/en-us/library/windows/desktop/aa373093(v=vs.85).aspx">Performance Counters Structures</A>
37  */
38 public interface WinPerf {
39 
40     int PERF_NO_INSTANCES = -1;  // no instances (see NumInstances above)
41 
42     //
43     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44     //
45     //  PERF_COUNTER_DEFINITION.CounterType field values
46     //
47     //
48     //            Counter ID Field Definition:
49     //
50     //   3      2        2    2    2        1        1    1
51     //   1      8        4    2    0        6        2    0    8                0
52     //  +--------+--------+----+----+--------+--------+----+----+----------------+
53     //  |Display |Calculation  |Time|Counter |        |Ctr |Size|                |
54     //  |Flags   |Modifiers    |Base|SubType |Reserved|Type|Fld |   Reserved     |
55     //  +--------+--------+----+----+--------+--------+----+----+----------------+
56     //
57     //
58     //  The counter type is the "or" of the following values as described below
59     //
60     //  select one of the following to indicate the counter's data size
61     //
62     int PERF_SIZE_DWORD        = 0x00000000;  // 32 bit field
63     int PERF_SIZE_LARGE        = 0x00000100;  // 64 bit field
64     int PERF_SIZE_ZERO         = 0x00000200;  // for Zero Length fields
65     int PERF_SIZE_VARIABLE_LEN = 0x00000300;  // length is in CounterLength field
66                                                 //  of Counter Definition struct
67     //
68     //  select one of the following values to indicate the counter field usage
69     //
70     int PERF_TYPE_NUMBER  = 0x00000000;  // a number (not a counter)
71     int PERF_TYPE_COUNTER = 0x00000400;  // an increasing numeric value
72     int PERF_TYPE_TEXT    = 0x00000800;  // a text field
73     int PERF_TYPE_ZERO    = 0x00000C00;  // displays a zero
74     //
75     //  If the PERF_TYPE_NUMBER field was selected, then select one of the
76     //  following to describe the Number
77     //
78     int PERF_NUMBER_HEX      = 0x00000000;  // display as HEX value
79     int PERF_NUMBER_DECIMAL  = 0x00010000;  // display as a decimal integer
80     int PERF_NUMBER_DEC_1000 = 0x00020000;  // display as a decimal/1000
81     //
82     //  If the PERF_TYPE_COUNTER value was selected then select one of the
83     //  following to indicate the type of counter
84     //
85     int PERF_COUNTER_VALUE     = 0x00000000;  // display counter value
86     int PERF_COUNTER_RATE      = 0x00010000;  // divide ctr / delta time
87     int PERF_COUNTER_FRACTION  = 0x00020000;  // divide ctr / base
88     int PERF_COUNTER_BASE      = 0x00030000;  // base value used in fractions
89     int PERF_COUNTER_ELAPSED   = 0x00040000;  // subtract counter from current time
90     int PERF_COUNTER_QUEUELEN  = 0x00050000;  // Use Queuelen processing func.
91     int PERF_COUNTER_HISTOGRAM = 0x00060000;  // Counter begins or ends a histogram
92     int PERF_COUNTER_PRECISION = 0x00070000;  // divide ctr / private clock
93     //
94     //  If the PERF_TYPE_TEXT value was selected, then select one of the
95     //  following to indicate the type of TEXT data.
96     //
97     int PERF_TEXT_UNICODE = 0x00000000;  // type of text in text field
98     int PERF_TEXT_ASCII   = 0x00010000;  // ASCII using the CodePage field
99     //
100     //  Timer SubTypes
101     //
102     int PERF_TIMER_TICK   = 0x00000000;  // use system perf. freq for base
103     int PERF_TIMER_100NS  = 0x00100000;  // use 100 NS timer time base units
104     int PERF_OBJECT_TIMER = 0x00200000;  // use the object timer freq
105     //
106     //  Any types that have calculations performed can use one or more of
107     //  the following calculation modification flags listed here
108     //
109     int PERF_DELTA_COUNTER   = 0x00400000;  // compute difference first
110     int PERF_DELTA_BASE      = 0x00800000;  // compute base diff as well
111     int PERF_INVERSE_COUNTER = 0x01000000;  // show as 1.00-value (assumes:
112     int PERF_MULTI_COUNTER   = 0x02000000;  // sum of multiple instances
113     //
114     //  Select one of the following values to indicate the display suffix (if any)
115     //
116     int PERF_DISPLAY_NO_SUFFIX = 0x00000000;  // no suffix
117     int PERF_DISPLAY_PER_SEC   = 0x10000000;  // "/sec"
118     int PERF_DISPLAY_PERCENT   = 0x20000000;  // "%"
119     int PERF_DISPLAY_SECONDS   = 0x30000000;  // "secs"
120     int PERF_DISPLAY_NOSHOW    = 0x40000000;  // value is not displayed
121     //
122     //  Predefined counter types
123     //
124 
125     // 32-bit Counter.  Divide delta by delta time.  Display suffix: "/sec"
126     int PERF_COUNTER_COUNTER =
127                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
128                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC);
129 
130 
131     // 64-bit Timer.  Divide delta by delta time.  Display suffix: "%"
132     int PERF_COUNTER_TIMER =
133                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
134                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT);
135 
136     // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix.
137     int PERF_COUNTER_QUEUELEN_TYPE =
138                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN |
139                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
140 
141     // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix.
142     int PERF_COUNTER_LARGE_QUEUELEN_TYPE =
143                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN |
144                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
145 
146     // Queue Length Space-Time Product using 100 Ns timebase.
147     // Divide delta by delta time. No Display Suffix.
148     int PERF_COUNTER_100NS_QUEUELEN_TYPE =
149                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN |
150                 PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
151 
152     // Queue Length Space-Time Product using Object specific timebase.
153     // Divide delta by delta time. No Display Suffix.
154     int PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE =
155                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN |
156                 PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
157 
158     // 64-bit Counter.  Divide delta by delta time. Display Suffix: "/sec"
159     int PERF_COUNTER_BULK_COUNT =
160                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
161                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC);
162 
163     // Indicates the counter is not a  counter but rather Unicode text Display as text.
164     int PERF_COUNTER_TEXT =
165                 (PERF_SIZE_VARIABLE_LEN | PERF_TYPE_TEXT | PERF_TEXT_UNICODE |
166                 PERF_DISPLAY_NO_SUFFIX);
167 
168     // Indicates the data is a counter  which should not be
169     // time averaged on display (such as an error counter on a serial line)
170     // Display as is.  No Display Suffix.
171     int PERF_COUNTER_RAWCOUNT =
172                 (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL |
173                 PERF_DISPLAY_NO_SUFFIX);
174 
175     // Same as PERF_COUNTER_RAWCOUNT except its size is a large integer
176     int PERF_COUNTER_LARGE_RAWCOUNT =
177                 (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL |
178                 PERF_DISPLAY_NO_SUFFIX);
179 
180     // Special case for RAWCOUNT that want to be displayed in hex
181     // Indicates the data is a counter  which should not be
182     // time averaged on display (such as an error counter on a serial line)
183     // Display as is.  No Display Suffix.
184     int PERF_COUNTER_RAWCOUNT_HEX =
185                 (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_HEX |
186                 PERF_DISPLAY_NO_SUFFIX);
187 
188     // Same as PERF_COUNTER_RAWCOUNT_HEX except its size is a large integer
189     int PERF_COUNTER_LARGE_RAWCOUNT_HEX =
190                 (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_HEX |
191                 PERF_DISPLAY_NO_SUFFIX);
192 
193 
194     // A count which is either 1 or 0 on each sampling interrupt (% busy)
195     // Divide delta by delta base. Display Suffix: "%"
196     int PERF_SAMPLE_FRACTION =
197                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION |
198                 PERF_DELTA_COUNTER | PERF_DELTA_BASE | PERF_DISPLAY_PERCENT);
199 
200     // A count which is sampled on each sampling interrupt (queue length)
201     // Divide delta by delta time. No Display Suffix.
202     int PERF_SAMPLE_COUNTER =
203                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
204                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
205 
206     // A label: no data is associated with this counter (it has 0 length)
207     // Do not display.
208     int PERF_COUNTER_NODATA =
209                 (PERF_SIZE_ZERO | PERF_DISPLAY_NOSHOW);
210 
211     // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
212     // Display 100 - delta divided by delta time.  Display suffix: "%"
213     int PERF_COUNTER_TIMER_INV =
214                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
215                 PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER |
216                 PERF_DISPLAY_PERCENT);
217 
218     // The divisor for a sample, used with the previous counter to form a
219     // sampled %.  You must check for >0 before dividing by this!  This
220     // counter will directly follow the  numerator counter.  It should not
221     // be displayed to the user.
222     int PERF_SAMPLE_BASE =
223                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE |
224                 PERF_DISPLAY_NOSHOW |
225                 0x00000001);  // for compatibility with pre-beta versions
226 
227     // A timer which, when divided by an average base, produces a time
228     // in seconds which is the average time of some operation.  This
229     // timer times total operations, and  the base is the number of opera-
230     // tions.  Display Suffix: "sec"
231     int PERF_AVERAGE_TIMER =
232                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION |
233                 PERF_DISPLAY_SECONDS);
234 
235     // Used as the denominator in the computation of time or count
236     // averages.  Must directly follow the numerator counter.  Not dis-
237     // played to the user.
238     int PERF_AVERAGE_BASE =
239                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE |
240                 PERF_DISPLAY_NOSHOW |
241                 0x00000002);  // for compatibility with pre-beta versions
242 
243 
244     // A bulk count which, when divided (typically) by the number of
245     // operations, gives (typically) the number of bytes per operation.
246     // No Display Suffix.
247     int PERF_AVERAGE_BULK =
248                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION  |
249                 PERF_DISPLAY_NOSHOW);
250 
251     // 64-bit Timer in object specific units. Display delta divided by
252     // delta time as returned in the object type header structure.  Display suffix: "%"
253     int PERF_OBJ_TIME_TIMER =
254                 (PERF_SIZE_LARGE   | PERF_TYPE_COUNTER  | PERF_COUNTER_RATE |
255                  PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT);
256 
257 
258     // 64-bit Timer in 100 nsec units. Display delta divided by
259     // delta time.  Display suffix: "%"
260     int PERF_100NSEC_TIMER =
261                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
262                 PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT);
263 
264     // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
265     // Display 100 - delta divided by delta time.  Display suffix: "%"
266     int PERF_100NSEC_TIMER_INV =
267                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
268                 PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER  |
269                 PERF_DISPLAY_PERCENT);
270 
271     // 64-bit Timer.  Divide delta by delta time.  Display suffix: "%"
272     // Timer for multiple instances, so result can exceed 100%.
273     int PERF_COUNTER_MULTI_TIMER =
274                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
275                 PERF_DELTA_COUNTER | PERF_TIMER_TICK | PERF_MULTI_COUNTER |
276                 PERF_DISPLAY_PERCENT);
277 
278     // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
279     // Display 100 * _MULTI_BASE - delta divided by delta time.
280     // Display suffix: "%" Timer for multiple instances, so result
281     // can exceed 100%.  Followed by a counter of type _MULTI_BASE.
282     int PERF_COUNTER_MULTI_TIMER_INV =
283                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE |
284                 PERF_DELTA_COUNTER | PERF_MULTI_COUNTER | PERF_TIMER_TICK |
285                 PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT);
286 
287     // Number of instances to which the preceding _MULTI_..._INV counter
288     // applies.  Used as a factor to get the percentage.
289     int PERF_COUNTER_MULTI_BASE =
290                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE |
291                 PERF_MULTI_COUNTER | PERF_DISPLAY_NOSHOW);
292 
293     // 64-bit Timer in 100 nsec units. Display delta divided by delta time.
294     // Display suffix: "%" Timer for multiple instances, so result can exceed 100%.
295     int PERF_100NSEC_MULTI_TIMER =
296                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER  |
297                 PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER |
298                 PERF_DISPLAY_PERCENT);
299 
300     // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
301     // Display 100 * _MULTI_BASE - delta divided by delta time.
302     // Display suffix: "%" Timer for multiple instances, so result
303     // can exceed 100%.  Followed by a counter of type _MULTI_BASE.
304     int PERF_100NSEC_MULTI_TIMER_INV =
305                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER  |
306                 PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER |
307                 PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT);
308 
309     // Indicates the data is a fraction of the following counter  which
310     // should not be time averaged on display (such as free space over
311     // total space.) Display as is.  Display the quotient as "%".
312     int PERF_RAW_FRACTION =
313                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION |
314                 PERF_DISPLAY_PERCENT);
315 
316     int PERF_LARGE_RAW_FRACTION =
317                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION |
318                 PERF_DISPLAY_PERCENT);
319 
320     // Indicates the data is a base for the preceding counter which should
321     // not be time averaged on display (such as free space over total space.)
322     int PERF_RAW_BASE =
323                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE |
324                 PERF_DISPLAY_NOSHOW |
325                 0x00000003);  // for compatibility with pre-beta versions
326 
327     int PERF_LARGE_RAW_BASE =
328                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE |
329                 PERF_DISPLAY_NOSHOW );
330 
331     // The data collected in this counter is actually the start time of the
332     // item being measured. For display, this data is subtracted from the
333     // sample time to yield the elapsed time as the difference between the two.
334     // In the definition below, the PerfTime field of the Object contains
335     // the sample time as indicated by the PERF_OBJECT_TIMER bit and the
336     // difference is scaled by the PerfFreq of the Object to convert the time
337     // units into seconds.
338     int PERF_ELAPSED_TIME =
339                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_ELAPSED |
340                 PERF_OBJECT_TIMER | PERF_DISPLAY_SECONDS);
341     //
342     //  The following counter type can be used with the preceding types to
343     //  define a range of values to be displayed in a histogram.
344     //
345 
346     int PERF_COUNTER_HISTOGRAM_TYPE = 0x80000000; // Counter begins or ends a histogram
347     //
348     //  This counter is used to display the difference from one sample
349     //  to the next. The counter value is a constantly increasing number
350     //  and the value displayed is the difference between the current
351     //  value and the previous value. Negative numbers are not allowed
352     //  which shouldn't be a problem as long as the counter value is
353     //  increasing or unchanged.
354     //
355     int PERF_COUNTER_DELTA =
356                 (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE |
357                 PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
358 
359     int PERF_COUNTER_LARGE_DELTA =
360                 (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE |
361                 PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX);
362     //
363     //  The precision counters are timers that consist of two counter values:
364     //          1) the count of elapsed time of the event being monitored
365     //          2) the "clock" time in the same units
366     //
367     //  the precition timers are used where the standard system timers are not
368     //  precise enough for accurate readings. It's assumed that the service
369     //  providing the data is also providing a timestamp at the same time which
370     //  will eliminate any error that may occur since some small and variable
371     //  time elapses between the time the system timestamp is captured and when
372     //  the data is collected from the performance DLL. Only in extreme cases
373     //  has this been observed to be problematic.
374     //
375     //  when using this type of timer, the definition of the
376     //  PERF_PRECISION_TIMESTAMP counter must immediately follow the
377     //  definition of the PERF_PRECISION_*_TIMER in the Object header
378     //
379     // The timer used has the same frequency as the System Performance Timer
380     int PERF_PRECISION_SYSTEM_TIMER =
381             (PERF_SIZE_LARGE    | PERF_TYPE_COUNTER     | PERF_COUNTER_PRECISION    |
382              PERF_TIMER_TICK    | PERF_DELTA_COUNTER    | PERF_DISPLAY_PERCENT   );
383     //
384     // The timer used has the same frequency as the 100 NanoSecond Timer
385     int PERF_PRECISION_100NS_TIMER  =
386             (PERF_SIZE_LARGE    | PERF_TYPE_COUNTER     | PERF_COUNTER_PRECISION    |
387              PERF_TIMER_100NS   | PERF_DELTA_COUNTER    | PERF_DISPLAY_PERCENT   );
388     //
389     // The timer used is of the frequency specified in the Object header's
390     //  PerfFreq field (PerfTime is ignored)
391     int PERF_PRECISION_OBJECT_TIMER =
392             (PERF_SIZE_LARGE    | PERF_TYPE_COUNTER     | PERF_COUNTER_PRECISION    |
393              PERF_OBJECT_TIMER  | PERF_DELTA_COUNTER    | PERF_DISPLAY_PERCENT   );
394     //
395     // This is the timestamp to use in the computation of the timer specified
396     // in the previous description block
397     int PERF_PRECISION_TIMESTAMP = PERF_LARGE_RAW_BASE;
398     //
399     //  The following are used to determine the level of detail associated
400     //  with the counter.  The user will be setting the level of detail
401     //  that should be displayed at any given time.
402     //
403     //
404     int PERF_DETAIL_NOVICE   = 100; // The uninformed can understand it
405     int PERF_DETAIL_ADVANCED = 200; // For the advanced user
406     int PERF_DETAIL_EXPERT   = 300; // For the expert user
407     int PERF_DETAIL_WIZARD   = 400; // For the system designer
408 
409     int PERF_NO_UNIQUE_ID = -1;
410 
411     int PERF_QUERY_OBJECTS = 0x80000000;
412     int PERF_QUERY_GLOBAL  = 0x80000001;
413     int PERF_QUERY_COSTLY  = 0x80000002;
414 
415     /**
416      * Describes the performance data block that you queried
417      * @see <A HREF="https://msdn.microsoft.com/en-us/library/windows/desktop/aa373157(v=vs.85).aspx">PERF_DATA_BLOCK</A>
418      */
419     @FieldOrder({"Signature", "LittleEndian", "Version",
420                 "Revision", "TotalByteLength", "HeaderLength",
421                 "NumObjectTypes", "DefaultObject", "SystemTime",
422                 "PerfTime", "PerfFreq", "PerfTime100nSec",
423                 "SystemNameLength", "SystemNameOffset"})
424     public class PERF_DATA_BLOCK extends Structure {
425         public char[]        Signature = new char[4];
426         public int           LittleEndian;
427         public int           Version;
428         public int           Revision;
429         public int           TotalByteLength;
430         public int           HeaderLength;
431         public int           NumObjectTypes;
432         public int           DefaultObject;
433         public SYSTEMTIME    SystemTime = new SYSTEMTIME();
434         public LARGE_INTEGER PerfTime = new LARGE_INTEGER();
435         public LARGE_INTEGER PerfFreq = new LARGE_INTEGER();
436         public LARGE_INTEGER PerfTime100nSec = new LARGE_INTEGER();
437         public int           SystemNameLength;
438         public int           SystemNameOffset;
439 
PERF_DATA_BLOCK()440         public PERF_DATA_BLOCK() {
441             super();
442         }
443 
PERF_DATA_BLOCK(Pointer p)444         public PERF_DATA_BLOCK(Pointer p) {
445             super(p);
446             read();
447         }
448     };
449 
450     /**
451      * Describes an instance of a performance object
452      * @see <A HREF="https://msdn.microsoft.com/en-us/library/windows/desktop/aa373159(v=vs.85).aspx">PERF_INSTANCE_DEFINITION</A>
453      */
454     @FieldOrder({"ByteLength", "ParentObjectTitleIndex", "ParentObjectInstance",
455                 "UniqueID", "NameOffset", "NameLength"})
456     public class PERF_INSTANCE_DEFINITION extends Structure {
457         public int ByteLength;
458         public int ParentObjectTitleIndex;
459         public int ParentObjectInstance;
460         public int UniqueID;
461         public int NameOffset;
462         public int NameLength;
463 
PERF_INSTANCE_DEFINITION()464         public PERF_INSTANCE_DEFINITION() {
465             super();
466         }
467 
PERF_INSTANCE_DEFINITION(Pointer p)468         public PERF_INSTANCE_DEFINITION(Pointer p) {
469             super(p);
470             read();
471         }
472     }
473 
474     /**
475      * Describes object-specific performance information, for example, the
476      * number of instances of the object and the number of counters that the
477      * object defines.
478      *
479      * @see <A HREF=
480      *      "https://msdn.microsoft.com/en-us/library/windows/desktop/aa373160(v=vs.85).aspx">
481      *      PERF_OBJECT_TYPE</A>
482      */
483     @FieldOrder({ "TotalByteLength", "DefinitionLength", "HeaderLength", "ObjectNameTitleIndex", "ObjectNameTitle",
484             "ObjectHelpTitleIndex", "ObjectHelpTitle", "DetailLevel", "NumCounters", "DefaultCounter", "NumInstances",
485             "CodePage", "PerfTime", "PerfFreq" })
486     public class PERF_OBJECT_TYPE extends Structure {
487         public int TotalByteLength;
488         public int DefinitionLength;
489         public int HeaderLength;
490         public int ObjectNameTitleIndex;
491         public int ObjectNameTitle; // always 32 bit
492         public int ObjectHelpTitleIndex;
493         public int ObjectHelpTitle; // always 32 bit
494         public int DetailLevel;
495         public int NumCounters;
496         public int DefaultCounter;
497         public int NumInstances;
498         public int CodePage;
499         public LARGE_INTEGER PerfTime;
500         public LARGE_INTEGER PerfFreq;
501 
PERF_OBJECT_TYPE()502         public PERF_OBJECT_TYPE() {
503             super();
504         }
505 
PERF_OBJECT_TYPE(Pointer p)506         public PERF_OBJECT_TYPE(Pointer p) {
507             super(p);
508             read();
509         }
510     }
511 
512     /**
513      * Describes a performance counter.
514      *
515      * @see <A HREF=
516      *      "https://msdn.microsoft.com/en-us/library/windows/desktop/aa373150(v=vs.85).aspx">
517      *      PERF_COUNTER_DEFINITION</A>
518      */
519     @FieldOrder({ "ByteLength", "CounterNameTitleIndex", "CounterNameTitle", "CounterHelpTitleIndex",
520             "CounterHelpTitle", "DefaultScale", "DetailLevel", "CounterType", "CounterSize", "CounterOffset" })
521     public class PERF_COUNTER_DEFINITION extends Structure {
522         public int ByteLength;
523         public int CounterNameTitleIndex;
524         public int CounterNameTitle; // always 32 bit
525         public int CounterHelpTitleIndex;
526         public int CounterHelpTitle; // always 32 bit
527         public int DefaultScale;
528         public int DetailLevel;
529         public int CounterType;
530         public int CounterSize;
531         public int CounterOffset;
532 
PERF_COUNTER_DEFINITION()533         public PERF_COUNTER_DEFINITION() {
534             super();
535         }
536 
PERF_COUNTER_DEFINITION(Pointer p)537         public PERF_COUNTER_DEFINITION(Pointer p) {
538             super(p);
539             read();
540         }
541     }
542 
543     /**
544      * Describes the block of memory that contains the raw performance counter
545      * data for an object's counters.
546      *
547      * @see <A HREF=
548      *      "https://msdn.microsoft.com/en-us/library/windows/desktop/aa373147(v=vs.85).aspx">
549      *      PERF_COUNTER_BLOCK</A>
550      */
551     @FieldOrder({ "ByteLength" })
552     public class PERF_COUNTER_BLOCK extends Structure {
553         public int ByteLength;
554 
PERF_COUNTER_BLOCK()555         public PERF_COUNTER_BLOCK() {
556             super();
557         }
558 
PERF_COUNTER_BLOCK(Pointer p)559         public PERF_COUNTER_BLOCK(Pointer p) {
560             super(p);
561             read();
562         }
563     }
564 }
565