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

WER_RUNTIME_EXCEPTION_INFORMATION

構造体
サイズx64: 1104 バイト / x86: 1024 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0本構造体のバイトサイズ。
hProcessHANDLE8/4+8+4例外が発生したプロセスのハンドル。
hThreadHANDLE8/4+16+8例外が発生したスレッドのハンドル。
exceptionRecordEXCEPTION_RECORD152/80+24+12例外の詳細を保持するEXCEPTION_RECORD。
contextCONTEXT912+176+96例外発生時のスレッドコンテキスト(CONTEXT)。
pwszReportIdLPWSTR8/4+1088+1008生成されたレポートの識別子(ワイド文字列)。
bIsFatalBOOL4+1096+1012例外が致命的かを示す真偽値。
dwReservedDWORD4+1100+1016予約フィールド。0であること。

各言語での定義

#include <windows.h>

// EXCEPTION_RECORD  (x64 152 / x86 80 バイト)
typedef struct EXCEPTION_RECORD {
    NTSTATUS ExceptionCode;
    DWORD ExceptionFlags;
    EXCEPTION_RECORD* ExceptionRecord;
    void* ExceptionAddress;
    DWORD NumberParameters;
    UINT_PTR ExceptionInformation[15];
} EXCEPTION_RECORD;

// ARM64_NT_NEON128  (x64 16 / x86 16 バイト)
typedef struct ARM64_NT_NEON128 {
    _Anonymous_e__Struct Anonymous;
    DOUBLE D[2];
    FLOAT S[4];
    WORD H[8];
    BYTE B[16];
} ARM64_NT_NEON128;

// CONTEXT  (x64 912 / x86 912 バイト)
typedef struct CONTEXT {
    CONTEXT_FLAGS ContextFlags;
    DWORD Cpsr;
    _Anonymous_e__Union Anonymous;
    ULONGLONG Sp;
    ULONGLONG Pc;
    ARM64_NT_NEON128 V[32];
    DWORD Fpcr;
    DWORD Fpsr;
    DWORD Bcr[8];
    ULONGLONG Bvr[8];
    DWORD Wcr[2];
    ULONGLONG Wvr[2];
} CONTEXT;

// WER_RUNTIME_EXCEPTION_INFORMATION  (x64 1104 / x86 1024 バイト)
typedef struct WER_RUNTIME_EXCEPTION_INFORMATION {
    DWORD dwSize;
    HANDLE hProcess;
    HANDLE hThread;
    EXCEPTION_RECORD exceptionRecord;
    CONTEXT context;
    LPWSTR pwszReportId;
    BOOL bIsFatal;
    DWORD dwReserved;
} WER_RUNTIME_EXCEPTION_INFORMATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EXCEPTION_RECORD
{
    public int ExceptionCode;
    public uint ExceptionFlags;
    public IntPtr ExceptionRecord;
    public IntPtr ExceptionAddress;
    public uint NumberParameters;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public UIntPtr[] ExceptionInformation;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ARM64_NT_NEON128
{
    public _Anonymous_e__Struct Anonymous;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public double[] D;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public float[] S;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public ushort[] H;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] B;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONTEXT
{
    public uint ContextFlags;
    public uint Cpsr;
    public _Anonymous_e__Union Anonymous;
    public ulong Sp;
    public ulong Pc;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ARM64_NT_NEON128[] V;
    public uint Fpcr;
    public uint Fpsr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public uint[] Bcr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public ulong[] Bvr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] Wcr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public ulong[] Wvr;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WER_RUNTIME_EXCEPTION_INFORMATION
{
    public uint dwSize;
    public IntPtr hProcess;
    public IntPtr hThread;
    public EXCEPTION_RECORD exceptionRecord;
    public CONTEXT context;
    public IntPtr pwszReportId;
    [MarshalAs(UnmanagedType.Bool)] public bool bIsFatal;
    public uint dwReserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EXCEPTION_RECORD
    Public ExceptionCode As Integer
    Public ExceptionFlags As UInteger
    Public ExceptionRecord As IntPtr
    Public ExceptionAddress As IntPtr
    Public NumberParameters As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=15)> Public ExceptionInformation() As UIntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ARM64_NT_NEON128
    Public Anonymous As _Anonymous_e__Struct
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public D() As Double
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public S() As Single
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public H() As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public B() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CONTEXT
    Public ContextFlags As UInteger
    Public Cpsr As UInteger
    Public Anonymous As _Anonymous_e__Union
    Public Sp As ULong
    Public Pc As ULong
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public V() As ARM64_NT_NEON128
    Public Fpcr As UInteger
    Public Fpsr As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public Bcr() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public Bvr() As ULong
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Wcr() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Wvr() As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WER_RUNTIME_EXCEPTION_INFORMATION
    Public dwSize As UInteger
    Public hProcess As IntPtr
    Public hThread As IntPtr
    Public exceptionRecord As EXCEPTION_RECORD
    Public context As CONTEXT
    Public pwszReportId As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public bIsFatal As Boolean
    Public dwReserved As UInteger
End Structure
import ctypes
from ctypes import wintypes

class EXCEPTION_RECORD(ctypes.Structure):
    _fields_ = [
        ("ExceptionCode", ctypes.c_int),
        ("ExceptionFlags", wintypes.DWORD),
        ("ExceptionRecord", ctypes.c_void_p),
        ("ExceptionAddress", ctypes.c_void_p),
        ("NumberParameters", wintypes.DWORD),
        ("ExceptionInformation", ctypes.c_size_t * 15),
    ]

class ARM64_NT_NEON128(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Struct),
        ("D", ctypes.c_double * 2),
        ("S", ctypes.c_float * 4),
        ("H", ctypes.c_ushort * 8),
        ("B", ctypes.c_ubyte * 16),
    ]

