ホーム › System.Diagnostics.Etw › TdhGetEventMapInformation
TdhGetEventMapInformation
関数イベントのマップ情報(列挙やビットマップ)を取得する。
シグネチャ
// TDH.dll
#include <windows.h>
DWORD TdhGetEventMapInformation(
EVENT_RECORD* pEvent,
LPWSTR pMapName,
EVENT_MAP_INFO* pBuffer, // optional
DWORD* pBufferSize
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pEvent | EVENT_RECORD* | in | EventRecordCallback コールバックに渡されるイベントレコードです。詳細については、EVENT_RECORD 構造体を参照してください。 |
| pMapName | LPWSTR | in | マップ属性値の名前を含む、null 終端の Unicode 文字列です。この名前は、EVENT_PROPERTY_INFO 構造体の MapNameOffset メンバーに由来します。 |
| pBuffer | EVENT_MAP_INFO* | outoptional | イベントマップを受け取るためのユーザー割り当てバッファーです。マップは、値マップ、ビットマップ、またはパターンマップのいずれかになります。詳細については、EVENT_MAP_INFO 構造体を参照してください。 |
| pBufferSize | DWORD* | inout | pBuffer バッファーのサイズ (バイト単位) です。関数が成功した場合、このパラメーターには使用されたバッファーのサイズが格納されます。バッファーが小さすぎる場合、関数は ERROR_INSUFFICIENT_BUFFER を返し、このパラメーターに必要なバッファーサイズを設定します。入力時にバッファーサイズが 0 の場合、バッファーにはデータが返されず、このパラメーターに必要なバッファーサイズが格納されます。 |
戻り値の型: DWORD
公式ドキュメント
イベントに含まれるイベントマップに関する情報を取得します。
戻り値
成功した場合は ERROR_SUCCESS を返します。それ以外の場合、この関数は次のいずれかの戻り値コード (またはその他のコード) を返します。
| 戻り値コード | 説明 |
|---|---|
| pBuffer バッファーのサイズが小さすぎます。pBufferSize に設定された必要なバッファーサイズを使用して、新しいバッファーを割り当ててください。 | |
| イベントのスキーマが見つからなかったか、指定されたマップが見つかりませんでした。 | |
| マニフェスト内の resourceFileName 属性には、プロバイダーバイナリの場所が含まれています。マニフェストを登録すると、その場所がレジストリに書き込まれます。TDH は、登録された場所に基づいてバイナリを見つけることができませんでした。 | |
| 1 つ以上のパラメーターが有効ではありません。 | |
| WMI サービスが利用できません。 |
解説(Remarks)
この関数を使用して、WPP イベントのイベントマップ情報を取得することはできません。
マニフェストで定義されたマップの場合、文字列の末尾にスペースが含まれます。たとえば、マニフェストで値が "Monday" にマップされている場合、文字列は "Monday " として返されます。
例
この関数の呼び出し方法を示す例については、Using TdhGetProperty to Consume Event Data を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// TDH.dll
#include <windows.h>
DWORD TdhGetEventMapInformation(
EVENT_RECORD* pEvent,
LPWSTR pMapName,
EVENT_MAP_INFO* pBuffer, // optional
DWORD* pBufferSize
);[DllImport("TDH.dll", ExactSpelling = true)]
static extern uint TdhGetEventMapInformation(
IntPtr pEvent, // EVENT_RECORD*
[MarshalAs(UnmanagedType.LPWStr)] string pMapName, // LPWSTR
IntPtr pBuffer, // EVENT_MAP_INFO* optional, out
ref uint pBufferSize // DWORD* in/out
);<DllImport("TDH.dll", ExactSpelling:=True)>
Public Shared Function TdhGetEventMapInformation(
pEvent As IntPtr, ' EVENT_RECORD*
<MarshalAs(UnmanagedType.LPWStr)> pMapName As String, ' LPWSTR
pBuffer As IntPtr, ' EVENT_MAP_INFO* optional, out
ByRef pBufferSize As UInteger ' DWORD* in/out
) As UInteger
End Function' pEvent : EVENT_RECORD*
' pMapName : LPWSTR
' pBuffer : EVENT_MAP_INFO* optional, out
' pBufferSize : DWORD* in/out
Declare PtrSafe Function TdhGetEventMapInformation Lib "tdh" ( _
ByVal pEvent As LongPtr, _
ByVal pMapName As LongPtr, _
ByVal pBuffer As LongPtr, _
ByRef pBufferSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TdhGetEventMapInformation = ctypes.windll.tdh.TdhGetEventMapInformation
TdhGetEventMapInformation.restype = wintypes.DWORD
TdhGetEventMapInformation.argtypes = [
ctypes.c_void_p, # pEvent : EVENT_RECORD*
wintypes.LPCWSTR, # pMapName : LPWSTR
ctypes.c_void_p, # pBuffer : EVENT_MAP_INFO* optional, out
ctypes.POINTER(wintypes.DWORD), # pBufferSize : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TDH.dll')
TdhGetEventMapInformation = Fiddle::Function.new(
lib['TdhGetEventMapInformation'],
[
Fiddle::TYPE_VOIDP, # pEvent : EVENT_RECORD*
Fiddle::TYPE_VOIDP, # pMapName : LPWSTR
Fiddle::TYPE_VOIDP, # pBuffer : EVENT_MAP_INFO* optional, out
Fiddle::TYPE_VOIDP, # pBufferSize : DWORD* in/out
],
-Fiddle::TYPE_INT)#[link(name = "tdh")]
extern "system" {
fn TdhGetEventMapInformation(
pEvent: *mut EVENT_RECORD, // EVENT_RECORD*
pMapName: *mut u16, // LPWSTR
pBuffer: *mut EVENT_MAP_INFO, // EVENT_MAP_INFO* optional, out
pBufferSize: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TDH.dll")]
public static extern uint TdhGetEventMapInformation(IntPtr pEvent, [MarshalAs(UnmanagedType.LPWStr)] string pMapName, IntPtr pBuffer, ref uint pBufferSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TDH_TdhGetEventMapInformation' -Namespace Win32 -PassThru
# $api::TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize)#uselib "TDH.dll"
#func global TdhGetEventMapInformation "TdhGetEventMapInformation" sptr, sptr, sptr, sptr
; TdhGetEventMapInformation varptr(pEvent), pMapName, varptr(pBuffer), varptr(pBufferSize) ; 戻り値は stat
; pEvent : EVENT_RECORD* -> "sptr"
; pMapName : LPWSTR -> "sptr"
; pBuffer : EVENT_MAP_INFO* optional, out -> "sptr"
; pBufferSize : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TDH.dll" #cfunc global TdhGetEventMapInformation "TdhGetEventMapInformation" var, wstr, var, var ; res = TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize) ; pEvent : EVENT_RECORD* -> "var" ; pMapName : LPWSTR -> "wstr" ; pBuffer : EVENT_MAP_INFO* optional, out -> "var" ; pBufferSize : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TDH.dll" #cfunc global TdhGetEventMapInformation "TdhGetEventMapInformation" sptr, wstr, sptr, sptr ; res = TdhGetEventMapInformation(varptr(pEvent), pMapName, varptr(pBuffer), varptr(pBufferSize)) ; pEvent : EVENT_RECORD* -> "sptr" ; pMapName : LPWSTR -> "wstr" ; pBuffer : EVENT_MAP_INFO* optional, out -> "sptr" ; pBufferSize : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD TdhGetEventMapInformation(EVENT_RECORD* pEvent, LPWSTR pMapName, EVENT_MAP_INFO* pBuffer, DWORD* pBufferSize) #uselib "TDH.dll" #cfunc global TdhGetEventMapInformation "TdhGetEventMapInformation" var, wstr, var, var ; res = TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize) ; pEvent : EVENT_RECORD* -> "var" ; pMapName : LPWSTR -> "wstr" ; pBuffer : EVENT_MAP_INFO* optional, out -> "var" ; pBufferSize : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD TdhGetEventMapInformation(EVENT_RECORD* pEvent, LPWSTR pMapName, EVENT_MAP_INFO* pBuffer, DWORD* pBufferSize) #uselib "TDH.dll" #cfunc global TdhGetEventMapInformation "TdhGetEventMapInformation" intptr, wstr, intptr, intptr ; res = TdhGetEventMapInformation(varptr(pEvent), pMapName, varptr(pBuffer), varptr(pBufferSize)) ; pEvent : EVENT_RECORD* -> "intptr" ; pMapName : LPWSTR -> "wstr" ; pBuffer : EVENT_MAP_INFO* optional, out -> "intptr" ; pBufferSize : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tdh = windows.NewLazySystemDLL("TDH.dll")
procTdhGetEventMapInformation = tdh.NewProc("TdhGetEventMapInformation")
)
// pEvent (EVENT_RECORD*), pMapName (LPWSTR), pBuffer (EVENT_MAP_INFO* optional, out), pBufferSize (DWORD* in/out)
r1, _, err := procTdhGetEventMapInformation.Call(
uintptr(pEvent),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pMapName))),
uintptr(pBuffer),
uintptr(pBufferSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction TdhGetEventMapInformation(
pEvent: Pointer; // EVENT_RECORD*
pMapName: PWideChar; // LPWSTR
pBuffer: Pointer; // EVENT_MAP_INFO* optional, out
pBufferSize: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'TDH.dll' name 'TdhGetEventMapInformation';result := DllCall("TDH\TdhGetEventMapInformation"
, "Ptr", pEvent ; EVENT_RECORD*
, "WStr", pMapName ; LPWSTR
, "Ptr", pBuffer ; EVENT_MAP_INFO* optional, out
, "Ptr", pBufferSize ; DWORD* in/out
, "UInt") ; return: DWORD●TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize) = DLL("TDH.dll", "dword TdhGetEventMapInformation(void*, char*, void*, void*)")
# 呼び出し: TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize)
# pEvent : EVENT_RECORD* -> "void*"
# pMapName : LPWSTR -> "char*"
# pBuffer : EVENT_MAP_INFO* optional, out -> "void*"
# pBufferSize : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "tdh" fn TdhGetEventMapInformation(
pEvent: [*c]EVENT_RECORD, // EVENT_RECORD*
pMapName: [*c]const u16, // LPWSTR
pBuffer: [*c]EVENT_MAP_INFO, // EVENT_MAP_INFO* optional, out
pBufferSize: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;proc TdhGetEventMapInformation(
pEvent: ptr EVENT_RECORD, # EVENT_RECORD*
pMapName: WideCString, # LPWSTR
pBuffer: ptr EVENT_MAP_INFO, # EVENT_MAP_INFO* optional, out
pBufferSize: ptr uint32 # DWORD* in/out
): uint32 {.importc: "TdhGetEventMapInformation", stdcall, dynlib: "TDH.dll".}pragma(lib, "tdh");
extern(Windows)
uint TdhGetEventMapInformation(
EVENT_RECORD* pEvent, // EVENT_RECORD*
const(wchar)* pMapName, // LPWSTR
EVENT_MAP_INFO* pBuffer, // EVENT_MAP_INFO* optional, out
uint* pBufferSize // DWORD* in/out
);ccall((:TdhGetEventMapInformation, "TDH.dll"), stdcall, UInt32,
(Ptr{EVENT_RECORD}, Cwstring, Ptr{EVENT_MAP_INFO}, Ptr{UInt32}),
pEvent, pMapName, pBuffer, pBufferSize)
# pEvent : EVENT_RECORD* -> Ptr{EVENT_RECORD}
# pMapName : LPWSTR -> Cwstring
# pBuffer : EVENT_MAP_INFO* optional, out -> Ptr{EVENT_MAP_INFO}
# pBufferSize : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t TdhGetEventMapInformation(
void* pEvent,
const uint16_t* pMapName,
void* pBuffer,
uint32_t* pBufferSize);
]]
local tdh = ffi.load("tdh")
-- tdh.TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize)
-- pEvent : EVENT_RECORD*
-- pMapName : LPWSTR
-- pBuffer : EVENT_MAP_INFO* optional, out
-- pBufferSize : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('TDH.dll');
const TdhGetEventMapInformation = lib.func('__stdcall', 'TdhGetEventMapInformation', 'uint32_t', ['void *', 'str16', 'void *', 'uint32_t *']);
// TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize)
// pEvent : EVENT_RECORD* -> 'void *'
// pMapName : LPWSTR -> 'str16'
// pBuffer : EVENT_MAP_INFO* optional, out -> 'void *'
// pBufferSize : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TDH.dll", {
TdhGetEventMapInformation: { parameters: ["pointer", "buffer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize)
// pEvent : EVENT_RECORD* -> "pointer"
// pMapName : LPWSTR -> "buffer"
// pBuffer : EVENT_MAP_INFO* optional, out -> "pointer"
// pBufferSize : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t TdhGetEventMapInformation(
void* pEvent,
const uint16_t* pMapName,
void* pBuffer,
uint32_t* pBufferSize);
C, "TDH.dll");
// $ffi->TdhGetEventMapInformation(pEvent, pMapName, pBuffer, pBufferSize);
// pEvent : EVENT_RECORD*
// pMapName : LPWSTR
// pBuffer : EVENT_MAP_INFO* optional, out
// pBufferSize : DWORD* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Tdh extends StdCallLibrary {
Tdh INSTANCE = Native.load("tdh", Tdh.class);
int TdhGetEventMapInformation(
Pointer pEvent, // EVENT_RECORD*
WString pMapName, // LPWSTR
Pointer pBuffer, // EVENT_MAP_INFO* optional, out
IntByReference pBufferSize // DWORD* in/out
);
}@[Link("tdh")]
lib LibTDH
fun TdhGetEventMapInformation = TdhGetEventMapInformation(
pEvent : EVENT_RECORD*, # EVENT_RECORD*
pMapName : UInt16*, # LPWSTR
pBuffer : EVENT_MAP_INFO*, # EVENT_MAP_INFO* optional, out
pBufferSize : UInt32* # DWORD* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TdhGetEventMapInformationNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Uint32>);
typedef TdhGetEventMapInformationDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Uint32>);
final TdhGetEventMapInformation = DynamicLibrary.open('TDH.dll')
.lookupFunction<TdhGetEventMapInformationNative, TdhGetEventMapInformationDart>('TdhGetEventMapInformation');
// pEvent : EVENT_RECORD* -> Pointer<Void>
// pMapName : LPWSTR -> Pointer<Utf16>
// pBuffer : EVENT_MAP_INFO* optional, out -> Pointer<Void>
// pBufferSize : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function TdhGetEventMapInformation(
pEvent: Pointer; // EVENT_RECORD*
pMapName: PWideChar; // LPWSTR
pBuffer: Pointer; // EVENT_MAP_INFO* optional, out
pBufferSize: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'TDH.dll' name 'TdhGetEventMapInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TdhGetEventMapInformation"
c_TdhGetEventMapInformation :: Ptr () -> CWString -> Ptr () -> Ptr Word32 -> IO Word32
-- pEvent : EVENT_RECORD* -> Ptr ()
-- pMapName : LPWSTR -> CWString
-- pBuffer : EVENT_MAP_INFO* optional, out -> Ptr ()
-- pBufferSize : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let tdhgeteventmapinformation =
foreign "TdhGetEventMapInformation"
((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr uint32_t) @-> returning uint32_t)
(* pEvent : EVENT_RECORD* -> (ptr void) *)
(* pMapName : LPWSTR -> (ptr uint16_t) *)
(* pBuffer : EVENT_MAP_INFO* optional, out -> (ptr void) *)
(* pBufferSize : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library tdh (t "TDH.dll"))
(cffi:use-foreign-library tdh)
(cffi:defcfun ("TdhGetEventMapInformation" tdh-get-event-map-information :convention :stdcall) :uint32
(p-event :pointer) ; EVENT_RECORD*
(p-map-name (:string :encoding :utf-16le)) ; LPWSTR
(p-buffer :pointer) ; EVENT_MAP_INFO* optional, out
(p-buffer-size :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TdhGetEventMapInformation = Win32::API::More->new('TDH',
'DWORD TdhGetEventMapInformation(LPVOID pEvent, LPCWSTR pMapName, LPVOID pBuffer, LPVOID pBufferSize)');
# my $ret = $TdhGetEventMapInformation->Call($pEvent, $pMapName, $pBuffer, $pBufferSize);
# pEvent : EVENT_RECORD* -> LPVOID
# pMapName : LPWSTR -> LPCWSTR
# pBuffer : EVENT_MAP_INFO* optional, out -> LPVOID
# pBufferSize : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。