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

MINIDUMP_EXCEPTION_STREAM

構造体
サイズx64: 168 バイト / x86: 168 バイトパッキング4

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

フィールド

フィールドサイズx64x86説明
ThreadIdDWORD4+0+0例外を発生させたスレッドのID。
__alignmentDWORD4+4+4アラインメント調整用のパディング。
ExceptionRecordMINIDUMP_EXCEPTION152+8+8例外の詳細(MINIDUMP_EXCEPTION)。
ThreadContextMINIDUMP_LOCATION_DESCRIPTOR8+160+160例外発生時のCONTEXTのダンプ内位置。

各言語での定義

#include <windows.h>

// MINIDUMP_EXCEPTION  (x64 152 / x86 152 バイト)
#pragma pack(push, 4)
typedef struct MINIDUMP_EXCEPTION {
    DWORD ExceptionCode;
    DWORD ExceptionFlags;
    ULONGLONG ExceptionRecord;
    ULONGLONG ExceptionAddress;
    DWORD NumberParameters;
    DWORD __unusedAlignment;
    ULONGLONG ExceptionInformation[15];
} MINIDUMP_EXCEPTION;
#pragma pack(pop)

// MINIDUMP_LOCATION_DESCRIPTOR  (x64 8 / x86 8 バイト)
#pragma pack(push, 4)
typedef struct MINIDUMP_LOCATION_DESCRIPTOR {
    DWORD DataSize;
    DWORD Rva;
} MINIDUMP_LOCATION_DESCRIPTOR;
#pragma pack(pop)

// MINIDUMP_EXCEPTION_STREAM  (x64 168 / x86 168 バイト)
#pragma pack(push, 4)
typedef struct MINIDUMP_EXCEPTION_STREAM {
    DWORD ThreadId;
    DWORD __alignment;
    MINIDUMP_EXCEPTION ExceptionRecord;
    MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
} MINIDUMP_EXCEPTION_STREAM;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
public struct MINIDUMP_EXCEPTION
{
    public uint ExceptionCode;
    public uint ExceptionFlags;
    public ulong ExceptionRecord;
    public ulong ExceptionAddress;
    public uint NumberParameters;
    public uint __unusedAlignment;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public ulong[] ExceptionInformation;
}

