ホーム › System.Diagnostics.Etw › TraceConfigureLastBranchRecord
TraceConfigureLastBranchRecord
関数トレースに対してLast Branch Record記録機能を構成する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
DWORD TraceConfigureLastBranchRecord(
ULONGLONG TraceId,
TRACE_LBR_CONFIGURATION LbrConfiguration,
const CLASSIC_EVENT_ID* Events,
DWORD EventCount
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| TraceId | ULONGLONG | in |
| LbrConfiguration | TRACE_LBR_CONFIGURATION | in |
| Events | CLASSIC_EVENT_ID* | in |
| EventCount | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
DWORD TraceConfigureLastBranchRecord(
ULONGLONG TraceId,
TRACE_LBR_CONFIGURATION LbrConfiguration,
const CLASSIC_EVENT_ID* Events,
DWORD EventCount
);[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint TraceConfigureLastBranchRecord(
ulong TraceId, // ULONGLONG
int LbrConfiguration, // TRACE_LBR_CONFIGURATION
IntPtr Events, // CLASSIC_EVENT_ID*
uint EventCount // DWORD
);<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function TraceConfigureLastBranchRecord(
TraceId As ULong, ' ULONGLONG
LbrConfiguration As Integer, ' TRACE_LBR_CONFIGURATION
Events As IntPtr, ' CLASSIC_EVENT_ID*
EventCount As UInteger ' DWORD
) As UInteger
End Function' TraceId : ULONGLONG
' LbrConfiguration : TRACE_LBR_CONFIGURATION
' Events : CLASSIC_EVENT_ID*
' EventCount : DWORD
Declare PtrSafe Function TraceConfigureLastBranchRecord Lib "advapi32" ( _
ByVal TraceId As LongLong, _
ByVal LbrConfiguration As Long, _
ByVal Events As LongPtr, _
ByVal EventCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TraceConfigureLastBranchRecord = ctypes.windll.advapi32.TraceConfigureLastBranchRecord
TraceConfigureLastBranchRecord.restype = wintypes.DWORD
TraceConfigureLastBranchRecord.argtypes = [
ctypes.c_ulonglong, # TraceId : ULONGLONG
ctypes.c_int, # LbrConfiguration : TRACE_LBR_CONFIGURATION
ctypes.c_void_p, # Events : CLASSIC_EVENT_ID*
wintypes.DWORD, # EventCount : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
TraceConfigureLastBranchRecord = Fiddle::Function.new(
lib['TraceConfigureLastBranchRecord'],
[
-Fiddle::TYPE_LONG_LONG, # TraceId : ULONGLONG
Fiddle::TYPE_INT, # LbrConfiguration : TRACE_LBR_CONFIGURATION
Fiddle::TYPE_VOIDP, # Events : CLASSIC_EVENT_ID*
-Fiddle::TYPE_INT, # EventCount : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn TraceConfigureLastBranchRecord(
TraceId: u64, // ULONGLONG
LbrConfiguration: i32, // TRACE_LBR_CONFIGURATION
Events: *const CLASSIC_EVENT_ID, // CLASSIC_EVENT_ID*
EventCount: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint TraceConfigureLastBranchRecord(ulong TraceId, int LbrConfiguration, IntPtr Events, uint EventCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_TraceConfigureLastBranchRecord' -Namespace Win32 -PassThru
# $api::TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, Events, EventCount)#uselib "ADVAPI32.dll"
#func global TraceConfigureLastBranchRecord "TraceConfigureLastBranchRecord" sptr, sptr, sptr, sptr
; TraceConfigureLastBranchRecord TraceId, LbrConfiguration, varptr(Events), EventCount ; 戻り値は stat
; TraceId : ULONGLONG -> "sptr"
; LbrConfiguration : TRACE_LBR_CONFIGURATION -> "sptr"
; Events : CLASSIC_EVENT_ID* -> "sptr"
; EventCount : DWORD -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global TraceConfigureLastBranchRecord "TraceConfigureLastBranchRecord" int64, int, var, int ; res = TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, Events, EventCount) ; TraceId : ULONGLONG -> "int64" ; LbrConfiguration : TRACE_LBR_CONFIGURATION -> "int" ; Events : CLASSIC_EVENT_ID* -> "var" ; EventCount : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "ADVAPI32.dll" #cfunc global TraceConfigureLastBranchRecord "TraceConfigureLastBranchRecord" int64, int, sptr, int ; res = TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, varptr(Events), EventCount) ; TraceId : ULONGLONG -> "int64" ; LbrConfiguration : TRACE_LBR_CONFIGURATION -> "int" ; Events : CLASSIC_EVENT_ID* -> "sptr" ; EventCount : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD TraceConfigureLastBranchRecord(ULONGLONG TraceId, TRACE_LBR_CONFIGURATION LbrConfiguration, CLASSIC_EVENT_ID* Events, DWORD EventCount) #uselib "ADVAPI32.dll" #cfunc global TraceConfigureLastBranchRecord "TraceConfigureLastBranchRecord" int64, int, var, int ; res = TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, Events, EventCount) ; TraceId : ULONGLONG -> "int64" ; LbrConfiguration : TRACE_LBR_CONFIGURATION -> "int" ; Events : CLASSIC_EVENT_ID* -> "var" ; EventCount : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD TraceConfigureLastBranchRecord(ULONGLONG TraceId, TRACE_LBR_CONFIGURATION LbrConfiguration, CLASSIC_EVENT_ID* Events, DWORD EventCount) #uselib "ADVAPI32.dll" #cfunc global TraceConfigureLastBranchRecord "TraceConfigureLastBranchRecord" int64, int, intptr, int ; res = TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, varptr(Events), EventCount) ; TraceId : ULONGLONG -> "int64" ; LbrConfiguration : TRACE_LBR_CONFIGURATION -> "int" ; Events : CLASSIC_EVENT_ID* -> "intptr" ; EventCount : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procTraceConfigureLastBranchRecord = advapi32.NewProc("TraceConfigureLastBranchRecord")
)
// TraceId (ULONGLONG), LbrConfiguration (TRACE_LBR_CONFIGURATION), Events (CLASSIC_EVENT_ID*), EventCount (DWORD)
r1, _, err := procTraceConfigureLastBranchRecord.Call(
uintptr(TraceId),
uintptr(LbrConfiguration),
uintptr(Events),
uintptr(EventCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction TraceConfigureLastBranchRecord(
TraceId: UInt64; // ULONGLONG
LbrConfiguration: Integer; // TRACE_LBR_CONFIGURATION
Events: Pointer; // CLASSIC_EVENT_ID*
EventCount: DWORD // DWORD
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'TraceConfigureLastBranchRecord';result := DllCall("ADVAPI32\TraceConfigureLastBranchRecord"
, "Int64", TraceId ; ULONGLONG
, "Int", LbrConfiguration ; TRACE_LBR_CONFIGURATION
, "Ptr", Events ; CLASSIC_EVENT_ID*
, "UInt", EventCount ; DWORD
, "UInt") ; return: DWORD●TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, Events, EventCount) = DLL("ADVAPI32.dll", "dword TraceConfigureLastBranchRecord(qword, int, void*, dword)")
# 呼び出し: TraceConfigureLastBranchRecord(TraceId, LbrConfiguration, Events, EventCount)
# TraceId : ULONGLONG -> "qword"
# LbrConfiguration : TRACE_LBR_CONFIGURATION -> "int"
# Events : CLASSIC_EVENT_ID* -> "void*"
# EventCount : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。