ホーム › System.WinRT › RoInspectThreadErrorInfo
RoInspectThreadErrorInfo
関数別プロセスのスレッドのエラー情報をコールバックで調査する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| targetTebAddress | UINT_PTR | in | 検査対象スレッドのTEBアドレス(UINT_PTR)。 |
| machine | WORD | in | 対象プロセスのマシンアーキテクチャを示すIMAGE_FILE_MACHINE値。 |
| readMemoryCallback | PINSPECT_MEMORY_CALLBACK | in | 対象プロセスのメモリを読み取るPINSPECT_MEMORY_CALLBACKコールバック。 |
| context | void* | inoptional | コールバックに渡すユーザー定義コンテキストポインタ。NULL可。 |
| targetErrorInfoAddress | UINT_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 方式にも切替可。#uselib "api-ms-win-core-winrt-error-l1-1-1.dll" #cfunc global RoInspectThreadErrorInfo "RoInspectThreadErrorInfo" sptr, int, sptr, sptr, sptr ; res = RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, varptr(targetErrorInfoAddress)) ; targetTebAddress : UINT_PTR -> "sptr" ; machine : WORD -> "int" ; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "sptr" ; context : void* optional -> "sptr" ; targetErrorInfoAddress : UINT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr ; res = RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, varptr(targetErrorInfoAddress)) ; targetTebAddress : UINT_PTR -> "intptr" ; machine : WORD -> "int" ; readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "intptr" ; context : void* optional -> "intptr" ; targetErrorInfoAddress : 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")
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 // HRESULTfunction 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)。const std = @import("std");
extern "api-ms-win-core-winrt-error-l1-1-1" fn RoInspectThreadErrorInfo(
targetTebAddress: usize, // UINT_PTR
machine: u16, // WORD
readMemoryCallback: ?*anyopaque, // PINSPECT_MEMORY_CALLBACK
context: ?*anyopaque, // void* optional
targetErrorInfoAddress: [*c]usize // UINT_PTR* out
) callconv(std.os.windows.WINAPI) i32;proc RoInspectThreadErrorInfo(
targetTebAddress: uint, # UINT_PTR
machine: uint16, # WORD
readMemoryCallback: pointer, # PINSPECT_MEMORY_CALLBACK
context: pointer, # void* optional
targetErrorInfoAddress: ptr uint # UINT_PTR* out
): int32 {.importc: "RoInspectThreadErrorInfo", 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 RoInspectThreadErrorInfo(
size_t targetTebAddress, // UINT_PTR
ushort machine, // WORD
void* readMemoryCallback, // PINSPECT_MEMORY_CALLBACK
void* context, // void* optional
size_t* targetErrorInfoAddress // UINT_PTR* out
);ccall((:RoInspectThreadErrorInfo, "api-ms-win-core-winrt-error-l1-1-1.dll"), stdcall, Int32,
(Csize_t, UInt16, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Csize_t}),
targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
# targetTebAddress : UINT_PTR -> Csize_t
# machine : WORD -> UInt16
# readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> Ptr{Cvoid}
# context : void* optional -> Ptr{Cvoid}
# targetErrorInfoAddress : UINT_PTR* out -> Ptr{Csize_t}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RoInspectThreadErrorInfo(
uintptr_t targetTebAddress,
uint16_t machine,
void* readMemoryCallback,
void* context,
uintptr_t* targetErrorInfoAddress);
]]
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.RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
-- targetTebAddress : UINT_PTR
-- machine : WORD
-- readMemoryCallback : PINSPECT_MEMORY_CALLBACK
-- context : void* optional
-- targetErrorInfoAddress : 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 RoInspectThreadErrorInfo = lib.func('__stdcall', 'RoInspectThreadErrorInfo', 'int32_t', ['uintptr_t', 'uint16_t', 'void *', 'void *', 'uintptr_t *']);
// RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
// targetTebAddress : UINT_PTR -> 'uintptr_t'
// machine : WORD -> 'uint16_t'
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> 'void *'
// context : void* optional -> 'void *'
// targetErrorInfoAddress : 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", {
RoInspectThreadErrorInfo: { parameters: ["usize", "u16", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress)
// targetTebAddress : UINT_PTR -> "usize"
// machine : WORD -> "u16"
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> "pointer"
// context : void* optional -> "pointer"
// targetErrorInfoAddress : UINT_PTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RoInspectThreadErrorInfo(
size_t targetTebAddress,
uint16_t machine,
void* readMemoryCallback,
void* context,
size_t* targetErrorInfoAddress);
C, "api-ms-win-core-winrt-error-l1-1-1.dll");
// $ffi->RoInspectThreadErrorInfo(targetTebAddress, machine, readMemoryCallback, context, targetErrorInfoAddress);
// targetTebAddress : UINT_PTR
// machine : WORD
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK
// context : void* optional
// targetErrorInfoAddress : 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 RoInspectThreadErrorInfo(
long targetTebAddress, // UINT_PTR
short machine, // WORD
Callback readMemoryCallback, // PINSPECT_MEMORY_CALLBACK
Pointer context, // void* optional
LongByReference targetErrorInfoAddress // UINT_PTR* out
);
}@[Link("api-ms-win-core-winrt-error-l1-1-1")]
lib Libapi-ms-win-core-winrt-error-l1-1-1
fun RoInspectThreadErrorInfo = RoInspectThreadErrorInfo(
targetTebAddress : LibC::SizeT, # UINT_PTR
machine : UInt16, # WORD
readMemoryCallback : Void*, # PINSPECT_MEMORY_CALLBACK
context : Void*, # void* optional
targetErrorInfoAddress : 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 RoInspectThreadErrorInfoNative = Int32 Function(UintPtr, Uint16, Pointer<Void>, Pointer<Void>, Pointer<UintPtr>);
typedef RoInspectThreadErrorInfoDart = int Function(int, int, Pointer<Void>, Pointer<Void>, Pointer<UintPtr>);
final RoInspectThreadErrorInfo = DynamicLibrary.open('api-ms-win-core-winrt-error-l1-1-1.dll')
.lookupFunction<RoInspectThreadErrorInfoNative, RoInspectThreadErrorInfoDart>('RoInspectThreadErrorInfo');
// targetTebAddress : UINT_PTR -> UintPtr
// machine : WORD -> Uint16
// readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> Pointer<Void>
// context : void* optional -> Pointer<Void>
// targetErrorInfoAddress : UINT_PTR* out -> Pointer<UintPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RoInspectThreadErrorInfo"
c_RoInspectThreadErrorInfo :: CUIntPtr -> Word16 -> Ptr () -> Ptr () -> Ptr CUIntPtr -> IO Int32
-- targetTebAddress : UINT_PTR -> CUIntPtr
-- machine : WORD -> Word16
-- readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> Ptr ()
-- context : void* optional -> Ptr ()
-- targetErrorInfoAddress : UINT_PTR* out -> Ptr CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let roinspectthreaderrorinfo =
foreign "RoInspectThreadErrorInfo"
(size_t @-> uint16_t @-> (ptr void) @-> (ptr void) @-> (ptr size_t) @-> returning int32_t)
(* targetTebAddress : UINT_PTR -> size_t *)
(* machine : WORD -> uint16_t *)
(* readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> (ptr void) *)
(* context : void* optional -> (ptr void) *)
(* targetErrorInfoAddress : 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 ("RoInspectThreadErrorInfo" ro-inspect-thread-error-info :convention :stdcall) :int32
(target-teb-address :uint64) ; UINT_PTR
(machine :uint16) ; WORD
(read-memory-callback :pointer) ; PINSPECT_MEMORY_CALLBACK
(context :pointer) ; void* optional
(target-error-info-address :pointer)) ; UINT_PTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RoInspectThreadErrorInfo = Win32::API::More->new('api-ms-win-core-winrt-error-l1-1-1',
'int RoInspectThreadErrorInfo(WPARAM targetTebAddress, WORD machine, LPVOID readMemoryCallback, LPVOID context, LPVOID targetErrorInfoAddress)');
# my $ret = $RoInspectThreadErrorInfo->Call($targetTebAddress, $machine, $readMemoryCallback, $context, $targetErrorInfoAddress);
# targetTebAddress : UINT_PTR -> WPARAM
# machine : WORD -> WORD
# readMemoryCallback : PINSPECT_MEMORY_CALLBACK -> LPVOID
# context : void* optional -> LPVOID
# targetErrorInfoAddress : UINT_PTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。