ホーム › System.Diagnostics.Debug › RaiseFailFastException
RaiseFailFastException
関数プロセスを即座に終了させるフェイルファスト例外を発生させる。
シグネチャ
// KERNEL32.dll
#include <windows.h>
void RaiseFailFastException(
EXCEPTION_RECORD* pExceptionRecord, // optional
CONTEXT* pContextRecord, // optional
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pExceptionRecord | EXCEPTION_RECORD* | inoptional |
| pContextRecord | CONTEXT* | inoptional |
| dwFlags | DWORD | in |
戻り値の型: void
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
void RaiseFailFastException(
EXCEPTION_RECORD* pExceptionRecord, // optional
CONTEXT* pContextRecord, // optional
DWORD dwFlags
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern void RaiseFailFastException(
IntPtr pExceptionRecord, // EXCEPTION_RECORD* optional
IntPtr pContextRecord, // CONTEXT* optional
uint dwFlags // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Sub RaiseFailFastException(
pExceptionRecord As IntPtr, ' EXCEPTION_RECORD* optional
pContextRecord As IntPtr, ' CONTEXT* optional
dwFlags As UInteger ' DWORD
)
End Sub' pExceptionRecord : EXCEPTION_RECORD* optional
' pContextRecord : CONTEXT* optional
' dwFlags : DWORD
Declare PtrSafe Sub RaiseFailFastException Lib "kernel32" ( _
ByVal pExceptionRecord As LongPtr, _
ByVal pContextRecord As LongPtr, _
ByVal dwFlags As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RaiseFailFastException = ctypes.windll.kernel32.RaiseFailFastException
RaiseFailFastException.restype = None
RaiseFailFastException.argtypes = [
ctypes.c_void_p, # pExceptionRecord : EXCEPTION_RECORD* optional
ctypes.c_void_p, # pContextRecord : CONTEXT* optional
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
RaiseFailFastException = Fiddle::Function.new(
lib['RaiseFailFastException'],
[
Fiddle::TYPE_VOIDP, # pExceptionRecord : EXCEPTION_RECORD* optional
Fiddle::TYPE_VOIDP, # pContextRecord : CONTEXT* optional
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_VOID)#[link(name = "kernel32")]
extern "system" {
fn RaiseFailFastException(
pExceptionRecord: *mut EXCEPTION_RECORD, // EXCEPTION_RECORD* optional
pContextRecord: *mut CONTEXT, // CONTEXT* optional
dwFlags: u32 // DWORD
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern void RaiseFailFastException(IntPtr pExceptionRecord, IntPtr pContextRecord, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_RaiseFailFastException' -Namespace Win32 -PassThru
# $api::RaiseFailFastException(pExceptionRecord, pContextRecord, dwFlags)#uselib "KERNEL32.dll"
#func global RaiseFailFastException "RaiseFailFastException" sptr, sptr, sptr
; RaiseFailFastException varptr(pExceptionRecord), varptr(pContextRecord), dwFlags
; pExceptionRecord : EXCEPTION_RECORD* optional -> "sptr"
; pContextRecord : CONTEXT* optional -> "sptr"
; dwFlags : DWORD -> "sptr"出力引数:
#uselib "KERNEL32.dll" #func global RaiseFailFastException "RaiseFailFastException" var, var, int ; RaiseFailFastException pExceptionRecord, pContextRecord, dwFlags ; pExceptionRecord : EXCEPTION_RECORD* optional -> "var" ; pContextRecord : CONTEXT* optional -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #func global RaiseFailFastException "RaiseFailFastException" sptr, sptr, int ; RaiseFailFastException varptr(pExceptionRecord), varptr(pContextRecord), dwFlags ; pExceptionRecord : EXCEPTION_RECORD* optional -> "sptr" ; pContextRecord : CONTEXT* optional -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void RaiseFailFastException(EXCEPTION_RECORD* pExceptionRecord, CONTEXT* pContextRecord, DWORD dwFlags) #uselib "KERNEL32.dll" #func global RaiseFailFastException "RaiseFailFastException" var, var, int ; RaiseFailFastException pExceptionRecord, pContextRecord, dwFlags ; pExceptionRecord : EXCEPTION_RECORD* optional -> "var" ; pContextRecord : CONTEXT* optional -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void RaiseFailFastException(EXCEPTION_RECORD* pExceptionRecord, CONTEXT* pContextRecord, DWORD dwFlags) #uselib "KERNEL32.dll" #func global RaiseFailFastException "RaiseFailFastException" intptr, intptr, int ; RaiseFailFastException varptr(pExceptionRecord), varptr(pContextRecord), dwFlags ; pExceptionRecord : EXCEPTION_RECORD* optional -> "intptr" ; pContextRecord : CONTEXT* optional -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procRaiseFailFastException = kernel32.NewProc("RaiseFailFastException")
)
// pExceptionRecord (EXCEPTION_RECORD* optional), pContextRecord (CONTEXT* optional), dwFlags (DWORD)
r1, _, err := procRaiseFailFastException.Call(
uintptr(pExceptionRecord),
uintptr(pContextRecord),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure RaiseFailFastException(
pExceptionRecord: Pointer; // EXCEPTION_RECORD* optional
pContextRecord: Pointer; // CONTEXT* optional
dwFlags: DWORD // DWORD
); stdcall;
external 'KERNEL32.dll' name 'RaiseFailFastException';result := DllCall("KERNEL32\RaiseFailFastException"
, "Ptr", pExceptionRecord ; EXCEPTION_RECORD* optional
, "Ptr", pContextRecord ; CONTEXT* optional
, "UInt", dwFlags ; DWORD
, "Int") ; return: void●RaiseFailFastException(pExceptionRecord, pContextRecord, dwFlags) = DLL("KERNEL32.dll", "int RaiseFailFastException(void*, void*, dword)")
# 呼び出し: RaiseFailFastException(pExceptionRecord, pContextRecord, dwFlags)
# pExceptionRecord : EXCEPTION_RECORD* optional -> "void*"
# pContextRecord : CONTEXT* optional -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。