[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
public struct MINIDUMP_LOCATION_DESCRIPTOR
{
    public uint DataSize;
    public uint Rva;
}

[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
public struct MINIDUMP_EXCEPTION_STREAM
{
    public uint ThreadId;
    public uint __alignment;
    public MINIDUMP_EXCEPTION ExceptionRecord;
    public MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=4, CharSet:=CharSet.Unicode)>
Public Structure MINIDUMP_EXCEPTION
    Public ExceptionCode As UInteger
    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

<StructLayout(LayoutKind.Sequential, Pack:=4, CharSet:=CharSet.Unicode)>
Public Structure MINIDUMP_LOCATION_DESCRIPTOR
    Public DataSize As UInteger
    Public Rva As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=4, CharSet:=CharSet.Unicode)>
Public Structure MINIDUMP_EXCEPTION_STREAM
    Public ThreadId As UInteger
    Public __alignment As UInteger
    Public ExceptionRecord As MINIDUMP_EXCEPTION
    Public ThreadContext As MINIDUMP_LOCATION_DESCRIPTOR
End Structure
import ctypes
from ctypes import wintypes

class MINIDUMP_EXCEPTION(ctypes.Structure):
    _pack_ = 4
    _fields_ = [
        ("ExceptionCode", wintypes.DWORD),
        ("ExceptionFlags", wintypes.DWORD),
        ("ExceptionRecord", ctypes.c_ulonglong),
        ("ExceptionAddress", ctypes.c_ulonglong),
        ("NumberParameters", wintypes.DWORD),
        ("__unusedAlignment", wintypes.DWORD),
        ("ExceptionInformation", ctypes.c_ulonglong * 15),
    ]

class MINIDUMP_LOCATION_DESCRIPTOR(ctypes.Structure):
    _pack_ = 4
    _fields_ = [
        ("DataSize", wintypes.DWORD),
        ("Rva", wintypes.DWORD),
    ]

class MINIDUMP_EXCEPTION_STREAM(ctypes.Structure):
    _pack_ = 4
    _fields_ = [
        ("ThreadId", wintypes.DWORD),
        ("__alignment", wintypes.DWORD),
        ("ExceptionRecord", MINIDUMP_EXCEPTION),
        ("ThreadContext", MINIDUMP_LOCATION_DESCRIPTOR),
    ]
#[repr(C, packed(4))]
pub struct MINIDUMP_EXCEPTION {
    pub ExceptionCode: u32,
    pub ExceptionFlags: u32,
    pub ExceptionRecord: u64,
    pub ExceptionAddress: u64,
    pub NumberParameters: u32,
    pub __unusedAlignment: u32,
    pub ExceptionInformation: [u64; 15],
}

#[repr(C, packed(4))]
pub struct MINIDUMP_LOCATION_DESCRIPTOR {
    pub DataSize: u32,
    pub Rva: u32,
}

#[repr(C, packed(4))]
pub struct MINIDUMP_EXCEPTION_STREAM {
    pub ThreadId: u32,
    pub __alignment: u32,
    pub ExceptionRecord: MINIDUMP_EXCEPTION,
    pub ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR,
}
import "golang.org/x/sys/windows"

type MINIDUMP_EXCEPTION struct {
	ExceptionCode uint32
	ExceptionFlags uint32
	ExceptionRecord uint64
	ExceptionAddress uint64
	NumberParameters uint32
	__unusedAlignment uint32
	ExceptionInformation [15]uint64
}

type MINIDUMP_LOCATION_DESCRIPTOR struct {
	DataSize uint32
	Rva uint32
}

type MINIDUMP_EXCEPTION_STREAM struct {
	ThreadId uint32
	__alignment uint32
	ExceptionRecord MINIDUMP_EXCEPTION
	ThreadContext MINIDUMP_LOCATION_DESCRIPTOR
}
type
  MINIDUMP_EXCEPTION = packed record
    ExceptionCode: DWORD;
    ExceptionFlags: DWORD;
    ExceptionRecord: UInt64;
    ExceptionAddress: UInt64;
    NumberParameters: DWORD;
    __unusedAlignment: DWORD;
    ExceptionInformation: array[0..14] of UInt64;
  end;

  MINIDUMP_LOCATION_DESCRIPTOR = packed record
    DataSize: DWORD;
    Rva: DWORD;
  end;

  MINIDUMP_EXCEPTION_STREAM = packed record
    ThreadId: DWORD;
    __alignment: DWORD;
    ExceptionRecord: MINIDUMP_EXCEPTION;
    ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR;
  end;
const MINIDUMP_EXCEPTION = extern struct {
    ExceptionCode: u32,
    ExceptionFlags: u32,
    ExceptionRecord: u64,
    ExceptionAddress: u64,
    NumberParameters: u32,
    __unusedAlignment: u32,
    ExceptionInformation: [15]u64,
};

const MINIDUMP_LOCATION_DESCRIPTOR = extern struct {
    DataSize: u32,
    Rva: u32,
};

const MINIDUMP_EXCEPTION_STREAM = extern struct {
    ThreadId: u32,
    __alignment: u32,
    ExceptionRecord: MINIDUMP_EXCEPTION,
    ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR,
};
type
  MINIDUMP_EXCEPTION {.packed.} = object
    ExceptionCode: uint32
    ExceptionFlags: uint32
    ExceptionRecord: uint64
    ExceptionAddress: uint64
    NumberParameters: uint32
    __unusedAlignment: uint32
    ExceptionInformation: array[15, uint64]

  MINIDUMP_LOCATION_DESCRIPTOR {.packed.} = object
    DataSize: uint32
    Rva: uint32

  MINIDUMP_EXCEPTION_STREAM {.packed.} = object
    ThreadId: uint32
    __alignment: uint32
    ExceptionRecord: MINIDUMP_EXCEPTION
    ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR
align(4)
struct MINIDUMP_EXCEPTION
{
    uint ExceptionCode;
    uint ExceptionFlags;
    ulong ExceptionRecord;
    ulong ExceptionAddress;
    uint NumberParameters;
    uint __unusedAlignment;
    ulong[15] ExceptionInformation;
}

align(4)
struct MINIDUMP_LOCATION_DESCRIPTOR
{
    uint DataSize;
    uint Rva;
}

align(4)
struct MINIDUMP_EXCEPTION_STREAM
{
    uint ThreadId;
    uint __alignment;
    MINIDUMP_EXCEPTION ExceptionRecord;
    MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MINIDUMP_EXCEPTION_STREAM サイズ: 168 バイト(x64)
dim st, 42    ; 4byte整数×42(構造体サイズ 168 / 4 切り上げ)
; ThreadId : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; __alignment : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ExceptionRecord : MINIDUMP_EXCEPTION (+8, 152byte)  varptr(st)+8 を基点に操作(152byte:入れ子/配列)
; ThreadContext : MINIDUMP_LOCATION_DESCRIPTOR (+160, 8byte)  varptr(st)+160 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global MINIDUMP_EXCEPTION, pack=4
    #field int ExceptionCode
    #field int ExceptionFlags
    #field int64 ExceptionRecord
    #field int64 ExceptionAddress
    #field int NumberParameters
    #field int __unusedAlignment
    #field int64 ExceptionInformation 15
#endstruct

#defstruct global MINIDUMP_LOCATION_DESCRIPTOR, pack=4
    #field int DataSize
    #field int Rva
#endstruct

#defstruct global MINIDUMP_EXCEPTION_STREAM, pack=4
    #field int ThreadId
    #field int __alignment
    #field MINIDUMP_EXCEPTION ExceptionRecord
    #field MINIDUMP_LOCATION_DESCRIPTOR ThreadContext
#endstruct

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