class CONTEXT(ctypes.Structure):
    _fields_ = [
        ("ContextFlags", wintypes.DWORD),
        ("Cpsr", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Union),
        ("Sp", ctypes.c_ulonglong),
        ("Pc", ctypes.c_ulonglong),
        ("V", ARM64_NT_NEON128 * 32),
        ("Fpcr", wintypes.DWORD),
        ("Fpsr", wintypes.DWORD),
        ("Bcr", wintypes.DWORD * 8),
        ("Bvr", ctypes.c_ulonglong * 8),
        ("Wcr", wintypes.DWORD * 2),
        ("Wvr", ctypes.c_ulonglong * 2),
    ]

class WER_RUNTIME_EXCEPTION_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("hProcess", ctypes.c_void_p),
        ("hThread", ctypes.c_void_p),
        ("exceptionRecord", EXCEPTION_RECORD),
        ("context", CONTEXT),
        ("pwszReportId", ctypes.c_void_p),
        ("bIsFatal", wintypes.BOOL),
        ("dwReserved", wintypes.DWORD),
    ]
#[repr(C)]
pub struct EXCEPTION_RECORD {
    pub ExceptionCode: i32,
    pub ExceptionFlags: u32,
    pub ExceptionRecord: *mut core::ffi::c_void,
    pub ExceptionAddress: *mut core::ffi::c_void,
    pub NumberParameters: u32,
    pub ExceptionInformation: [usize; 15],
}

#[repr(C)]
pub struct ARM64_NT_NEON128 {
    pub Anonymous: _Anonymous_e__Struct,
    pub D: [f64; 2],
    pub S: [f32; 4],
    pub H: [u16; 8],
    pub B: [u8; 16],
}

#[repr(C)]
pub struct CONTEXT {
    pub ContextFlags: u32,
    pub Cpsr: u32,
    pub Anonymous: _Anonymous_e__Union,
    pub Sp: u64,
    pub Pc: u64,
    pub V: [ARM64_NT_NEON128; 32],
    pub Fpcr: u32,
    pub Fpsr: u32,
    pub Bcr: [u32; 8],
    pub Bvr: [u64; 8],
    pub Wcr: [u32; 2],
    pub Wvr: [u64; 2],
}

#[repr(C)]
pub struct WER_RUNTIME_EXCEPTION_INFORMATION {
    pub dwSize: u32,
    pub hProcess: *mut core::ffi::c_void,
    pub hThread: *mut core::ffi::c_void,
    pub exceptionRecord: EXCEPTION_RECORD,
    pub context: CONTEXT,
    pub pwszReportId: *mut core::ffi::c_void,
    pub bIsFatal: i32,
    pub dwReserved: u32,
}
import "golang.org/x/sys/windows"

type EXCEPTION_RECORD struct {
	ExceptionCode int32
	ExceptionFlags uint32
	ExceptionRecord uintptr
	ExceptionAddress uintptr
	NumberParameters uint32
	ExceptionInformation [15]uintptr
}

type ARM64_NT_NEON128 struct {
	Anonymous _Anonymous_e__Struct
	D [2]float64
	S [4]float32
	H [8]uint16
	B [16]byte
}

