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

RtlRestoreContext

関数
指定したCPUコンテキストを復元して実行を再開する。
DLLKERNEL32.dll呼出規約cdecl

シグネチャ

// KERNEL32.dll
#include <windows.h>

void RtlRestoreContext(
    CONTEXT* ContextRecord,
    EXCEPTION_RECORD* ExceptionRecord   // optional
);

パラメーター

名前方向
ContextRecordCONTEXT*in
ExceptionRecordEXCEPTION_RECORD*inoptional

戻り値の型: void

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

void RtlRestoreContext(
    CONTEXT* ContextRecord,
    EXCEPTION_RECORD* ExceptionRecord   // optional
);
[DllImport("KERNEL32.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void RtlRestoreContext(
    IntPtr ContextRecord,   // CONTEXT*
    IntPtr ExceptionRecord   // EXCEPTION_RECORD* optional
);
<DllImport("KERNEL32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub RtlRestoreContext(
    ContextRecord As IntPtr,   ' CONTEXT*
    ExceptionRecord As IntPtr   ' EXCEPTION_RECORD* optional
)
End Sub
' ContextRecord : CONTEXT*
' ExceptionRecord : EXCEPTION_RECORD* optional
Declare PtrSafe Sub RtlRestoreContext Lib "kernel32" ( _
    ByVal ContextRecord As LongPtr, _
    ByVal ExceptionRecord As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtlRestoreContext = ctypes.cdll.kernel32.RtlRestoreContext
RtlRestoreContext.restype = None
RtlRestoreContext.argtypes = [
    ctypes.c_void_p,  # ContextRecord : CONTEXT*
    ctypes.c_void_p,  # ExceptionRecord : EXCEPTION_RECORD* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
RtlRestoreContext = Fiddle::Function.new(
  lib['RtlRestoreContext'],
  [
    Fiddle::TYPE_VOIDP,  # ContextRecord : CONTEXT*
    Fiddle::TYPE_VOIDP,  # ExceptionRecord : EXCEPTION_RECORD* optional
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "kernel32")]
extern "C" {
    fn RtlRestoreContext(
        ContextRecord: *mut CONTEXT,  // CONTEXT*
        ExceptionRecord: *mut EXCEPTION_RECORD  // EXCEPTION_RECORD* optional
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void RtlRestoreContext(IntPtr ContextRecord, IntPtr ExceptionRecord);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_RtlRestoreContext' -Namespace Win32 -PassThru
# $api::RtlRestoreContext(ContextRecord, ExceptionRecord)
#uselib "KERNEL32.dll"
#func global RtlRestoreContext "RtlRestoreContext" sptr, sptr
; RtlRestoreContext varptr(ContextRecord), varptr(ExceptionRecord)
; ContextRecord : CONTEXT* -> "sptr"
; ExceptionRecord : EXCEPTION_RECORD* optional -> "sptr"
出力引数:
#uselib "KERNEL32.dll"
#func global RtlRestoreContext "RtlRestoreContext" var, var
; RtlRestoreContext ContextRecord, ExceptionRecord
; ContextRecord : CONTEXT* -> "var"
; ExceptionRecord : EXCEPTION_RECORD* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void RtlRestoreContext(CONTEXT* ContextRecord, EXCEPTION_RECORD* ExceptionRecord)
#uselib "KERNEL32.dll"
#func global RtlRestoreContext "RtlRestoreContext" var, var
; RtlRestoreContext ContextRecord, ExceptionRecord
; ContextRecord : CONTEXT* -> "var"
; ExceptionRecord : EXCEPTION_RECORD* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procRtlRestoreContext = kernel32.NewProc("RtlRestoreContext")
)

// ContextRecord (CONTEXT*), ExceptionRecord (EXCEPTION_RECORD* optional)
r1, _, err := procRtlRestoreContext.Call(
	uintptr(ContextRecord),
	uintptr(ExceptionRecord),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure RtlRestoreContext(
  ContextRecord: Pointer;   // CONTEXT*
  ExceptionRecord: Pointer   // EXCEPTION_RECORD* optional
); cdecl;
  external 'KERNEL32.dll' name 'RtlRestoreContext';
result := DllCall("KERNEL32\RtlRestoreContext"
    , "Ptr", ContextRecord   ; CONTEXT*
    , "Ptr", ExceptionRecord   ; EXCEPTION_RECORD* optional
    , "Cdecl Int")   ; return: void
●RtlRestoreContext(ContextRecord, ExceptionRecord) = DLL("KERNEL32.dll", "int RtlRestoreContext(void*, void*)")
# 呼び出し: RtlRestoreContext(ContextRecord, ExceptionRecord)
# ContextRecord : CONTEXT* -> "void*"
# ExceptionRecord : EXCEPTION_RECORD* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。