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

RtlInstallFunctionTableCallback

関数
関数テーブルを動的に提供するコールバックを登録する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOLEAN RtlInstallFunctionTableCallback(
    ULONGLONG TableIdentifier,
    ULONGLONG BaseAddress,
    DWORD Length,
    PGET_RUNTIME_FUNCTION_CALLBACK Callback,
    void* Context,   // optional
    LPCWSTR OutOfProcessCallbackDll   // optional
);

パラメーター

名前方向
TableIdentifierULONGLONGin
BaseAddressULONGLONGin
LengthDWORDin
CallbackPGET_RUNTIME_FUNCTION_CALLBACKin
Contextvoid*inoptional
OutOfProcessCallbackDllLPCWSTRinoptional

戻り値の型: BOOLEAN

各言語での呼び出し定義

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

BOOLEAN RtlInstallFunctionTableCallback(
    ULONGLONG TableIdentifier,
    ULONGLONG BaseAddress,
    DWORD Length,
    PGET_RUNTIME_FUNCTION_CALLBACK Callback,
    void* Context,   // optional
    LPCWSTR OutOfProcessCallbackDll   // optional
);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern byte RtlInstallFunctionTableCallback(
    ulong TableIdentifier,   // ULONGLONG
    ulong BaseAddress,   // ULONGLONG
    uint Length,   // DWORD
    IntPtr Callback,   // PGET_RUNTIME_FUNCTION_CALLBACK
    IntPtr Context,   // void* optional
    [MarshalAs(UnmanagedType.LPWStr)] string OutOfProcessCallbackDll   // LPCWSTR optional
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function RtlInstallFunctionTableCallback(
    TableIdentifier As ULong,   ' ULONGLONG
    BaseAddress As ULong,   ' ULONGLONG
    Length As UInteger,   ' DWORD
    Callback As IntPtr,   ' PGET_RUNTIME_FUNCTION_CALLBACK
    Context As IntPtr,   ' void* optional
    <MarshalAs(UnmanagedType.LPWStr)> OutOfProcessCallbackDll As String   ' LPCWSTR optional
) As Byte
End Function
' TableIdentifier : ULONGLONG
' BaseAddress : ULONGLONG
' Length : DWORD
' Callback : PGET_RUNTIME_FUNCTION_CALLBACK
' Context : void* optional
' OutOfProcessCallbackDll : LPCWSTR optional
Declare PtrSafe Function RtlInstallFunctionTableCallback Lib "kernel32" ( _
    ByVal TableIdentifier As LongLong, _
    ByVal BaseAddress As LongLong, _
    ByVal Length As Long, _
    ByVal Callback As LongPtr, _
    ByVal Context As LongPtr, _
    ByVal OutOfProcessCallbackDll As LongPtr) As Byte
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtlInstallFunctionTableCallback = ctypes.windll.kernel32.RtlInstallFunctionTableCallback
RtlInstallFunctionTableCallback.restype = ctypes.c_byte
RtlInstallFunctionTableCallback.argtypes = [
    ctypes.c_ulonglong,  # TableIdentifier : ULONGLONG
    ctypes.c_ulonglong,  # BaseAddress : ULONGLONG
    wintypes.DWORD,  # Length : DWORD
    ctypes.c_void_p,  # Callback : PGET_RUNTIME_FUNCTION_CALLBACK
    ctypes.POINTER(None),  # Context : void* optional
    wintypes.LPCWSTR,  # OutOfProcessCallbackDll : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
RtlInstallFunctionTableCallback = Fiddle::Function.new(
  lib['RtlInstallFunctionTableCallback'],
  [
    -Fiddle::TYPE_LONG_LONG,  # TableIdentifier : ULONGLONG
    -Fiddle::TYPE_LONG_LONG,  # BaseAddress : ULONGLONG
    -Fiddle::TYPE_INT,  # Length : DWORD
    Fiddle::TYPE_VOIDP,  # Callback : PGET_RUNTIME_FUNCTION_CALLBACK
    Fiddle::TYPE_VOIDP,  # Context : void* optional
    Fiddle::TYPE_VOIDP,  # OutOfProcessCallbackDll : LPCWSTR optional
  ],
  Fiddle::TYPE_CHAR)
#[link(name = "kernel32")]
extern "system" {
    fn RtlInstallFunctionTableCallback(
        TableIdentifier: u64,  // ULONGLONG
        BaseAddress: u64,  // ULONGLONG
        Length: u32,  // DWORD
        Callback: *const core::ffi::c_void,  // PGET_RUNTIME_FUNCTION_CALLBACK
        Context: *mut (),  // void* optional
        OutOfProcessCallbackDll: *const u16  // LPCWSTR optional
    ) -> u8;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll")]
public static extern byte RtlInstallFunctionTableCallback(ulong TableIdentifier, ulong BaseAddress, uint Length, IntPtr Callback, IntPtr Context, [MarshalAs(UnmanagedType.LPWStr)] string OutOfProcessCallbackDll);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_RtlInstallFunctionTableCallback' -Namespace Win32 -PassThru
# $api::RtlInstallFunctionTableCallback(TableIdentifier, BaseAddress, Length, Callback, Context, OutOfProcessCallbackDll)
#uselib "KERNEL32.dll"
#func global RtlInstallFunctionTableCallback "RtlInstallFunctionTableCallback" sptr, sptr, sptr, sptr, sptr, sptr
; RtlInstallFunctionTableCallback TableIdentifier, BaseAddress, Length, Callback, Context, OutOfProcessCallbackDll   ; 戻り値は stat
; TableIdentifier : ULONGLONG -> "sptr"
; BaseAddress : ULONGLONG -> "sptr"
; Length : DWORD -> "sptr"
; Callback : PGET_RUNTIME_FUNCTION_CALLBACK -> "sptr"
; Context : void* optional -> "sptr"
; OutOfProcessCallbackDll : LPCWSTR optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global RtlInstallFunctionTableCallback "RtlInstallFunctionTableCallback" int64, int64, int, sptr, sptr, wstr
; res = RtlInstallFunctionTableCallback(TableIdentifier, BaseAddress, Length, Callback, Context, OutOfProcessCallbackDll)
; TableIdentifier : ULONGLONG -> "int64"
; BaseAddress : ULONGLONG -> "int64"
; Length : DWORD -> "int"
; Callback : PGET_RUNTIME_FUNCTION_CALLBACK -> "sptr"
; Context : void* optional -> "sptr"
; OutOfProcessCallbackDll : LPCWSTR optional -> "wstr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; BOOLEAN RtlInstallFunctionTableCallback(ULONGLONG TableIdentifier, ULONGLONG BaseAddress, DWORD Length, PGET_RUNTIME_FUNCTION_CALLBACK Callback, void* Context, LPCWSTR OutOfProcessCallbackDll)
#uselib "KERNEL32.dll"
#cfunc global RtlInstallFunctionTableCallback "RtlInstallFunctionTableCallback" int64, int64, int, intptr, intptr, wstr
; res = RtlInstallFunctionTableCallback(TableIdentifier, BaseAddress, Length, Callback, Context, OutOfProcessCallbackDll)
; TableIdentifier : ULONGLONG -> "int64"
; BaseAddress : ULONGLONG -> "int64"
; Length : DWORD -> "int"
; Callback : PGET_RUNTIME_FUNCTION_CALLBACK -> "intptr"
; Context : void* optional -> "intptr"
; OutOfProcessCallbackDll : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procRtlInstallFunctionTableCallback = kernel32.NewProc("RtlInstallFunctionTableCallback")
)

// TableIdentifier (ULONGLONG), BaseAddress (ULONGLONG), Length (DWORD), Callback (PGET_RUNTIME_FUNCTION_CALLBACK), Context (void* optional), OutOfProcessCallbackDll (LPCWSTR optional)
r1, _, err := procRtlInstallFunctionTableCallback.Call(
	uintptr(TableIdentifier),
	uintptr(BaseAddress),
	uintptr(Length),
	uintptr(Callback),
	uintptr(Context),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(OutOfProcessCallbackDll))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOLEAN
function RtlInstallFunctionTableCallback(
  TableIdentifier: UInt64;   // ULONGLONG
  BaseAddress: UInt64;   // ULONGLONG
  Length: DWORD;   // DWORD
  Callback: Pointer;   // PGET_RUNTIME_FUNCTION_CALLBACK
  Context: Pointer;   // void* optional
  OutOfProcessCallbackDll: PWideChar   // LPCWSTR optional
): ByteBool; stdcall;
  external 'KERNEL32.dll' name 'RtlInstallFunctionTableCallback';
result := DllCall("KERNEL32\RtlInstallFunctionTableCallback"
    , "Int64", TableIdentifier   ; ULONGLONG
    , "Int64", BaseAddress   ; ULONGLONG
    , "UInt", Length   ; DWORD
    , "Ptr", Callback   ; PGET_RUNTIME_FUNCTION_CALLBACK
    , "Ptr", Context   ; void* optional
    , "WStr", OutOfProcessCallbackDll   ; LPCWSTR optional
    , "Char")   ; return: BOOLEAN
●RtlInstallFunctionTableCallback(TableIdentifier, BaseAddress, Length, Callback, Context, OutOfProcessCallbackDll) = DLL("KERNEL32.dll", "byte RtlInstallFunctionTableCallback(qword, qword, dword, void*, void*, char*)")
# 呼び出し: RtlInstallFunctionTableCallback(TableIdentifier, BaseAddress, Length, Callback, Context, OutOfProcessCallbackDll)
# TableIdentifier : ULONGLONG -> "qword"
# BaseAddress : ULONGLONG -> "qword"
# Length : DWORD -> "dword"
# Callback : PGET_RUNTIME_FUNCTION_CALLBACK -> "void*"
# Context : void* optional -> "void*"
# OutOfProcessCallbackDll : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。