type CONTEXT struct {
	ContextFlags uint32
	Cpsr uint32
	Anonymous _Anonymous_e__Union
	Sp uint64
	Pc uint64
	V [32]ARM64_NT_NEON128
	Fpcr uint32
	Fpsr uint32
	Bcr [8]uint32
	Bvr [8]uint64
	Wcr [2]uint32
	Wvr [2]uint64
}

type WER_RUNTIME_EXCEPTION_INFORMATION struct {
	dwSize uint32
	hProcess uintptr
	hThread uintptr
	exceptionRecord EXCEPTION_RECORD
	context CONTEXT
	pwszReportId uintptr
	bIsFatal int32
	dwReserved uint32
}
type
  EXCEPTION_RECORD = record
    ExceptionCode: Integer;
    ExceptionFlags: DWORD;
    ExceptionRecord: Pointer;
    ExceptionAddress: Pointer;
    NumberParameters: DWORD;
    ExceptionInformation: array[0..14] of NativeUInt;
  end;

  ARM64_NT_NEON128 = record
    Anonymous: _Anonymous_e__Struct;
    D: array[0..1] of Double;
    S: array[0..3] of Single;
    H: array[0..7] of Word;
    B: array[0..15] of Byte;
  end;

  CONTEXT = record
    ContextFlags: DWORD;
    Cpsr: DWORD;
    Anonymous: _Anonymous_e__Union;
    Sp: UInt64;
    Pc: UInt64;
    V: array[0..31] of ARM64_NT_NEON128;
    Fpcr: DWORD;
    Fpsr: DWORD;
    Bcr: array[0..7] of DWORD;
    Bvr: array[0..7] of UInt64;
    Wcr: array[0..1] of DWORD;
    Wvr: array[0..1] of UInt64;
  end;

  WER_RUNTIME_EXCEPTION_INFORMATION = record
    dwSize: DWORD;
    hProcess: Pointer;
    hThread: Pointer;
    exceptionRecord: EXCEPTION_RECORD;
    context: CONTEXT;
    pwszReportId: Pointer;
    bIsFatal: BOOL;
    dwReserved: DWORD;
  end;
const EXCEPTION_RECORD = extern struct {
    ExceptionCode: i32,
    ExceptionFlags: u32,
    ExceptionRecord: ?*anyopaque,
    ExceptionAddress: ?*anyopaque,
    NumberParameters: u32,
    ExceptionInformation: [15]usize,
};

const ARM64_NT_NEON128 = extern struct {
    Anonymous: _Anonymous_e__Struct,
    D: [2]f64,
    S: [4]f32,
    H: [8]u16,
    B: [16]u8,
};

const CONTEXT = extern struct {
    ContextFlags: u32,
    Cpsr: u32,
    Anonymous: _Anonymous_e__Union,
    Sp: u64,
    Pc: u64,
    V: [32]ARM64_NT_NEON128,
    Fpcr: u32,
    Fpsr: u32,
    Bcr: [8]u32,
    Bvr: [8]u64,
    Wcr: [2]u32,
    Wvr: [2]u64,
};

const WER_RUNTIME_EXCEPTION_INFORMATION = extern struct {
    dwSize: u32,
    hProcess: ?*anyopaque,
    hThread: ?*anyopaque,
    exceptionRecord: EXCEPTION_RECORD,
    context: CONTEXT,
    pwszReportId: ?*anyopaque,
    bIsFatal: i32,
    dwReserved: u32,
};
type
  EXCEPTION_RECORD {.bycopy.} = object
    ExceptionCode: int32
    ExceptionFlags: uint32
    ExceptionRecord: pointer
    ExceptionAddress: pointer
    NumberParameters: uint32
    ExceptionInformation: array[15, uint]

  ARM64_NT_NEON128 {.bycopy.} = object
    Anonymous: _Anonymous_e__Struct
    D: array[2, float64]
    S: array[4, float32]
    H: array[8, uint16]
    B: array[16, uint8]

  CONTEXT {.bycopy.} = object
    ContextFlags: uint32
    Cpsr: uint32
    Anonymous: _Anonymous_e__Union
    Sp: uint64
    Pc: uint64
    V: array[32, ARM64_NT_NEON128]
    Fpcr: uint32
    Fpsr: uint32
    Bcr: array[8, uint32]
    Bvr: array[8, uint64]
    Wcr: array[2, uint32]
    Wvr: array[2, uint64]

  WER_RUNTIME_EXCEPTION_INFORMATION {.bycopy.} = object
    dwSize: uint32
    hProcess: pointer
    hThread: pointer
    exceptionRecord: EXCEPTION_RECORD
    context: CONTEXT
    pwszReportId: pointer
    bIsFatal: int32
    dwReserved: uint32
