Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › TraceDumpExW

TraceDumpExW

関数
バイト配列を16進ダンプ形式でトレース出力する(Unicode版)。
DLLrtutils.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// rtutils.dll  (Unicode / -W)
#include <windows.h>

DWORD TraceDumpExW(
    DWORD dwTraceID,
    DWORD dwFlags,
    BYTE* lpbBytes,
    DWORD dwByteCount,
    DWORD dwGroupSize,
    BOOL bAddressPrefix,
    LPCWSTR lpszPrefix
);

パラメーター

名前方向説明
dwTraceIDDWORDin登録時に取得したトレースID。出力先トレースを指す。
dwFlagsDWORDin出力動作を制御するフラグを指定する。
lpbBytesBYTE*inoutダンプ出力する生バイトデータへのポインター。
dwByteCountDWORDinlpbBytesのバイト数を指定する。
dwGroupSizeDWORDinダンプ表示時のグループ化バイト数を指定する。
bAddressPrefixBOOLin各行にアドレスプレフィックスを付けるか指定する真偽値。
lpszPrefixLPCWSTRin各行頭に付加するプレフィックス文字列(Unicode)。NULL可。

戻り値の型: DWORD

各言語での呼び出し定義

// rtutils.dll  (Unicode / -W)
#include <windows.h>

