Win32 API 日本語リファレンス
ホームSystem.WinRT › RoInspectCapturedStackBackTrace

RoInspectCapturedStackBackTrace

関数
捕捉済みエラーのスタックバックトレースを調査する。
DLLapi-ms-win-core-winrt-error-l1-1-1.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

// 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
);

パラメーター

名前方向
targetErrorInfoAddressUINT_PTRin
machineWORDin
readMemoryCallbackPINSPECT_MEMORY_CALLBACKin
contextvoid*inoptional
frameCountDWORD*out
targetBackTraceAddressUINT_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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
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';
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)。