Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › EXCEPTION_RECORD

EXCEPTION_RECORD

構造体
サイズx64: 152 バイト / x86: 80 バイト

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

フィールド

フィールドサイズx64x86説明
ExceptionCodeNTSTATUS4+0+0例外の種類を示すコード(NTSTATUS)。
ExceptionFlagsDWORD4+4+4例外フラグ。継続不能例外などを示す。
ExceptionRecordEXCEPTION_RECORD*8/4+8+8入れ子の例外を表す次のEXCEPTION_RECORDへのポインタ。NULL可。
ExceptionAddressvoid*8/4+16+12例外が発生した命令のアドレス。
NumberParametersDWORD4+24+16ExceptionInformationに含まれる有効パラメータ数。
ExceptionInformationUINT_PTR120/60+32+20例外固有の追加情報を格納する配列(最大15要素)。

各言語での定義

#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;
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;
}
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
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),
    ]
#[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],
}
import "golang.org/x/sys/windows"

type EXCEPTION_RECORD struct {
	ExceptionCode int32
	ExceptionFlags uint32
	ExceptionRecord uintptr
	ExceptionAddress uintptr
	NumberParameters uint32
	ExceptionInformation [15]uintptr
}
type
  EXCEPTION_RECORD = record
    ExceptionCode: Integer;
    ExceptionFlags: DWORD;
    ExceptionRecord: Pointer;
    ExceptionAddress: Pointer;
    NumberParameters: DWORD;
    ExceptionInformation: array[0..14] of NativeUInt;
  end;
const EXCEPTION_RECORD = extern struct {
    ExceptionCode: i32,
    ExceptionFlags: u32,
    ExceptionRecord: ?*anyopaque,
    ExceptionAddress: ?*anyopaque,
    NumberParameters: u32,
    ExceptionInformation: [15]usize,
};
type
  EXCEPTION_RECORD {.bycopy.} = object
    ExceptionCode: int32
    ExceptionFlags: uint32
    ExceptionRecord: pointer
    ExceptionAddress: pointer
    NumberParameters: uint32
    ExceptionInformation: array[15, uint]
struct EXCEPTION_RECORD
{
    int ExceptionCode;
    uint ExceptionFlags;
    void* ExceptionRecord;
    void* ExceptionAddress;
    uint NumberParameters;
    size_t[15] ExceptionInformation;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; EXCEPTION_RECORD サイズ: 80 バイト(x86)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; ExceptionCode : NTSTATUS (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ExceptionFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ExceptionRecord : EXCEPTION_RECORD* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; ExceptionAddress : void* (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; NumberParameters : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ExceptionInformation : UINT_PTR (+20, 60byte)  varptr(st)+20 を基点に操作(60byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EXCEPTION_RECORD サイズ: 152 バイト(x64)
dim st, 38    ; 4byte整数×38(構造体サイズ 152 / 4 切り上げ)
; ExceptionCode : NTSTATUS (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ExceptionFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ExceptionRecord : EXCEPTION_RECORD* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ExceptionAddress : void* (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; NumberParameters : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ExceptionInformation : UINT_PTR (+32, 120byte)  varptr(st)+32 を基点に操作(120byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global EXCEPTION_RECORD
    #field int ExceptionCode
    #field int ExceptionFlags
    #field intptr ExceptionRecord
    #field intptr ExceptionAddress
    #field int NumberParameters
    #field intptr ExceptionInformation 15
#endstruct

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