DWORD TraceDumpExW(
    DWORD dwTraceID,
    DWORD dwFlags,
    BYTE* lpbBytes,
    DWORD dwByteCount,
    DWORD dwGroupSize,
    BOOL bAddressPrefix,
    LPCWSTR lpszPrefix
);
[DllImport("rtutils.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint TraceDumpExW(
    uint dwTraceID,   // DWORD
    uint dwFlags,   // DWORD
    IntPtr lpbBytes,   // BYTE* in/out
    uint dwByteCount,   // DWORD
    uint dwGroupSize,   // DWORD
    bool bAddressPrefix,   // BOOL
    [MarshalAs(UnmanagedType.LPWStr)] string lpszPrefix   // LPCWSTR
);
<DllImport("rtutils.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function TraceDumpExW(
    dwTraceID As UInteger,   ' DWORD
    dwFlags As UInteger,   ' DWORD
    lpbBytes As IntPtr,   ' BYTE* in/out
    dwByteCount As UInteger,   ' DWORD
    dwGroupSize As UInteger,   ' DWORD
    bAddressPrefix As Boolean,   ' BOOL
    <MarshalAs(UnmanagedType.LPWStr)> lpszPrefix As String   ' LPCWSTR
) As UInteger
End Function
' dwTraceID : DWORD
' dwFlags : DWORD
' lpbBytes : BYTE* in/out
' dwByteCount : DWORD
' dwGroupSize : DWORD
' bAddressPrefix : BOOL
' lpszPrefix : LPCWSTR
Declare PtrSafe Function TraceDumpExW Lib "rtutils" ( _
    ByVal dwTraceID As Long, _
    ByVal dwFlags As Long, _
    ByVal lpbBytes As LongPtr, _
    ByVal dwByteCount As Long, _
    ByVal dwGroupSize As Long, _
    ByVal bAddressPrefix As Long, _
    ByVal lpszPrefix As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

TraceDumpExW = ctypes.windll.rtutils.TraceDumpExW
TraceDumpExW.restype = wintypes.DWORD
TraceDumpExW.argtypes = [
    wintypes.DWORD,  # dwTraceID : DWORD
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # lpbBytes : BYTE* in/out
    wintypes.DWORD,  # dwByteCount : DWORD
    wintypes.DWORD,  # dwGroupSize : DWORD
    wintypes.BOOL,  # bAddressPrefix : BOOL
    wintypes.LPCWSTR,  # lpszPrefix : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rtutils.dll')
TraceDumpExW = Fiddle::Function.new(
  lib['TraceDumpExW'],
  [
    -Fiddle::TYPE_INT,  # dwTraceID : DWORD
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # lpbBytes : BYTE* in/out
    -Fiddle::TYPE_INT,  # dwByteCount : DWORD
    -Fiddle::TYPE_INT,  # dwGroupSize : DWORD
    Fiddle::TYPE_INT,  # bAddressPrefix : BOOL
    Fiddle::TYPE_VOIDP,  # lpszPrefix : LPCWSTR
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rtutils")]
extern "system" {
    fn TraceDumpExW(
        dwTraceID: u32,  // DWORD
        dwFlags: u32,  // DWORD
        lpbBytes: *mut u8,  // BYTE* in/out
        dwByteCount: u32,  // DWORD
        dwGroupSize: u32,  // DWORD
        bAddressPrefix: i32,  // BOOL
        lpszPrefix: *const u16  // LPCWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rtutils.dll", CharSet = CharSet.Unicode)]
public static extern uint TraceDumpExW(uint dwTraceID, uint dwFlags, IntPtr lpbBytes, uint dwByteCount, uint dwGroupSize, bool bAddressPrefix, [MarshalAs(UnmanagedType.LPWStr)] string lpszPrefix);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtutils_TraceDumpExW' -Namespace Win32 -PassThru
# $api::TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
#uselib "rtutils.dll"
#func global TraceDumpExW "TraceDumpExW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; TraceDumpExW dwTraceID, dwFlags, varptr(lpbBytes), dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix   ; 戻り値は stat
; dwTraceID : DWORD -> "wptr"
; dwFlags : DWORD -> "wptr"
; lpbBytes : BYTE* in/out -> "wptr"
; dwByteCount : DWORD -> "wptr"
; dwGroupSize : DWORD -> "wptr"
; bAddressPrefix : BOOL -> "wptr"
; lpszPrefix : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "rtutils.dll"
#cfunc global TraceDumpExW "TraceDumpExW" int, int, var, int, int, int, wstr
; res = TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
; dwTraceID : DWORD -> "int"
; dwFlags : DWORD -> "int"
; lpbBytes : BYTE* in/out -> "var"
; dwByteCount : DWORD -> "int"
; dwGroupSize : DWORD -> "int"
; bAddressPrefix : BOOL -> "int"
; lpszPrefix : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD TraceDumpExW(DWORD dwTraceID, DWORD dwFlags, BYTE* lpbBytes, DWORD dwByteCount, DWORD dwGroupSize, BOOL bAddressPrefix, LPCWSTR lpszPrefix)
#uselib "rtutils.dll"
#cfunc global TraceDumpExW "TraceDumpExW" int, int, var, int, int, int, wstr
; res = TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
; dwTraceID : DWORD -> "int"
; dwFlags : DWORD -> "int"
; lpbBytes : BYTE* in/out -> "var"
; dwByteCount : DWORD -> "int"
; dwGroupSize : DWORD -> "int"
; bAddressPrefix : BOOL -> "int"
; lpszPrefix : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rtutils = windows.NewLazySystemDLL("rtutils.dll")
	procTraceDumpExW = rtutils.NewProc("TraceDumpExW")
)

// dwTraceID (DWORD), dwFlags (DWORD), lpbBytes (BYTE* in/out), dwByteCount (DWORD), dwGroupSize (DWORD), bAddressPrefix (BOOL), lpszPrefix (LPCWSTR)
r1, _, err := procTraceDumpExW.Call(
	uintptr(dwTraceID),
	uintptr(dwFlags),
	uintptr(lpbBytes),
	uintptr(dwByteCount),
	uintptr(dwGroupSize),
	uintptr(bAddressPrefix),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszPrefix))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function TraceDumpExW(
  dwTraceID: DWORD;   // DWORD
  dwFlags: DWORD;   // DWORD
  lpbBytes: Pointer;   // BYTE* in/out
  dwByteCount: DWORD;   // DWORD
  dwGroupSize: DWORD;   // DWORD
  bAddressPrefix: BOOL;   // BOOL
  lpszPrefix: PWideChar   // LPCWSTR
): DWORD; stdcall;
  external 'rtutils.dll' name 'TraceDumpExW';
result := DllCall("rtutils\TraceDumpExW"
    , "UInt", dwTraceID   ; DWORD
    , "UInt", dwFlags   ; DWORD
    , "Ptr", lpbBytes   ; BYTE* in/out
    , "UInt", dwByteCount   ; DWORD
    , "UInt", dwGroupSize   ; DWORD
    , "Int", bAddressPrefix   ; BOOL
    , "WStr", lpszPrefix   ; LPCWSTR
    , "UInt")   ; return: DWORD
●TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix) = DLL("rtutils.dll", "dword TraceDumpExW(dword, dword, void*, dword, dword, bool, char*)")
# 呼び出し: TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
# dwTraceID : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# lpbBytes : BYTE* in/out -> "void*"
# dwByteCount : DWORD -> "dword"
# dwGroupSize : DWORD -> "dword"
# bAddressPrefix : BOOL -> "bool"
# lpszPrefix : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "rtutils" fn TraceDumpExW(
    dwTraceID: u32, // DWORD
    dwFlags: u32, // DWORD
    lpbBytes: [*c]u8, // BYTE* in/out
    dwByteCount: u32, // DWORD
    dwGroupSize: u32, // DWORD
    bAddressPrefix: i32, // BOOL
    lpszPrefix: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc TraceDumpExW(
    dwTraceID: uint32,  # DWORD
    dwFlags: uint32,  # DWORD
    lpbBytes: ptr uint8,  # BYTE* in/out
    dwByteCount: uint32,  # DWORD
    dwGroupSize: uint32,  # DWORD
    bAddressPrefix: int32,  # BOOL
    lpszPrefix: WideCString  # LPCWSTR
): uint32 {.importc: "TraceDumpExW", stdcall, dynlib: "rtutils.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "rtutils");
extern(Windows)
uint TraceDumpExW(
    uint dwTraceID,   // DWORD
    uint dwFlags,   // DWORD
    ubyte* lpbBytes,   // BYTE* in/out
    uint dwByteCount,   // DWORD
    uint dwGroupSize,   // DWORD
    int bAddressPrefix,   // BOOL
    const(wchar)* lpszPrefix   // LPCWSTR
);
ccall((:TraceDumpExW, "rtutils.dll"), stdcall, UInt32,
      (UInt32, UInt32, Ptr{UInt8}, UInt32, UInt32, Int32, Cwstring),
      dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
# dwTraceID : DWORD -> UInt32
# dwFlags : DWORD -> UInt32
# lpbBytes : BYTE* in/out -> Ptr{UInt8}
# dwByteCount : DWORD -> UInt32
# dwGroupSize : DWORD -> UInt32
# bAddressPrefix : BOOL -> Int32
# lpszPrefix : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t TraceDumpExW(
    uint32_t dwTraceID,
    uint32_t dwFlags,
    uint8_t* lpbBytes,
    uint32_t dwByteCount,
    uint32_t dwGroupSize,
    int32_t bAddressPrefix,
    const uint16_t* lpszPrefix);
]]
local rtutils = ffi.load("rtutils")
-- rtutils.TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
-- dwTraceID : DWORD
-- dwFlags : DWORD
-- lpbBytes : BYTE* in/out
-- dwByteCount : DWORD
-- dwGroupSize : DWORD
-- bAddressPrefix : BOOL
-- lpszPrefix : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('rtutils.dll');
const TraceDumpExW = lib.func('__stdcall', 'TraceDumpExW', 'uint32_t', ['uint32_t', 'uint32_t', 'uint8_t *', 'uint32_t', 'uint32_t', 'int32_t', 'str16']);
// TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
// dwTraceID : DWORD -> 'uint32_t'
// dwFlags : DWORD -> 'uint32_t'
// lpbBytes : BYTE* in/out -> 'uint8_t *'
// dwByteCount : DWORD -> 'uint32_t'
// dwGroupSize : DWORD -> 'uint32_t'
// bAddressPrefix : BOOL -> 'int32_t'
// lpszPrefix : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("rtutils.dll", {
  TraceDumpExW: { parameters: ["u32", "u32", "pointer", "u32", "u32", "i32", "buffer"], result: "u32" },
});
// lib.symbols.TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
// dwTraceID : DWORD -> "u32"
// dwFlags : DWORD -> "u32"
// lpbBytes : BYTE* in/out -> "pointer"
// dwByteCount : DWORD -> "u32"
// dwGroupSize : DWORD -> "u32"
// bAddressPrefix : BOOL -> "i32"
// lpszPrefix : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t TraceDumpExW(
    uint32_t dwTraceID,
    uint32_t dwFlags,
    uint8_t* lpbBytes,
    uint32_t dwByteCount,
    uint32_t dwGroupSize,
    int32_t bAddressPrefix,
    const uint16_t* lpszPrefix);
