EXCEPTION_RECORD
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ExceptionCode | NTSTATUS | 4 | +0 | +0 | 例外が発生した理由です。これは、ハードウェア例外によって生成されたコード、またはソフトウェアによって生成された例外の場合は RaiseException 関数で指定されたコードです。次の表は、一般的なプログラミングエラーが原因で発生する可能性の高い例外コードを説明しています。 コンソールプロセスをデバッグしているときには、さらに別の例外コードが発生する可能性があります。これはプログラミングエラーが原因で発生するものではありません。DBG_CONTROL_C 例外コードは、CTRL+C シグナルを処理し、かつデバッグ中のコンソールプロセスに CTRL+C が入力されたときに発生します。この例外コードは、アプリケーションで処理することを意図したものではありません。これはデバッガーのためだけに発生し、デバッガーがコンソールプロセスにアタッチされている場合にのみ発生します。 | ||||||
| ExceptionFlags | DWORD | 4 | +4 | +4 | このメンバーには、0 個以上の例外フラグが格納されます。次の表では、よく見られる例外フラグの一部を説明します。次の表にない例外フラグは、システム用に予約済みとして扱ってください。
| ||||||
| ExceptionRecord | EXCEPTION_RECORD* | 8/4 | +8 | +8 | 関連付けられた EXCEPTION_RECORD 構造体へのポインターです。入れ子になった例外が発生したときに追加情報を提供できるよう、例外レコードは連結できます。 | ||||||
| ExceptionAddress | void* | 8/4 | +16 | +12 | 例外が発生したアドレスです。 | ||||||
| NumberParameters | DWORD | 4 | +24 | +16 | 例外に関連付けられたパラメーターの数です。これは ExceptionInformation 配列内の定義済み要素の数です。 | ||||||
| ExceptionInformation | UINT_PTR | 120/60 | +32 | +20 | 例外を説明する追加の引数の配列です。 RaiseException 関数でこの引数の配列を指定できます。ほとんどの例外コードでは、配列の要素は未定義です。次の表では、配列の要素が定義されている例外コードを説明します。 |
公式ドキュメント
例外を記述します。
解説(Remarks)
デバッガーが異なるアーキテクチャ (32 ビットと 64 ビット) 上で実行されているターゲットをデバッグできるようにするには、この構造体の明示的な形式のいずれかを使用します。
typedef struct _EXCEPTION_RECORD32 {
DWORD ExceptionCode;
DWORD ExceptionFlags;
DWORD ExceptionRecord;
DWORD ExceptionAddress;
DWORD NumberParameters;
DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
typedef struct _EXCEPTION_RECORD64 {
DWORD ExceptionCode;
DWORD ExceptionFlags;
DWORD64 ExceptionRecord;
DWORD64 ExceptionAddress;
DWORD NumberParameters;
DWORD __unusedAlignment;
DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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 Structureimport 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