PERF_COUNTER_DEFINITION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ByteLength | DWORD | 4 | +0 | +0 | この構造体のサイズ (バイト単位)。 | ||||||||||
| CounterNameTitleIndex | DWORD | 4 | +4 | +4 | タイトル データベース内におけるカウンター名のインデックス。このインデックスを使用してカウンター名を取得する方法の詳細については、Retrieving Counter Names and Help Text を参照してください。 この値を設定するには、プロバイダーはシンボル ファイルで定義したカウンターのオフセット値を First Counter レジストリ値に加算します。詳細については、Adding Counter Names and Descriptions to the Registry および Implementing the OpenPerformanceData function を参照してください。 カウンターが基本カウンターである場合 (CounterType に PERF_COUNTER_BASE フラグが含まれる場合)、この値は 0 にする必要があります。 | ||||||||||
| CounterNameTitle | LPWSTR | 8/4 | +8 | +8 | 予約済みです。 | ||||||||||
| CounterHelpTitleIndex | DWORD | 4 | +16 | +12 | タイトル データベース内におけるカウンターのヘルプ テキストのインデックス。このインデックスを使用してカウンターのヘルプ テキストを取得する方法の詳細については、Retrieving Counter Names and Help Text を参照してください。 この値を設定するには、プロバイダーはシンボル ファイルで定義したカウンターのオフセット値を First Help レジストリ値に加算します。詳細については、Adding Counter Names and Descriptions to the Registry および Implementing the OpenPerformanceData function を参照してください。 カウンターが基本カウンターである場合 (CounterType に PERF_COUNTER_BASE フラグが含まれる場合)、この値は 0 にする必要があります。 | ||||||||||
| CounterHelpTitle | LPWSTR | 8/4 | +24 | +16 | 予約済みです。 | ||||||||||
| DefaultScale | INT | 4 | +32 | +20 | カウンター値をグラフ表示する際に使用するスケール係数。有効な値の範囲は -7 から 7 です (これらの値は 0.0000001 ~ 10000000 に対応します)。この値が 0 の場合、スケール値は 1 です。この値が 1 の場合、スケール値は 10 です。この値が -1 の場合、スケール値は .10 となります。以降も同様です。 | ||||||||||
| DetailLevel | DWORD | 4 | +36 | +24 | カウンターの詳細レベル。コンシューマーはこの値を使用して、表示の複雑さを制御します。このメンバーには次のいずれかの値を指定できます。
| ||||||||||
| CounterType | DWORD | 4 | +40 | +28 | カウンターの種類。定義済みのカウンターの種類の一覧については、Windows Server 2003 Deployment Kit の「Counter Types」セクションを参照してください。コンシューマーはカウンターの種類を使用して、カウンター値の計算方法と表示方法を判断します。プロバイダーは、選択するカウンターの種類を定義済みの一覧の範囲内にとどめてください。 | ||||||||||
| CounterSize | DWORD | 4 | +44 | +32 | カウンターのサイズ (バイト単位)。 現在、カウンター値の提供に使用されるのは DWORD (4 バイト) と ULONGLONG (8 バイト) のみです。 | ||||||||||
| CounterOffset | DWORD | 4 | +48 | +36 | PERF_COUNTER_BLOCK 構造体の先頭から、このカウンターの最初のバイトまでのオフセット。PERF_OBJECT_TYPE ブロック内における PERF_COUNTER_BLOCK 構造体の位置は、オブジェクトがインスタンスを含むかどうかによって異なります。詳細については、Performance Data Format を参照してください。 複数のカウンターが同じ生データを使用し、PERF_COUNTER_BLOCK ブロック内の同じオフセットを指す場合があることに注意してください。 |
公式ドキュメント
パフォーマンス カウンターについて説明します。
解説(Remarks)
PERF_OBJECT_TYPE 構造体には、1 つ以上のカウンターが含まれます。この構造体は個々のカウンターを定義し、その値へのオフセットを示します。これらの構造体は、メモリ上で PERF_OBJECT_TYPE 構造体の後に続きます。詳細については、Performance Data Format を参照してください。
プロバイダーは、カウンターが照会されるたびに同じ順序でカウンターを提供する必要があります。カウンターが計算に基本カウンターを使用する場合 (カウンターの種類に PERF_COUNTER_FRACTION フラグが含まれる場合)、基本カウンターはカウンターの一覧においてこのカウンターの後に続かなければなりません。カウンターの種類に PERF_MULTI_COUNTER フラグが含まれる場合、2 番目のカウンター値は PERF_COUNTER_BLOCK ブロック内でこのカウンターの値の後に続かなければなりません。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// PERF_COUNTER_DEFINITION (x64 56 / x86 40 バイト)
typedef struct PERF_COUNTER_DEFINITION {
DWORD ByteLength;
DWORD CounterNameTitleIndex;
LPWSTR CounterNameTitle;
DWORD CounterHelpTitleIndex;
LPWSTR CounterHelpTitle;
INT DefaultScale;
DWORD DetailLevel;
DWORD CounterType;
DWORD CounterSize;
DWORD CounterOffset;
} PERF_COUNTER_DEFINITION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PERF_COUNTER_DEFINITION
{
public uint ByteLength;
public uint CounterNameTitleIndex;
public IntPtr CounterNameTitle;
public uint CounterHelpTitleIndex;
public IntPtr CounterHelpTitle;
public int DefaultScale;
public uint DetailLevel;
public uint CounterType;
public uint CounterSize;
public uint CounterOffset;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PERF_COUNTER_DEFINITION
Public ByteLength As UInteger
Public CounterNameTitleIndex As UInteger
Public CounterNameTitle As IntPtr
Public CounterHelpTitleIndex As UInteger
Public CounterHelpTitle As IntPtr
Public DefaultScale As Integer
Public DetailLevel As UInteger
Public CounterType As UInteger
Public CounterSize As UInteger
Public CounterOffset As UInteger
End Structureimport ctypes
from ctypes import wintypes
class PERF_COUNTER_DEFINITION(ctypes.Structure):
_fields_ = [
("ByteLength", wintypes.DWORD),
("CounterNameTitleIndex", wintypes.DWORD),
("CounterNameTitle", ctypes.c_void_p),
("CounterHelpTitleIndex", wintypes.DWORD),
("CounterHelpTitle", ctypes.c_void_p),
("DefaultScale", ctypes.c_int),
("DetailLevel", wintypes.DWORD),
("CounterType", wintypes.DWORD),
("CounterSize", wintypes.DWORD),
("CounterOffset", wintypes.DWORD),
]#[repr(C)]
pub struct PERF_COUNTER_DEFINITION {
pub ByteLength: u32,
pub CounterNameTitleIndex: u32,
pub CounterNameTitle: *mut core::ffi::c_void,
pub CounterHelpTitleIndex: u32,
pub CounterHelpTitle: *mut core::ffi::c_void,
pub DefaultScale: i32,
pub DetailLevel: u32,
pub CounterType: u32,
pub CounterSize: u32,
pub CounterOffset: u32,
}import "golang.org/x/sys/windows"
type PERF_COUNTER_DEFINITION struct {
ByteLength uint32
CounterNameTitleIndex uint32
CounterNameTitle uintptr
CounterHelpTitleIndex uint32
CounterHelpTitle uintptr
DefaultScale int32
DetailLevel uint32
CounterType uint32
CounterSize uint32
CounterOffset uint32
}type
PERF_COUNTER_DEFINITION = record
ByteLength: DWORD;
CounterNameTitleIndex: DWORD;
CounterNameTitle: Pointer;
CounterHelpTitleIndex: DWORD;
CounterHelpTitle: Pointer;
DefaultScale: Integer;
DetailLevel: DWORD;
CounterType: DWORD;
CounterSize: DWORD;
CounterOffset: DWORD;
end;const PERF_COUNTER_DEFINITION = extern struct {
ByteLength: u32,
CounterNameTitleIndex: u32,
CounterNameTitle: ?*anyopaque,
CounterHelpTitleIndex: u32,
CounterHelpTitle: ?*anyopaque,
DefaultScale: i32,
DetailLevel: u32,
CounterType: u32,
CounterSize: u32,
CounterOffset: u32,
};type
PERF_COUNTER_DEFINITION {.bycopy.} = object
ByteLength: uint32
CounterNameTitleIndex: uint32
CounterNameTitle: pointer
CounterHelpTitleIndex: uint32
CounterHelpTitle: pointer
DefaultScale: int32
DetailLevel: uint32
CounterType: uint32
CounterSize: uint32
CounterOffset: uint32struct PERF_COUNTER_DEFINITION
{
uint ByteLength;
uint CounterNameTitleIndex;
void* CounterNameTitle;
uint CounterHelpTitleIndex;
void* CounterHelpTitle;
int DefaultScale;
uint DetailLevel;
uint CounterType;
uint CounterSize;
uint CounterOffset;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PERF_COUNTER_DEFINITION サイズ: 40 バイト(x86)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; ByteLength : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; CounterNameTitleIndex : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; CounterNameTitle : LPWSTR (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; CounterHelpTitleIndex : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; CounterHelpTitle : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; DefaultScale : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; DetailLevel : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; CounterType : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; CounterSize : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; CounterOffset : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PERF_COUNTER_DEFINITION サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; ByteLength : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; CounterNameTitleIndex : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; CounterNameTitle : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; CounterHelpTitleIndex : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; CounterHelpTitle : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; DefaultScale : INT (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; DetailLevel : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; CounterType : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; CounterSize : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; CounterOffset : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PERF_COUNTER_DEFINITION
#field int ByteLength
#field int CounterNameTitleIndex
#field intptr CounterNameTitle
#field int CounterHelpTitleIndex
#field intptr CounterHelpTitle
#field int DefaultScale
#field int DetailLevel
#field int CounterType
#field int CounterSize
#field int CounterOffset
#endstruct
stdim st, PERF_COUNTER_DEFINITION ; NSTRUCT 変数を確保
st->ByteLength = 100
mes "ByteLength=" + st->ByteLength