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