C, "rtutils.dll");
// $ffi->TraceDumpExW(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix);
// dwTraceID : DWORD
// dwFlags : DWORD
// lpbBytes : BYTE* in/out
// dwByteCount : DWORD
// dwGroupSize : DWORD
// bAddressPrefix : BOOL
// lpszPrefix : LPCWSTR
// 構造体/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 Rtutils extends StdCallLibrary {
    Rtutils INSTANCE = Native.load("rtutils", Rtutils.class, W32APIOptions.UNICODE_OPTIONS);
    int TraceDumpExW(
        int dwTraceID,   // DWORD
        int dwFlags,   // DWORD
        byte[] lpbBytes,   // BYTE* in/out
        int dwByteCount,   // DWORD
        int dwGroupSize,   // DWORD
        boolean bAddressPrefix,   // BOOL
        WString lpszPrefix   // LPCWSTR
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("rtutils")]
lib Librtutils
  fun TraceDumpExW = TraceDumpExW(
    dwTraceID : UInt32,   # DWORD
    dwFlags : UInt32,   # DWORD
    lpbBytes : UInt8*,   # BYTE* in/out
    dwByteCount : UInt32,   # DWORD
    dwGroupSize : UInt32,   # DWORD
    bAddressPrefix : Int32,   # BOOL
    lpszPrefix : UInt16*   # LPCWSTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef TraceDumpExWNative = Uint32 Function(Uint32, Uint32, Pointer<Uint8>, Uint32, Uint32, Int32, Pointer<Utf16>);
typedef TraceDumpExWDart = int Function(int, int, Pointer<Uint8>, int, int, int, Pointer<Utf16>);
final TraceDumpExW = DynamicLibrary.open('rtutils.dll')
    .lookupFunction<TraceDumpExWNative, TraceDumpExWDart>('TraceDumpExW');
// dwTraceID : DWORD -> Uint32
// dwFlags : DWORD -> Uint32
// lpbBytes : BYTE* in/out -> Pointer<Uint8>
// dwByteCount : DWORD -> Uint32
// dwGroupSize : DWORD -> Uint32
// bAddressPrefix : BOOL -> Int32
// lpszPrefix : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function TraceDumpExW(
  dwTraceID: DWORD;   // DWORD
  dwFlags: DWORD;   // DWORD
  lpbBytes: Pointer;   // BYTE* in/out
  dwByteCount: DWORD;   // DWORD
  dwGroupSize: DWORD;   // DWORD
  bAddressPrefix: BOOL;   // BOOL
  lpszPrefix: PWideChar   // LPCWSTR
): DWORD; stdcall;
  external 'rtutils.dll' name 'TraceDumpExW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "TraceDumpExW"
  c_TraceDumpExW :: Word32 -> Word32 -> Ptr Word8 -> Word32 -> Word32 -> CInt -> CWString -> IO Word32
