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

EXCEPTION_RECORD32

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

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

フィールド

フィールドサイズx64x86説明
ExceptionCodeNTSTATUS4+0+0例外の種類を示すコード(NTSTATUS)。
ExceptionFlagsDWORD4+4+4例外フラグ。
ExceptionRecordDWORD4+8+8入れ子の例外レコードへの32ビットアドレス。
ExceptionAddressDWORD4+12+12例外発生命令の32ビットアドレス。
NumberParametersDWORD4+16+16有効なパラメータ数。
ExceptionInformationDWORD60+20+20例外固有の追加情報配列(32ビット)。

各言語での定義

#include <windows.h>

// EXCEPTION_RECORD32  (x64 80 / x86 80 バイト)
typedef struct EXCEPTION_RECORD32 {
    NTSTATUS ExceptionCode;
    DWORD ExceptionFlags;
    DWORD ExceptionRecord;
    DWORD ExceptionAddress;
    DWORD NumberParameters;
    DWORD ExceptionInformation[15];
} EXCEPTION_RECORD32;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EXCEPTION_RECORD32
{
    public int ExceptionCode;
    public uint ExceptionFlags;
    public uint ExceptionRecord;
    public uint ExceptionAddress;
    public uint NumberParameters;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public uint[] ExceptionInformation;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EXCEPTION_RECORD32
    Public ExceptionCode As Integer
    Public ExceptionFlags As UInteger
    Public ExceptionRecord As UInteger
    Public ExceptionAddress As UInteger
    Public NumberParameters As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=15)> Public ExceptionInformation() As UInteger
End Structure
import ctypes
from ctypes import wintypes

class EXCEPTION_RECORD32(ctypes.Structure):
    _fields_ = [
        ("ExceptionCode", ctypes.c_int),
        ("ExceptionFlags", wintypes.DWORD),
        ("ExceptionRecord", wintypes.DWORD),
        ("ExceptionAddress", wintypes.DWORD),
        ("NumberParameters", wintypes.DWORD),
        ("ExceptionInformation", wintypes.DWORD * 15),
    ]
#[repr(C)]
pub struct EXCEPTION_RECORD32 {
    pub ExceptionCode: i32,
    pub ExceptionFlags: u32,
    pub ExceptionRecord: u32,
    pub ExceptionAddress: u32,
    pub NumberParameters: u32,
    pub ExceptionInformation: [u32; 15],
}
import "golang.org/x/sys/windows"

type EXCEPTION_RECORD32 struct {
	ExceptionCode int32
	ExceptionFlags uint32
	ExceptionRecord uint32
	ExceptionAddress uint32
	NumberParameters uint32
	ExceptionInformation [15]uint32
}
type
  EXCEPTION_RECORD32 = record
    ExceptionCode: Integer;
    ExceptionFlags: DWORD;
    ExceptionRecord: DWORD;
    ExceptionAddress: DWORD;
    NumberParameters: DWORD;
    ExceptionInformation: array[0..14] of DWORD;
  end;
const EXCEPTION_RECORD32 = extern struct {
    ExceptionCode: i32,
    ExceptionFlags: u32,
    ExceptionRecord: u32,
    ExceptionAddress: u32,
    NumberParameters: u32,
    ExceptionInformation: [15]u32,
};
type
  EXCEPTION_RECORD32 {.bycopy.} = object
    ExceptionCode: int32
    ExceptionFlags: uint32
    ExceptionRecord: uint32
    ExceptionAddress: uint32
    NumberParameters: uint32
    ExceptionInformation: array[15, uint32]
struct EXCEPTION_RECORD32
{
    int ExceptionCode;
    uint ExceptionFlags;
    uint ExceptionRecord;
    uint ExceptionAddress;
    uint NumberParameters;
    uint[15] ExceptionInformation;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EXCEPTION_RECORD32 サイズ: 80 バイト(x64)
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 : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ExceptionAddress : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; NumberParameters : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ExceptionInformation : DWORD (+20, 60byte)  varptr(st)+20 を基点に操作(60byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global EXCEPTION_RECORD32
    #field int ExceptionCode
    #field int ExceptionFlags
    #field int ExceptionRecord
    #field int ExceptionAddress
    #field int NumberParameters
    #field int ExceptionInformation 15
#endstruct

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