ホーム › NetworkManagement.NetManagement › TraceDumpExA
TraceDumpExA
関数バイト配列を16進ダンプ形式でトレース出力する(ANSI版)。
シグネチャ
// rtutils.dll (ANSI / -A)
#include <windows.h>
DWORD TraceDumpExA(
DWORD dwTraceID,
DWORD dwFlags,
BYTE* lpbBytes,
DWORD dwByteCount,
DWORD dwGroupSize,
BOOL bAddressPrefix,
LPCSTR lpszPrefix
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwTraceID | DWORD | in | 登録時に取得したトレースID。出力先トレースを指す。 |
| dwFlags | DWORD | in | 出力動作を制御するフラグを指定する。 |
| lpbBytes | BYTE* | inout | ダンプ出力する生バイトデータへのポインター。 |
| dwByteCount | DWORD | in | lpbBytesのバイト数を指定する。 |
| dwGroupSize | DWORD | in | ダンプ表示時のグループ化バイト数を指定する。 |
| bAddressPrefix | BOOL | in | 各行にアドレスプレフィックスを付けるか指定する真偽値。 |
| lpszPrefix | LPCSTR | in | 各行頭に付加するプレフィックス文字列(ANSI)。NULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// rtutils.dll (ANSI / -A)
#include <windows.h>
DWORD TraceDumpExA(
DWORD dwTraceID,
DWORD dwFlags,
BYTE* lpbBytes,
DWORD dwByteCount,
DWORD dwGroupSize,
BOOL bAddressPrefix,
LPCSTR lpszPrefix
);[DllImport("rtutils.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint TraceDumpExA(
uint dwTraceID, // DWORD
uint dwFlags, // DWORD
IntPtr lpbBytes, // BYTE* in/out
uint dwByteCount, // DWORD
uint dwGroupSize, // DWORD
bool bAddressPrefix, // BOOL
[MarshalAs(UnmanagedType.LPStr)] string lpszPrefix // LPCSTR
);<DllImport("rtutils.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function TraceDumpExA(
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.LPStr)> lpszPrefix As String ' LPCSTR
) As UInteger
End Function' dwTraceID : DWORD
' dwFlags : DWORD
' lpbBytes : BYTE* in/out
' dwByteCount : DWORD
' dwGroupSize : DWORD
' bAddressPrefix : BOOL
' lpszPrefix : LPCSTR
Declare PtrSafe Function TraceDumpExA 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 String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TraceDumpExA = ctypes.windll.rtutils.TraceDumpExA
TraceDumpExA.restype = wintypes.DWORD
TraceDumpExA.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.LPCSTR, # lpszPrefix : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('rtutils.dll')
TraceDumpExA = Fiddle::Function.new(
lib['TraceDumpExA'],
[
-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 : LPCSTR
],
-Fiddle::TYPE_INT)#[link(name = "rtutils")]
extern "system" {
fn TraceDumpExA(
dwTraceID: u32, // DWORD
dwFlags: u32, // DWORD
lpbBytes: *mut u8, // BYTE* in/out
dwByteCount: u32, // DWORD
dwGroupSize: u32, // DWORD
bAddressPrefix: i32, // BOOL
lpszPrefix: *const u8 // LPCSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("rtutils.dll", CharSet = CharSet.Ansi)]
public static extern uint TraceDumpExA(uint dwTraceID, uint dwFlags, IntPtr lpbBytes, uint dwByteCount, uint dwGroupSize, bool bAddressPrefix, [MarshalAs(UnmanagedType.LPStr)] string lpszPrefix);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtutils_TraceDumpExA' -Namespace Win32 -PassThru
# $api::TraceDumpExA(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)#uselib "rtutils.dll"
#func global TraceDumpExA "TraceDumpExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; TraceDumpExA dwTraceID, dwFlags, varptr(lpbBytes), dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix ; 戻り値は stat
; dwTraceID : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; lpbBytes : BYTE* in/out -> "sptr"
; dwByteCount : DWORD -> "sptr"
; dwGroupSize : DWORD -> "sptr"
; bAddressPrefix : BOOL -> "sptr"
; lpszPrefix : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "rtutils.dll" #cfunc global TraceDumpExA "TraceDumpExA" int, int, var, int, int, int, str ; res = TraceDumpExA(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 : LPCSTR -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "rtutils.dll" #cfunc global TraceDumpExA "TraceDumpExA" int, int, sptr, int, int, int, str ; res = TraceDumpExA(dwTraceID, dwFlags, varptr(lpbBytes), dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix) ; dwTraceID : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpbBytes : BYTE* in/out -> "sptr" ; dwByteCount : DWORD -> "int" ; dwGroupSize : DWORD -> "int" ; bAddressPrefix : BOOL -> "int" ; lpszPrefix : LPCSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD TraceDumpExA(DWORD dwTraceID, DWORD dwFlags, BYTE* lpbBytes, DWORD dwByteCount, DWORD dwGroupSize, BOOL bAddressPrefix, LPCSTR lpszPrefix) #uselib "rtutils.dll" #cfunc global TraceDumpExA "TraceDumpExA" int, int, var, int, int, int, str ; res = TraceDumpExA(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 : LPCSTR -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD TraceDumpExA(DWORD dwTraceID, DWORD dwFlags, BYTE* lpbBytes, DWORD dwByteCount, DWORD dwGroupSize, BOOL bAddressPrefix, LPCSTR lpszPrefix) #uselib "rtutils.dll" #cfunc global TraceDumpExA "TraceDumpExA" int, int, intptr, int, int, int, str ; res = TraceDumpExA(dwTraceID, dwFlags, varptr(lpbBytes), dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix) ; dwTraceID : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpbBytes : BYTE* in/out -> "intptr" ; dwByteCount : DWORD -> "int" ; dwGroupSize : DWORD -> "int" ; bAddressPrefix : BOOL -> "int" ; lpszPrefix : LPCSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rtutils = windows.NewLazySystemDLL("rtutils.dll")
procTraceDumpExA = rtutils.NewProc("TraceDumpExA")
)
// dwTraceID (DWORD), dwFlags (DWORD), lpbBytes (BYTE* in/out), dwByteCount (DWORD), dwGroupSize (DWORD), bAddressPrefix (BOOL), lpszPrefix (LPCSTR)
r1, _, err := procTraceDumpExA.Call(
uintptr(dwTraceID),
uintptr(dwFlags),
uintptr(lpbBytes),
uintptr(dwByteCount),
uintptr(dwGroupSize),
uintptr(bAddressPrefix),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszPrefix))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction TraceDumpExA(
dwTraceID: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpbBytes: Pointer; // BYTE* in/out
dwByteCount: DWORD; // DWORD
dwGroupSize: DWORD; // DWORD
bAddressPrefix: BOOL; // BOOL
lpszPrefix: PAnsiChar // LPCSTR
): DWORD; stdcall;
external 'rtutils.dll' name 'TraceDumpExA';result := DllCall("rtutils\TraceDumpExA"
, "UInt", dwTraceID ; DWORD
, "UInt", dwFlags ; DWORD
, "Ptr", lpbBytes ; BYTE* in/out
, "UInt", dwByteCount ; DWORD
, "UInt", dwGroupSize ; DWORD
, "Int", bAddressPrefix ; BOOL
, "AStr", lpszPrefix ; LPCSTR
, "UInt") ; return: DWORD●TraceDumpExA(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix) = DLL("rtutils.dll", "dword TraceDumpExA(dword, dword, void*, dword, dword, bool, char*)")
# 呼び出し: TraceDumpExA(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 : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rtutils" fn TraceDumpExA(
dwTraceID: u32, // DWORD
dwFlags: u32, // DWORD
lpbBytes: [*c]u8, // BYTE* in/out
dwByteCount: u32, // DWORD
dwGroupSize: u32, // DWORD
bAddressPrefix: i32, // BOOL
lpszPrefix: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) u32;proc TraceDumpExA(
dwTraceID: uint32, # DWORD
dwFlags: uint32, # DWORD
lpbBytes: ptr uint8, # BYTE* in/out
dwByteCount: uint32, # DWORD
dwGroupSize: uint32, # DWORD
bAddressPrefix: int32, # BOOL
lpszPrefix: cstring # LPCSTR
): uint32 {.importc: "TraceDumpExA", stdcall, dynlib: "rtutils.dll".}pragma(lib, "rtutils");
extern(Windows)
uint TraceDumpExA(
uint dwTraceID, // DWORD
uint dwFlags, // DWORD
ubyte* lpbBytes, // BYTE* in/out
uint dwByteCount, // DWORD
uint dwGroupSize, // DWORD
int bAddressPrefix, // BOOL
const(char)* lpszPrefix // LPCSTR
);ccall((:TraceDumpExA, "rtutils.dll"), stdcall, UInt32,
(UInt32, UInt32, Ptr{UInt8}, UInt32, UInt32, Int32, Cstring),
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 : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t TraceDumpExA(
uint32_t dwTraceID,
uint32_t dwFlags,
uint8_t* lpbBytes,
uint32_t dwByteCount,
uint32_t dwGroupSize,
int32_t bAddressPrefix,
const char* lpszPrefix);
]]
local rtutils = ffi.load("rtutils")
-- rtutils.TraceDumpExA(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix)
-- dwTraceID : DWORD
-- dwFlags : DWORD
-- lpbBytes : BYTE* in/out
-- dwByteCount : DWORD
-- dwGroupSize : DWORD
-- bAddressPrefix : BOOL
-- lpszPrefix : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('rtutils.dll');
const TraceDumpExA = lib.func('__stdcall', 'TraceDumpExA', 'uint32_t', ['uint32_t', 'uint32_t', 'uint8_t *', 'uint32_t', 'uint32_t', 'int32_t', 'str']);
// TraceDumpExA(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 : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("rtutils.dll", {
TraceDumpExA: { parameters: ["u32", "u32", "pointer", "u32", "u32", "i32", "buffer"], result: "u32" },
});
// lib.symbols.TraceDumpExA(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 : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t TraceDumpExA(
uint32_t dwTraceID,
uint32_t dwFlags,
uint8_t* lpbBytes,
uint32_t dwByteCount,
uint32_t dwGroupSize,
int32_t bAddressPrefix,
const char* lpszPrefix);
C, "rtutils.dll");
// $ffi->TraceDumpExA(dwTraceID, dwFlags, lpbBytes, dwByteCount, dwGroupSize, bAddressPrefix, lpszPrefix);
// dwTraceID : DWORD
// dwFlags : DWORD
// lpbBytes : BYTE* in/out
// dwByteCount : DWORD
// dwGroupSize : DWORD
// bAddressPrefix : BOOL
// lpszPrefix : LPCSTR
// 構造体/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.ASCII_OPTIONS);
int TraceDumpExA(
int dwTraceID, // DWORD
int dwFlags, // DWORD
byte[] lpbBytes, // BYTE* in/out
int dwByteCount, // DWORD
int dwGroupSize, // DWORD
boolean bAddressPrefix, // BOOL
String lpszPrefix // LPCSTR
);
}@[Link("rtutils")]
lib Librtutils
fun TraceDumpExA = TraceDumpExA(
dwTraceID : UInt32, # DWORD
dwFlags : UInt32, # DWORD
lpbBytes : UInt8*, # BYTE* in/out
dwByteCount : UInt32, # DWORD
dwGroupSize : UInt32, # DWORD
bAddressPrefix : Int32, # BOOL
lpszPrefix : UInt8* # LPCSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TraceDumpExANative = Uint32 Function(Uint32, Uint32, Pointer<Uint8>, Uint32, Uint32, Int32, Pointer<Utf8>);
typedef TraceDumpExADart = int Function(int, int, Pointer<Uint8>, int, int, int, Pointer<Utf8>);
final TraceDumpExA = DynamicLibrary.open('rtutils.dll')
.lookupFunction<TraceDumpExANative, TraceDumpExADart>('TraceDumpExA');
// dwTraceID : DWORD -> Uint32
// dwFlags : DWORD -> Uint32
// lpbBytes : BYTE* in/out -> Pointer<Uint8>
// dwByteCount : DWORD -> Uint32
// dwGroupSize : DWORD -> Uint32
// bAddressPrefix : BOOL -> Int32
// lpszPrefix : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function TraceDumpExA(
dwTraceID: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpbBytes: Pointer; // BYTE* in/out
dwByteCount: DWORD; // DWORD
dwGroupSize: DWORD; // DWORD
bAddressPrefix: BOOL; // BOOL
lpszPrefix: PAnsiChar // LPCSTR
): DWORD; stdcall;
external 'rtutils.dll' name 'TraceDumpExA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TraceDumpExA"
c_TraceDumpExA :: Word32 -> Word32 -> Ptr Word8 -> Word32 -> Word32 -> CInt -> CString -> IO Word32
-- dwTraceID : DWORD -> Word32
-- dwFlags : DWORD -> Word32
-- lpbBytes : BYTE* in/out -> Ptr Word8
-- dwByteCount : DWORD -> Word32
-- dwGroupSize : DWORD -> Word32
-- bAddressPrefix : BOOL -> CInt
-- lpszPrefix : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let tracedumpexa =
foreign "TraceDumpExA"
(uint32_t @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> uint32_t @-> int32_t @-> string @-> 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 : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rtutils (t "rtutils.dll"))
(cffi:use-foreign-library rtutils)
(cffi:defcfun ("TraceDumpExA" trace-dump-ex-a :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)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TraceDumpExA = Win32::API::More->new('rtutils',
'DWORD TraceDumpExA(DWORD dwTraceID, DWORD dwFlags, LPVOID lpbBytes, DWORD dwByteCount, DWORD dwGroupSize, BOOL bAddressPrefix, LPCSTR lpszPrefix)');
# my $ret = $TraceDumpExA->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 : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f TraceDumpExW (Unicode版) — バイト配列を16進ダンプ形式でトレース出力する(Unicode版)。