Win32 API 日本語リファレンス
ホームSystem.Performance › PERF_PROVIDER_CONTEXT

PERF_PROVIDER_CONTEXT

構造体
サイズx64: 40 バイト / x86: 24 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
ContextSizeDWORD4+0+0このコンテキスト構造体のバイトサイズである。
ReservedDWORD4+4+4予約フィールドである。0となる。
ControlCallbackPERFLIBREQUEST8/4+8+8制御要求を処理するPERFLIBREQUESTコールバックである。NULL可。
MemAllocRoutinePERF_MEM_ALLOC8/4+16+12メモリ割り当てに使うPERF_MEM_ALLOCコールバックである。NULL可。
MemFreeRoutinePERF_MEM_FREE8/4+24+16メモリ解放に使うPERF_MEM_FREEコールバックである。NULL可。
pMemContextvoid*8/4+32+20メモリコールバックへ渡すコンテキストポインタである。NULL可。

各言語での定義

#include <windows.h>

// PERF_PROVIDER_CONTEXT  (x64 40 / x86 24 バイト)
typedef struct PERF_PROVIDER_CONTEXT {
    DWORD ContextSize;
    DWORD Reserved;
    PERFLIBREQUEST ControlCallback;
    PERF_MEM_ALLOC MemAllocRoutine;
    PERF_MEM_FREE MemFreeRoutine;
    void* pMemContext;
} PERF_PROVIDER_CONTEXT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PERF_PROVIDER_CONTEXT
{
    public uint ContextSize;
    public uint Reserved;
    public IntPtr ControlCallback;
    public IntPtr MemAllocRoutine;
    public IntPtr MemFreeRoutine;
    public IntPtr pMemContext;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PERF_PROVIDER_CONTEXT
    Public ContextSize As UInteger
    Public Reserved As UInteger
    Public ControlCallback As IntPtr
    Public MemAllocRoutine As IntPtr
    Public MemFreeRoutine As IntPtr
    Public pMemContext As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class PERF_PROVIDER_CONTEXT(ctypes.Structure):
    _fields_ = [
        ("ContextSize", wintypes.DWORD),
        ("Reserved", wintypes.DWORD),
        ("ControlCallback", ctypes.c_void_p),
        ("MemAllocRoutine", ctypes.c_void_p),
        ("MemFreeRoutine", ctypes.c_void_p),
        ("pMemContext", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct PERF_PROVIDER_CONTEXT {
    pub ContextSize: u32,
    pub Reserved: u32,
    pub ControlCallback: *mut core::ffi::c_void,
    pub MemAllocRoutine: *mut core::ffi::c_void,
    pub MemFreeRoutine: *mut core::ffi::c_void,
    pub pMemContext: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type PERF_PROVIDER_CONTEXT struct {
	ContextSize uint32
	Reserved uint32
	ControlCallback uintptr
	MemAllocRoutine uintptr
	MemFreeRoutine uintptr
	pMemContext uintptr
}
type
  PERF_PROVIDER_CONTEXT = record
    ContextSize: DWORD;
    Reserved: DWORD;
    ControlCallback: Pointer;
    MemAllocRoutine: Pointer;
    MemFreeRoutine: Pointer;
    pMemContext: Pointer;
  end;
const PERF_PROVIDER_CONTEXT = extern struct {
    ContextSize: u32,
    Reserved: u32,
    ControlCallback: ?*anyopaque,
    MemAllocRoutine: ?*anyopaque,
    MemFreeRoutine: ?*anyopaque,
    pMemContext: ?*anyopaque,
};
type
  PERF_PROVIDER_CONTEXT {.bycopy.} = object
    ContextSize: uint32
    Reserved: uint32
    ControlCallback: pointer
    MemAllocRoutine: pointer
    MemFreeRoutine: pointer
    pMemContext: pointer
struct PERF_PROVIDER_CONTEXT
{
    uint ContextSize;
    uint Reserved;
    void* ControlCallback;
    void* MemAllocRoutine;
    void* MemFreeRoutine;
    void* pMemContext;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PERF_PROVIDER_CONTEXT サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; ContextSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Reserved : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ControlCallback : PERFLIBREQUEST (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; MemAllocRoutine : PERF_MEM_ALLOC (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; MemFreeRoutine : PERF_MEM_FREE (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; pMemContext : void* (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PERF_PROVIDER_CONTEXT サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; ContextSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Reserved : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ControlCallback : PERFLIBREQUEST (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; MemAllocRoutine : PERF_MEM_ALLOC (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; MemFreeRoutine : PERF_MEM_FREE (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; pMemContext : void* (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PERF_PROVIDER_CONTEXT
    #field int ContextSize
    #field int Reserved
    #field intptr ControlCallback
    #field intptr MemAllocRoutine
    #field intptr MemFreeRoutine
    #field intptr pMemContext
#endstruct

stdim st, PERF_PROVIDER_CONTEXT        ; NSTRUCT 変数を確保
st->ContextSize = 100
mes "ContextSize=" + st->ContextSize