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

EXCEPTION_RECORD64

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

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

フィールド

フィールドサイズx64x86説明
ExceptionCodeNTSTATUS4+0+0例外の種類を示すコード(NTSTATUS)。
ExceptionFlagsDWORD4+4+4例外フラグ。
ExceptionRecordULONGLONG8+8+8入れ子の例外レコードへの64ビットアドレス。
ExceptionAddressULONGLONG8+16+16例外発生命令の64ビットアドレス。
NumberParametersDWORD4+24+24有効なパラメータ数。
__unusedAlignmentDWORD4+28+2864ビット境界調整用の未使用パディング。
ExceptionInformationULONGLONG120+32+32例外固有の追加情報配列(64ビット)。

各言語での定義

#include <windows.h>

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

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

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

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

type EXCEPTION_RECORD64 struct {
	ExceptionCode int32
	ExceptionFlags uint32
	ExceptionRecord uint64
	ExceptionAddress uint64
	NumberParameters uint32
	__unusedAlignment uint32
	ExceptionInformation [15]uint64
}
type
  EXCEPTION_RECORD64 = record
    ExceptionCode: Integer;
    ExceptionFlags: DWORD;
    ExceptionRecord: UInt64;
    ExceptionAddress: UInt64;
    NumberParameters: DWORD;
    __unusedAlignment: DWORD;
    ExceptionInformation: array[0..14] of UInt64;
  end;
const EXCEPTION_RECORD64 = extern struct {
    ExceptionCode: i32,
    ExceptionFlags: u32,
    ExceptionRecord: u64,
    ExceptionAddress: u64,
    NumberParameters: u32,
    __unusedAlignment: u32,
    ExceptionInformation: [15]u64,
};
type
  EXCEPTION_RECORD64 {.bycopy.} = object
    ExceptionCode: int32
    ExceptionFlags: uint32
    ExceptionRecord: uint64
    ExceptionAddress: uint64
    NumberParameters: uint32
    __unusedAlignment: uint32
    ExceptionInformation: array[15, uint64]
struct EXCEPTION_RECORD64
{
    int ExceptionCode;
    uint ExceptionFlags;
    ulong ExceptionRecord;
    ulong ExceptionAddress;
    uint NumberParameters;
    uint __unusedAlignment;
    ulong[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_RECORD64 サイズ: 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 : ULONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ExceptionAddress : ULONGLONG (+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 も可)
; __unusedAlignment : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ExceptionInformation : ULONGLONG (+32, 120byte)  varptr(st)+32 を基点に操作(120byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global EXCEPTION_RECORD64
    #field int ExceptionCode
    #field int ExceptionFlags
    #field int64 ExceptionRecord
    #field int64 ExceptionAddress
    #field int NumberParameters
    #field int __unusedAlignment
    #field int64 ExceptionInformation 15
#endstruct

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