-- dwTraceID : DWORD -> Word32
-- dwFlags : DWORD -> Word32
-- lpbBytes : BYTE* in/out -> Ptr Word8
-- dwByteCount : DWORD -> Word32
-- dwGroupSize : DWORD -> Word32
-- bAddressPrefix : BOOL -> CInt
-- lpszPrefix : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let tracedumpexw =
  foreign "TraceDumpExW"
    (uint32_t @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> uint32_t @-> int32_t @-> (ptr uint16_t) @-> returning uint32_t)
(* dwTraceID : DWORD -> uint32_t *)
(* dwFlags : DWORD -> uint32_t *)
(* lpbBytes : BYTE* in/out -> (ptr uint8_t) *)
(* dwByteCount : DWORD -> uint32_t *)
(* dwGroupSize : DWORD -> uint32_t *)
(* bAddressPrefix : BOOL -> int32_t *)
(* lpszPrefix : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rtutils (t "rtutils.dll"))
(cffi:use-foreign-library rtutils)

(cffi:defcfun ("TraceDumpExW" trace-dump-ex-w :convention :stdcall) :uint32
  (dw-trace-id :uint32)   ; DWORD
  (dw-flags :uint32)   ; DWORD
  (lpb-bytes :pointer)   ; BYTE* in/out
  (dw-byte-count :uint32)   ; DWORD
  (dw-group-size :uint32)   ; DWORD
  (b-address-prefix :int32)   ; BOOL
  (lpsz-prefix (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $TraceDumpExW = Win32::API::More->new('rtutils',
    'DWORD TraceDumpExW(DWORD dwTraceID, DWORD dwFlags, LPVOID lpbBytes, DWORD dwByteCount, DWORD dwGroupSize, BOOL bAddressPrefix, LPCWSTR lpszPrefix)');
# my $ret = $TraceDumpExW->Call($dwTraceID, $dwFlags, $lpbBytes, $dwByteCount, $dwGroupSize, $bAddressPrefix, $lpszPrefix);
# dwTraceID : DWORD -> DWORD
# dwFlags : DWORD -> DWORD
# lpbBytes : BYTE* in/out -> LPVOID
# dwByteCount : DWORD -> DWORD
# dwGroupSize : DWORD -> DWORD
# bAddressPrefix : BOOL -> BOOL
# lpszPrefix : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い