ホーム › System.WinRT › RoInspectCapturedStackBackTrace
RoInspectCapturedStackBackTrace
関数捕捉済みエラーのスタックバックトレースを調査する。
シグネチャ
// api-ms-win-core-winrt-error-l1-1-1.dll
#include <windows.h>
HRESULT RoInspectCapturedStackBackTrace(
UINT_PTR targetErrorInfoAddress,
WORD machine,
PINSPECT_MEMORY_CALLBACK readMemoryCallback,
void* context, // optional
DWORD* frameCount,
UINT_PTR* targetBackTraceAddress
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| targetErrorInfoAddress | UINT_PTR | in | 検査対象のエラー情報アドレス(UINT_PTR)。 |
| machine | WORD | in | 対象プロセスのマシンアーキテクチャを示すIMAGE_FILE_MACHINE値。 |
| readMemoryCallback | PINSPECT_MEMORY_CALLBACK | in | 対象プロセスのメモリを読み取るPINSPECT_MEMORY_CALLBACKコールバック。 |
| context | void* | inoptional | コールバックに渡すユーザー定義コンテキストポインタ。NULL可。 |
| frameCount | DWORD* | out | 出力としてスタックフレーム数を受け取るDWORDポインタ。 |
| targetBackTraceAddress | UINT_PTR* | out | 出力としてバックトレース配列のアドレスを受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-core-winrt-error-l1-1-1.dll
#include <windows.h>
HRESULT RoInspectCapturedStackBackTrace(
UINT_PTR targetErrorInfoAddress,
WORD machine,
PINSPECT_MEMORY_CALLBACK readMemoryCallback,
void* context, // optional
DWORD* frameCount,
UINT_PTR* targetBackTraceAddress
);[DllImport("api-ms-win-core-winrt-error-l1-1-1.dll", ExactSpelling = true)]
static extern int RoInspectCapturedStackBackTrace(
UIntPtr targetErrorInfoAddress, // UINT_PTR
ushort machine, // WORD
IntPtr readMemoryCallback, // PINSPECT_MEMORY_CALLBACK
IntPtr context, // void* optional
out uint frameCount, // DWORD* out
out UIntPtr targetBackTraceAddress // UINT_PTR* out
);<DllImport("api-ms-win-core-winrt-error-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function RoInspectCapturedStackBackTrace(
targetErrorInfoAddress As UIntPtr, ' UINT_PTR
machine As UShort, ' WORD
readMemoryCallback As IntPtr, ' PINSPECT_MEMORY_CALLBACK
context As IntPtr, ' void* optional
<Out> ByRef frameCount As UInteger, ' DWORD* out
<Out> ByRef targetBackTraceAddress As UIntPtr ' UINT_PTR* out
) As Integer
End Function' targetErrorInfoAddress : UINT_PTR
' machine : WORD
' readMemoryCallback : PINSPECT_MEMORY_CALLBACK
' context : void* optional
' frameCount : DWORD* out
' targetBackTraceAddress : UINT_PTR* out
Declare PtrSafe Function RoInspectCapturedStackBackTrace Lib "api-ms-win-core-winrt-error-l1-1-1" ( _
ByVal targetErrorInfoAddress As LongPtr, _
ByVal machine As Integer, _
ByVal readMemoryCallback As LongPtr, _
ByVal context As LongPtr, _
ByRef frameCount As Long, _
ByRef targetBackTraceAddress As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RoInspectCapturedStackBackTrace = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-error-l1-1-1.dll").RoInspectCapturedStackBackTrace
RoInspectCapturedStackBackTrace.restype = ctypes.c_int
RoInspectCapturedStackBackTrace.argtypes = [
ctypes.c_size_t, # targetErrorInfoAddress : UINT_PTR
ctypes.c_ushort, # machine : WORD
ctypes.c_void_p, # readMemoryCallback : PINSPECT_MEMORY_CALLBACK
ctypes.POINTER(None), # context : void* optional
ctypes.POINTER(wintypes.DWORD), # frameCount : DWORD* out
ctypes.POINTER(ctypes.c_size_t), # targetBackTraceAddress : UINT_PTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-winrt-error-l1-1-1.dll')
RoInspectCapturedStackBackTrace = Fiddle::Function.new(
lib['RoInspectCapturedStackBackTrace'],
[
Fiddle::TYPE_UINTPTR_T, # targetErrorInfoAddress : UINT_PTR
-Fiddle::TYPE_SHORT, # machine : WORD
Fiddle::TYPE_VOIDP, # readMemoryCallback : PINSPECT_MEMORY_CALLBACK
Fiddle::TYPE_VOIDP, # context : void* optional
Fiddle::TYPE_VOIDP, # frameCount : DWORD* out
Fiddle::TYPE_VOIDP, # targetBackTraceAddress : UINT_PTR* out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-winrt-error-l1-1-1")]
extern "system" {
fn RoInspectCapturedStackBackTrace(
targetErrorInfoAddress: usize, // UINT_PTR
machine: u16, // WORD
readMemoryCallback: *const core::ffi::c_void, // PINSPECT_MEMORY_CALLBACK
context: *mut (), // void* optional
frameCount: *mut u32, // DWORD* out
targetBackTraceAddress: *mut usize // UINT_PTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-winrt-error-l1-1-1.dll")]
public static extern int RoInspectCapturedStackBackTrace(UIntPtr targetErrorInfoAddress, ushort machine, IntPtr readMemoryCallback, IntPtr context, out uint frameCount, out UIntPtr targetBackTraceAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-error-l1-1-1_RoInspectCapturedStackBackTrace' -Namespace Win32 -PassThru
# $api::RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress)#uselib "api-ms-win-core-winrt-error-l1-1-1.dll"
#func global RoInspectCapturedStackBackTrace "RoInspectCapturedStackBackTrace" sptr, sptr, sptr, sptr, sptr, sptr
; RoInspectCapturedStackBackTrace targetErrorInfoAddress, machine, readMemoryCallback, context, varptr(frameCount), varptr(targetBackTraceAddress) ; 戻り値は stat
; targetErrorInfoAddress : UINT_PTR -> "sptr"
; machine : WORD -> "sptr"
; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "sptr"
; context : void* optional -> "sptr"
; frameCount : DWORD* out -> "sptr"
; targetBackTraceAddress : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-winrt-error-l1-1-1.dll" #cfunc global RoInspectCapturedStackBackTrace "RoInspectCapturedStackBackTrace" sptr, int, sptr, sptr, var, var ; res = RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress) ; targetErrorInfoAddress : UINT_PTR -> "sptr" ; machine : WORD -> "int" ; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "sptr" ; context : void* optional -> "sptr" ; frameCount : DWORD* out -> "var" ; targetBackTraceAddress : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-winrt-error-l1-1-1.dll" #cfunc global RoInspectCapturedStackBackTrace "RoInspectCapturedStackBackTrace" sptr, int, sptr, sptr, sptr, sptr ; res = RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, varptr(frameCount), varptr(targetBackTraceAddress)) ; targetErrorInfoAddress : UINT_PTR -> "sptr" ; machine : WORD -> "int" ; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "sptr" ; context : void* optional -> "sptr" ; frameCount : DWORD* out -> "sptr" ; targetBackTraceAddress : UINT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT RoInspectCapturedStackBackTrace(UINT_PTR targetErrorInfoAddress, WORD machine, PINSPECT_MEMORY_CALLBACK readMemoryCallback, void* context, DWORD* frameCount, UINT_PTR* targetBackTraceAddress) #uselib "api-ms-win-core-winrt-error-l1-1-1.dll" #cfunc global RoInspectCapturedStackBackTrace "RoInspectCapturedStackBackTrace" intptr, int, intptr, intptr, var, var ; res = RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress) ; targetErrorInfoAddress : UINT_PTR -> "intptr" ; machine : WORD -> "int" ; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "intptr" ; context : void* optional -> "intptr" ; frameCount : DWORD* out -> "var" ; targetBackTraceAddress : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT RoInspectCapturedStackBackTrace(UINT_PTR targetErrorInfoAddress, WORD machine, PINSPECT_MEMORY_CALLBACK readMemoryCallback, void* context, DWORD* frameCount, UINT_PTR* targetBackTraceAddress) #uselib "api-ms-win-core-winrt-error-l1-1-1.dll" #cfunc global RoInspectCapturedStackBackTrace "RoInspectCapturedStackBackTrace" intptr, int, intptr, intptr, intptr, intptr ; res = RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, varptr(frameCount), varptr(targetBackTraceAddress)) ; targetErrorInfoAddress : UINT_PTR -> "intptr" ; machine : WORD -> "int" ; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "intptr" ; context : void* optional -> "intptr" ; frameCount : DWORD* out -> "intptr" ; targetBackTraceAddress : UINT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_winrt_error_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-core-winrt-error-l1-1-1.dll")
procRoInspectCapturedStackBackTrace = api_ms_win_core_winrt_error_l1_1_1.NewProc("RoInspectCapturedStackBackTrace")
)
// targetErrorInfoAddress (UINT_PTR), machine (WORD), readMemoryCallback (PINSPECT_MEMORY_CALLBACK), context (void* optional), frameCount (DWORD* out), targetBackTraceAddress (UINT_PTR* out)
r1, _, err := procRoInspectCapturedStackBackTrace.Call(
uintptr(targetErrorInfoAddress),
uintptr(machine),
uintptr(readMemoryCallback),
uintptr(context),
uintptr(frameCount),
uintptr(targetBackTraceAddress),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RoInspectCapturedStackBackTrace(
targetErrorInfoAddress: NativeUInt; // UINT_PTR
machine: Word; // WORD
readMemoryCallback: Pointer; // PINSPECT_MEMORY_CALLBACK
context: Pointer; // void* optional
frameCount: Pointer; // DWORD* out
targetBackTraceAddress: Pointer // UINT_PTR* out
): Integer; stdcall;
external 'api-ms-win-core-winrt-error-l1-1-1.dll' name 'RoInspectCapturedStackBackTrace';result := DllCall("api-ms-win-core-winrt-error-l1-1-1\RoInspectCapturedStackBackTrace"
, "UPtr", targetErrorInfoAddress ; UINT_PTR
, "UShort", machine ; WORD
, "Ptr", readMemoryCallback ; PINSPECT_MEMORY_CALLBACK
, "Ptr", context ; void* optional
, "Ptr", frameCount ; DWORD* out
, "Ptr", targetBackTraceAddress ; UINT_PTR* out
, "Int") ; return: HRESULT●RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress) = DLL("api-ms-win-core-winrt-error-l1-1-1.dll", "int RoInspectCapturedStackBackTrace(int, int, void*, void*, void*, void*)")
# 呼び出し: RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress)
# targetErrorInfoAddress : UINT_PTR -> "int"
# machine : WORD -> "int"
# readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "void*"
# context : void* optional -> "void*"
# frameCount : DWORD* out -> "void*"
# targetBackTraceAddress : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-winrt-error-l1-1-1" fn RoInspectCapturedStackBackTrace(
targetErrorInfoAddress: usize, // UINT_PTR
machine: u16, // WORD
readMemoryCallback: ?*anyopaque, // PINSPECT_MEMORY_CALLBACK
context: ?*anyopaque, // void* optional
frameCount: [*c]u32, // DWORD* out
targetBackTraceAddress: [*c]usize // UINT_PTR* out
) callconv(std.os.windows.WINAPI) i32;proc RoInspectCapturedStackBackTrace(
targetErrorInfoAddress: uint, # UINT_PTR
machine: uint16, # WORD
readMemoryCallback: pointer, # PINSPECT_MEMORY_CALLBACK
context: pointer, # void* optional
frameCount: ptr uint32, # DWORD* out
targetBackTraceAddress: ptr uint # UINT_PTR* out
): int32 {.importc: "RoInspectCapturedStackBackTrace", stdcall, dynlib: "api-ms-win-core-winrt-error-l1-1-1.dll".}pragma(lib, "api-ms-win-core-winrt-error-l1-1-1");
extern(Windows)
int RoInspectCapturedStackBackTrace(
size_t targetErrorInfoAddress, // UINT_PTR
ushort machine, // WORD
void* readMemoryCallback, // PINSPECT_MEMORY_CALLBACK
void* context, // void* optional
uint* frameCount, // DWORD* out
size_t* targetBackTraceAddress // UINT_PTR* out
);ccall((:RoInspectCapturedStackBackTrace, "api-ms-win-core-winrt-error-l1-1-1.dll"), stdcall, Int32,
(Csize_t, UInt16, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{UInt32}, Ptr{Csize_t}),
targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress)
# targetErrorInfoAddress : UINT_PTR -> Csize_t
# machine : WORD -> UInt16
# readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> Ptr{Cvoid}
# context : void* optional -> Ptr{Cvoid}
# frameCount : DWORD* out -> Ptr{UInt32}
# targetBackTraceAddress : UINT_PTR* out -> Ptr{Csize_t}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RoInspectCapturedStackBackTrace(
uintptr_t targetErrorInfoAddress,
uint16_t machine,
void* readMemoryCallback,
void* context,
uint32_t* frameCount,
uintptr_t* targetBackTraceAddress);
]]
local api-ms-win-core-winrt-error-l1-1-1 = ffi.load("api-ms-win-core-winrt-error-l1-1-1")
-- api-ms-win-core-winrt-error-l1-1-1.RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress)
-- targetErrorInfoAddress : UINT_PTR
-- machine : WORD
-- readMemoryCallback : PINSPECT_MEMORY_CALLBACK
-- context : void* optional
-- frameCount : DWORD* out
-- targetBackTraceAddress : UINT_PTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-winrt-error-l1-1-1.dll');
const RoInspectCapturedStackBackTrace = lib.func('__stdcall', 'RoInspectCapturedStackBackTrace', 'int32_t', ['uintptr_t', 'uint16_t', 'void *', 'void *', 'uint32_t *', 'uintptr_t *']);
// RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress)
// targetErrorInfoAddress : UINT_PTR -> 'uintptr_t'
// machine : WORD -> 'uint16_t'
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> 'void *'
// context : void* optional -> 'void *'
// frameCount : DWORD* out -> 'uint32_t *'
// targetBackTraceAddress : UINT_PTR* out -> 'uintptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("api-ms-win-core-winrt-error-l1-1-1.dll", {
RoInspectCapturedStackBackTrace: { parameters: ["usize", "u16", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress)
// targetErrorInfoAddress : UINT_PTR -> "usize"
// machine : WORD -> "u16"
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "pointer"
// context : void* optional -> "pointer"
// frameCount : DWORD* out -> "pointer"
// targetBackTraceAddress : UINT_PTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RoInspectCapturedStackBackTrace(
size_t targetErrorInfoAddress,
uint16_t machine,
void* readMemoryCallback,
void* context,
uint32_t* frameCount,
size_t* targetBackTraceAddress);
C, "api-ms-win-core-winrt-error-l1-1-1.dll");
// $ffi->RoInspectCapturedStackBackTrace(targetErrorInfoAddress, machine, readMemoryCallback, context, frameCount, targetBackTraceAddress);
// targetErrorInfoAddress : UINT_PTR
// machine : WORD
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK
// context : void* optional
// frameCount : DWORD* out
// targetBackTraceAddress : UINT_PTR* 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 Api-ms-win-core-winrt-error-l1-1-1 extends StdCallLibrary {
Api-ms-win-core-winrt-error-l1-1-1 INSTANCE = Native.load("api-ms-win-core-winrt-error-l1-1-1", Api-ms-win-core-winrt-error-l1-1-1.class);
int RoInspectCapturedStackBackTrace(
long targetErrorInfoAddress, // UINT_PTR
short machine, // WORD
Callback readMemoryCallback, // PINSPECT_MEMORY_CALLBACK
Pointer context, // void* optional
IntByReference frameCount, // DWORD* out
LongByReference targetBackTraceAddress // UINT_PTR* out
);
}@[Link("api-ms-win-core-winrt-error-l1-1-1")]
lib Libapi-ms-win-core-winrt-error-l1-1-1
fun RoInspectCapturedStackBackTrace = RoInspectCapturedStackBackTrace(
targetErrorInfoAddress : LibC::SizeT, # UINT_PTR
machine : UInt16, # WORD
readMemoryCallback : Void*, # PINSPECT_MEMORY_CALLBACK
context : Void*, # void* optional
frameCount : UInt32*, # DWORD* out
targetBackTraceAddress : LibC::SizeT* # UINT_PTR* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RoInspectCapturedStackBackTraceNative = Int32 Function(UintPtr, Uint16, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<UintPtr>);
typedef RoInspectCapturedStackBackTraceDart = int Function(int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<UintPtr>);
final RoInspectCapturedStackBackTrace = DynamicLibrary.open('api-ms-win-core-winrt-error-l1-1-1.dll')
.lookupFunction<RoInspectCapturedStackBackTraceNative, RoInspectCapturedStackBackTraceDart>('RoInspectCapturedStackBackTrace');
// targetErrorInfoAddress : UINT_PTR -> UintPtr
// machine : WORD -> Uint16
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> Pointer<Void>
// context : void* optional -> Pointer<Void>
// frameCount : DWORD* out -> Pointer<Uint32>
// targetBackTraceAddress : UINT_PTR* out -> Pointer<UintPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RoInspectCapturedStackBackTrace(
targetErrorInfoAddress: NativeUInt; // UINT_PTR
machine: Word; // WORD
readMemoryCallback: Pointer; // PINSPECT_MEMORY_CALLBACK
context: Pointer; // void* optional
frameCount: Pointer; // DWORD* out
targetBackTraceAddress: Pointer // UINT_PTR* out
): Integer; stdcall;
external 'api-ms-win-core-winrt-error-l1-1-1.dll' name 'RoInspectCapturedStackBackTrace';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RoInspectCapturedStackBackTrace"
c_RoInspectCapturedStackBackTrace :: CUIntPtr -> Word16 -> Ptr () -> Ptr () -> Ptr Word32 -> Ptr CUIntPtr -> IO Int32
-- targetErrorInfoAddress : UINT_PTR -> CUIntPtr
-- machine : WORD -> Word16
-- readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> Ptr ()
-- context : void* optional -> Ptr ()
-- frameCount : DWORD* out -> Ptr Word32
-- targetBackTraceAddress : UINT_PTR* out -> Ptr CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let roinspectcapturedstackbacktrace =
foreign "RoInspectCapturedStackBackTrace"
(size_t @-> uint16_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr size_t) @-> returning int32_t)
(* targetErrorInfoAddress : UINT_PTR -> size_t *)
(* machine : WORD -> uint16_t *)
(* readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> (ptr void) *)
(* context : void* optional -> (ptr void) *)
(* frameCount : DWORD* out -> (ptr uint32_t) *)
(* targetBackTraceAddress : UINT_PTR* out -> (ptr size_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-winrt-error-l1-1-1 (t "api-ms-win-core-winrt-error-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-core-winrt-error-l1-1-1)
(cffi:defcfun ("RoInspectCapturedStackBackTrace" ro-inspect-captured-stack-back-trace :convention :stdcall) :int32
(target-error-info-address :uint64) ; UINT_PTR
(machine :uint16) ; WORD
(read-memory-callback :pointer) ; PINSPECT_MEMORY_CALLBACK
(context :pointer) ; void* optional
(frame-count :pointer) ; DWORD* out
(target-back-trace-address :pointer)) ; UINT_PTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RoInspectCapturedStackBackTrace = Win32::API::More->new('api-ms-win-core-winrt-error-l1-1-1',
'int RoInspectCapturedStackBackTrace(WPARAM targetErrorInfoAddress, WORD machine, LPVOID readMemoryCallback, LPVOID context, LPVOID frameCount, LPVOID targetBackTraceAddress)');
# my $ret = $RoInspectCapturedStackBackTrace->Call($targetErrorInfoAddress, $machine, $readMemoryCallback, $context, $frameCount, $targetBackTraceAddress);
# targetErrorInfoAddress : UINT_PTR -> WPARAM
# machine : WORD -> WORD
# readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> LPVOID
# context : void* optional -> LPVOID
# frameCount : DWORD* out -> LPVOID
# targetBackTraceAddress : UINT_PTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。