struct EXCEPTION_RECORD
{
    int ExceptionCode;
    uint ExceptionFlags;
    void* ExceptionRecord;
    void* ExceptionAddress;
    uint NumberParameters;
    size_t[15] ExceptionInformation;
}

struct ARM64_NT_NEON128
{
    _Anonymous_e__Struct Anonymous;
    double[2] D;
    float[4] S;
    ushort[8] H;
    ubyte[16] B;
}

struct CONTEXT
{
    uint ContextFlags;
    uint Cpsr;
    _Anonymous_e__Union Anonymous;
    ulong Sp;
    ulong Pc;
    ARM64_NT_NEON128[32] V;
    uint Fpcr;
    uint Fpsr;
    uint[8] Bcr;
    ulong[8] Bvr;
    uint[2] Wcr;
    ulong[2] Wvr;
}

struct WER_RUNTIME_EXCEPTION_INFORMATION
{
    uint dwSize;
    void* hProcess;
    void* hThread;
    EXCEPTION_RECORD exceptionRecord;
    CONTEXT context;
    void* pwszReportId;
    int bIsFatal;
    uint dwReserved;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WER_RUNTIME_EXCEPTION_INFORMATION サイズ: 1024 バイト(x86)
dim st, 256    ; 4byte整数×256(構造体サイズ 1024 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; hProcess : HANDLE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; hThread : HANDLE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; exceptionRecord : EXCEPTION_RECORD (+12, 80byte)  varptr(st)+12 を基点に操作(80byte:入れ子/配列)
; context : CONTEXT (+96, 912byte)  varptr(st)+96 を基点に操作(912byte:入れ子/配列)
; pwszReportId : LPWSTR (+1008, 4byte)  st.252 = 値  /  値 = st.252   (lpoke/lpeek も可)
; bIsFatal : BOOL (+1012, 4byte)  st.253 = 値  /  値 = st.253   (lpoke/lpeek も可)
; dwReserved : DWORD (+1016, 4byte)  st.254 = 値  /  値 = st.254   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WER_RUNTIME_EXCEPTION_INFORMATION サイズ: 1104 バイト(x64)
dim st, 276    ; 4byte整数×276(構造体サイズ 1104 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; hProcess : HANDLE (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; hThread : HANDLE (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; exceptionRecord : EXCEPTION_RECORD (+24, 152byte)  varptr(st)+24 を基点に操作(152byte:入れ子/配列)
; context : CONTEXT (+176, 912byte)  varptr(st)+176 を基点に操作(912byte:入れ子/配列)
; pwszReportId : LPWSTR (+1088, 8byte)  qpoke st,1088,値 / qpeek(st,1088)  ※IronHSPのみ。3.7/3.8は lpoke st,1088,下位 : lpoke st,1092,上位
; bIsFatal : BOOL (+1096, 4byte)  st.274 = 値  /  値 = st.274   (lpoke/lpeek も可)
; dwReserved : DWORD (+1100, 4byte)  st.275 = 値  /  値 = st.275   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global EXCEPTION_RECORD
    #field int ExceptionCode
    #field int ExceptionFlags
    #field intptr ExceptionRecord
    #field intptr ExceptionAddress
    #field int NumberParameters
    #field intptr ExceptionInformation 15
#endstruct

#defstruct global CONTEXT
    #field int ContextFlags
    #field int Cpsr
    #field byte Anonymous 248
    #field int64 Sp
    #field int64 Pc
    #field byte V 512
    #field int Fpcr
    #field int Fpsr
    #field int Bcr 8
    #field int64 Bvr 8
    #field int Wcr 2
    #field int64 Wvr 2
#endstruct

#defstruct global WER_RUNTIME_EXCEPTION_INFORMATION
    #field int dwSize
    #field intptr hProcess
    #field intptr hThread
    #field EXCEPTION_RECORD exceptionRecord
    #field CONTEXT context
    #field intptr pwszReportId
    #field bool bIsFatal
    #field int dwReserved
#endstruct

stdim st, WER_RUNTIME_EXCEPTION_INFORMATION        ; NSTRUCT 変数を確保
st->dwSize = 100
mes "dwSize=" + st->dwSize