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

RtlCaptureContext

関数
現在のスレッドのCPUコンテキストを取得する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

void RtlCaptureContext(
    CONTEXT* ContextRecord
);

パラメーター

名前方向
ContextRecordCONTEXT*out

戻り値の型: void

各言語での呼び出し定義

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

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

RtlCaptureContext = ctypes.windll.kernel32.RtlCaptureContext
RtlCaptureContext.restype = None
RtlCaptureContext.argtypes = [
    ctypes.c_void_p,  # ContextRecord : CONTEXT* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procRtlCaptureContext = kernel32.NewProc("RtlCaptureContext")
)

// ContextRecord (CONTEXT* out)
r1, _, err := procRtlCaptureContext.Call(
	uintptr(ContextRecord),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure RtlCaptureContext(
  ContextRecord: Pointer   // CONTEXT* out
); stdcall;
  external 'KERNEL32.dll' name 'RtlCaptureContext';
result := DllCall("KERNEL32\RtlCaptureContext"
    , "Ptr", ContextRecord   ; CONTEXT* out
    , "Int")   ; return: void
●RtlCaptureContext(ContextRecord) = DLL("KERNEL32.dll", "int RtlCaptureContext(void*)")
# 呼び出し: RtlCaptureContext(ContextRecord)
# ContextRecord : CONTEXT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。