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

RoInspectThreadErrorInfo

関数
別プロセスのスレッドのエラー情報をコールバックで調査する。
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 RoInspectThreadErrorInfo(
    UINT_PTR targetTebAddress,
    WORD machine,
    PINSPECT_MEMORY_CALLBACK readMemoryCallback,
    void* context,   // optional
    UINT_PTR* targetErrorInfoAddress
);

パラメーター

名前方向
targetTebAddressUINT_PTRin
machineWORDin
readMemoryCallbackPINSPECT_MEMORY_CALLBACKin
contextvoid*inoptional
targetErrorInfoAddressUINT_PTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

// api-ms-win-core-winrt-error-l1-1-1.dll
#include <windows.h>

HRESULT RoInspectThreadErrorInfo(
    UINT_PTR targetTebAddress,
    WORD machine,
    PINSPECT_MEMORY_CALLBACK readMemoryCallback,
    void* context,   // optional
    UINT_PTR* targetErrorInfoAddress
);
[DllImport("api-ms-win-core-winrt-error-l1-1-1.dll", ExactSpelling = true)]
static extern int RoInspectThreadErrorInfo(
    UIntPtr targetTebAddress,   // UINT_PTR
    ushort machine,   // WORD
    IntPtr readMemoryCallback,   // PINSPECT_MEMORY_CALLBACK
    IntPtr context,   // void* optional
    out UIntPtr targetErrorInfoAddress   // UINT_PTR* out
);
<DllImport("api-ms-win-core-winrt-error-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function RoInspectThreadErrorInfo(
    targetTebAddress As UIntPtr,   ' UINT_PTR
    machine As UShort,   ' WORD
    readMemoryCallback As IntPtr,   ' PINSPECT_MEMORY_CALLBACK
    context As IntPtr,   ' void* optional
    <Out> ByRef targetErrorInfoAddress As UIntPtr   ' UINT_PTR* out
) As Integer
End Function
' targetTebAddress : UINT_PTR
' machine : WORD
' readMemoryCallback : PINSPECT_MEMORY_CALLBACK
' context : void* optional
' targetErrorInfoAddress : UINT_PTR* out
Declare PtrSafe Function RoInspectThreadErrorInfo Lib "api-ms-win-core-winrt-error-l1-1-1" ( _
    ByVal targetTebAddress As LongPtr, _
    ByVal machine As Integer, _
    ByVal readMemoryCallback As LongPtr, _
    ByVal context As LongPtr, _
    ByRef targetErrorInfoAddress As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RoInspectThreadErrorInfo = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-error-l1-1-1.dll").RoInspectThreadErrorInfo
RoInspectThreadErrorInfo.restype = ctypes.c_int
RoInspectThreadErrorInfo.argtypes = [
    ctypes.c_size_t,  # targetTebAddress : UINT_PTR
    ctypes.c_ushort,  # machine : WORD
    ctypes.c_void_p,  # readMemoryCallback : PINSPECT_MEMORY_CALLBACK
    ctypes.POINTER(None),  # context : void* optional
    ctypes.POINTER(ctypes.c_size_t),  # targetErrorInfoAddress : UINT_PTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-winrt-error-l1-1-1.dll')
RoInspectThreadErrorInfo = Fiddle::Function.new(
  lib['RoInspectThreadErrorInfo'],
  [
    Fiddle::TYPE_UINTPTR_T,  # targetTebAddress : UINT_PTR
    -Fiddle::TYPE_SHORT,  # machine : WORD
    Fiddle::TYPE_VOIDP,  # readMemoryCallback : PINSPECT_MEMORY_CALLBACK
    Fiddle::TYPE_VOIDP,  # context : void* optional
    Fiddle::TYPE_VOIDP,  # targetErrorInfoAddress : UINT_PTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-winrt-error-l1-1-1")]
extern "system" {
    fn RoInspectThreadErrorInfo(
        targetTebAddress: usize,  // UINT_PTR
        machine: u16,  // WORD
        readMemoryCallback: *const core::ffi::c_void,  // PINSPECT_MEMORY_CALLBACK
        context: *mut (),  // void* optional
        targetErrorInfoAddress: *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 RoInspectThreadErrorInfo(UIntPtr targetTebAddress, ushort machine, IntPtr readMemoryCallback, IntPtr context, out UIntPtr targetErrorInfoAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-error-l1-1-1_RoInspectThreadErrorInfo' -Namespace Win32 -PassThru
# $api::RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
#uselib "api-ms-win-core-winrt-error-l1-1-1.dll"
#func global RoInspectThreadErrorInfo "RoInspectThreadErrorInfo" sptr, sptr, sptr, sptr, sptr
; RoInspectThreadErrorInfo targetTebAddress, machine, readMemoryCallback, context, varptr(targetErrorInfoAddress)   ; 戻り値は stat
; targetTebAddress : UINT_PTR -> "sptr"
; machine : WORD -> "sptr"
; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "sptr"
; context : void* optional -> "sptr"
; targetErrorInfoAddress : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-core-winrt-error-l1-1-1.dll"
#cfunc global RoInspectThreadErrorInfo "RoInspectThreadErrorInfo" sptr, int, sptr, sptr, var
; res = RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
; targetTebAddress : UINT_PTR -> "sptr"
; machine : WORD -> "int"
; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "sptr"
; context : void* optional -> "sptr"
; targetErrorInfoAddress : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT RoInspectThreadErrorInfo(UINT_PTR targetTebAddress, WORD machine, PINSPECT_MEMORY_CALLBACK readMemoryCallback, void* context, UINT_PTR* targetErrorInfoAddress)
#uselib "api-ms-win-core-winrt-error-l1-1-1.dll"
#cfunc global RoInspectThreadErrorInfo "RoInspectThreadErrorInfo" intptr, int, intptr, intptr, var
; res = RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
; targetTebAddress : UINT_PTR -> "intptr"
; machine : WORD -> "int"
; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "intptr"
; context : void* optional -> "intptr"
; targetErrorInfoAddress : 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")
	procRoInspectThreadErrorInfo = api_ms_win_core_winrt_error_l1_1_1.NewProc("RoInspectThreadErrorInfo")
)

// targetTebAddress (UINT_PTR), machine (WORD), readMemoryCallback (PINSPECT_MEMORY_CALLBACK), context (void* optional), targetErrorInfoAddress (UINT_PTR* out)
r1, _, err := procRoInspectThreadErrorInfo.Call(
	uintptr(targetTebAddress),
	uintptr(machine),
	uintptr(readMemoryCallback),
	uintptr(context),
	uintptr(targetErrorInfoAddress),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function RoInspectThreadErrorInfo(
  targetTebAddress: NativeUInt;   // UINT_PTR
  machine: Word;   // WORD
  readMemoryCallback: Pointer;   // PINSPECT_MEMORY_CALLBACK
  context: Pointer;   // void* optional
  targetErrorInfoAddress: Pointer   // UINT_PTR* out
): Integer; stdcall;
  external 'api-ms-win-core-winrt-error-l1-1-1.dll' name 'RoInspectThreadErrorInfo';
result := DllCall("api-ms-win-core-winrt-error-l1-1-1\RoInspectThreadErrorInfo"
    , "UPtr", targetTebAddress   ; UINT_PTR
    , "UShort", machine   ; WORD
    , "Ptr", readMemoryCallback   ; PINSPECT_MEMORY_CALLBACK
    , "Ptr", context   ; void* optional
    , "Ptr", targetErrorInfoAddress   ; UINT_PTR* out
    , "Int")   ; return: HRESULT
●RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress) = DLL("api-ms-win-core-winrt-error-l1-1-1.dll", "int RoInspectThreadErrorInfo(int, int, void*, void*, void*)")
# 呼び出し: RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
# targetTebAddress : UINT_PTR -> "int"
# machine : WORD -> "int"
# readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "void*"
# context : void* optional -> "void*"
# targetErrorInfoAddress : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。