Win32 API 日本語リファレンス
ホームSystem.Rpc › NDRSContextMarshall2

NDRSContextMarshall2

関数
ガード付きでサーバーコンテキストをマーシャリングする拡張版。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

void NDRSContextMarshall2(
    void* BindingHandle,
    NDR_SCONTEXT* CContext,
    void* pBuff,
    NDR_RUNDOWN userRunDownIn,
    void* CtxGuard,   // optional
    DWORD Flags
);

パラメーター

名前方向
BindingHandlevoid*in
CContextNDR_SCONTEXT*in
pBuffvoid*out
userRunDownInNDR_RUNDOWNin
CtxGuardvoid*inoptional
FlagsDWORDin

戻り値の型: void

各言語での呼び出し定義

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

void NDRSContextMarshall2(
    void* BindingHandle,
    NDR_SCONTEXT* CContext,
    void* pBuff,
    NDR_RUNDOWN userRunDownIn,
    void* CtxGuard,   // optional
    DWORD Flags
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern void NDRSContextMarshall2(
    IntPtr BindingHandle,   // void*
    IntPtr CContext,   // NDR_SCONTEXT*
    IntPtr pBuff,   // void* out
    IntPtr userRunDownIn,   // NDR_RUNDOWN
    IntPtr CtxGuard,   // void* optional
    uint Flags   // DWORD
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Sub NDRSContextMarshall2(
    BindingHandle As IntPtr,   ' void*
    CContext As IntPtr,   ' NDR_SCONTEXT*
    pBuff As IntPtr,   ' void* out
    userRunDownIn As IntPtr,   ' NDR_RUNDOWN
    CtxGuard As IntPtr,   ' void* optional
    Flags As UInteger   ' DWORD
)
End Sub
' BindingHandle : void*
' CContext : NDR_SCONTEXT*
' pBuff : void* out
' userRunDownIn : NDR_RUNDOWN
' CtxGuard : void* optional
' Flags : DWORD
Declare PtrSafe Sub NDRSContextMarshall2 Lib "rpcrt4" ( _
    ByVal BindingHandle As LongPtr, _
    ByVal CContext As LongPtr, _
    ByVal pBuff As LongPtr, _
    ByVal userRunDownIn As LongPtr, _
    ByVal CtxGuard As LongPtr, _
    ByVal Flags As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NDRSContextMarshall2 = ctypes.windll.rpcrt4.NDRSContextMarshall2
NDRSContextMarshall2.restype = None
NDRSContextMarshall2.argtypes = [
    ctypes.POINTER(None),  # BindingHandle : void*
    ctypes.c_void_p,  # CContext : NDR_SCONTEXT*
    ctypes.POINTER(None),  # pBuff : void* out
    ctypes.c_void_p,  # userRunDownIn : NDR_RUNDOWN
    ctypes.POINTER(None),  # CtxGuard : void* optional
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
NDRSContextMarshall2 = Fiddle::Function.new(
  lib['NDRSContextMarshall2'],
  [
    Fiddle::TYPE_VOIDP,  # BindingHandle : void*
    Fiddle::TYPE_VOIDP,  # CContext : NDR_SCONTEXT*
    Fiddle::TYPE_VOIDP,  # pBuff : void* out
    Fiddle::TYPE_VOIDP,  # userRunDownIn : NDR_RUNDOWN
    Fiddle::TYPE_VOIDP,  # CtxGuard : void* optional
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_VOID)
#[link(name = "rpcrt4")]
extern "system" {
    fn NDRSContextMarshall2(
        BindingHandle: *mut (),  // void*
        CContext: *mut NDR_SCONTEXT,  // NDR_SCONTEXT*
        pBuff: *mut (),  // void* out
        userRunDownIn: *const core::ffi::c_void,  // NDR_RUNDOWN
        CtxGuard: *mut (),  // void* optional
        Flags: u32  // DWORD
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll")]
public static extern void NDRSContextMarshall2(IntPtr BindingHandle, IntPtr CContext, IntPtr pBuff, IntPtr userRunDownIn, IntPtr CtxGuard, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_NDRSContextMarshall2' -Namespace Win32 -PassThru
# $api::NDRSContextMarshall2(BindingHandle, CContext, pBuff, userRunDownIn, CtxGuard, Flags)
#uselib "RPCRT4.dll"
#func global NDRSContextMarshall2 "NDRSContextMarshall2" sptr, sptr, sptr, sptr, sptr, sptr
; NDRSContextMarshall2 BindingHandle, varptr(CContext), pBuff, userRunDownIn, CtxGuard, Flags
; BindingHandle : void* -> "sptr"
; CContext : NDR_SCONTEXT* -> "sptr"
; pBuff : void* out -> "sptr"
; userRunDownIn : NDR_RUNDOWN -> "sptr"
; CtxGuard : void* optional -> "sptr"
; Flags : DWORD -> "sptr"
出力引数:
#uselib "RPCRT4.dll"
#func global NDRSContextMarshall2 "NDRSContextMarshall2" sptr, var, sptr, sptr, sptr, int
; NDRSContextMarshall2 BindingHandle, CContext, pBuff, userRunDownIn, CtxGuard, Flags
; BindingHandle : void* -> "sptr"
; CContext : NDR_SCONTEXT* -> "var"
; pBuff : void* out -> "sptr"
; userRunDownIn : NDR_RUNDOWN -> "sptr"
; CtxGuard : void* optional -> "sptr"
; Flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void NDRSContextMarshall2(void* BindingHandle, NDR_SCONTEXT* CContext, void* pBuff, NDR_RUNDOWN userRunDownIn, void* CtxGuard, DWORD Flags)
#uselib "RPCRT4.dll"
#func global NDRSContextMarshall2 "NDRSContextMarshall2" intptr, var, intptr, intptr, intptr, int
; NDRSContextMarshall2 BindingHandle, CContext, pBuff, userRunDownIn, CtxGuard, Flags
; BindingHandle : void* -> "intptr"
; CContext : NDR_SCONTEXT* -> "var"
; pBuff : void* out -> "intptr"
; userRunDownIn : NDR_RUNDOWN -> "intptr"
; CtxGuard : void* optional -> "intptr"
; Flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNDRSContextMarshall2 = rpcrt4.NewProc("NDRSContextMarshall2")
)

// BindingHandle (void*), CContext (NDR_SCONTEXT*), pBuff (void* out), userRunDownIn (NDR_RUNDOWN), CtxGuard (void* optional), Flags (DWORD)
r1, _, err := procNDRSContextMarshall2.Call(
	uintptr(BindingHandle),
	uintptr(CContext),
	uintptr(pBuff),
	uintptr(userRunDownIn),
	uintptr(CtxGuard),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure NDRSContextMarshall2(
  BindingHandle: Pointer;   // void*
  CContext: Pointer;   // NDR_SCONTEXT*
  pBuff: Pointer;   // void* out
  userRunDownIn: Pointer;   // NDR_RUNDOWN
  CtxGuard: Pointer;   // void* optional
  Flags: DWORD   // DWORD
); stdcall;
  external 'RPCRT4.dll' name 'NDRSContextMarshall2';
result := DllCall("RPCRT4\NDRSContextMarshall2"
    , "Ptr", BindingHandle   ; void*
    , "Ptr", CContext   ; NDR_SCONTEXT*
    , "Ptr", pBuff   ; void* out
    , "Ptr", userRunDownIn   ; NDR_RUNDOWN
    , "Ptr", CtxGuard   ; void* optional
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: void
●NDRSContextMarshall2(BindingHandle, CContext, pBuff, userRunDownIn, CtxGuard, Flags) = DLL("RPCRT4.dll", "int NDRSContextMarshall2(void*, void*, void*, void*, void*, dword)")
# 呼び出し: NDRSContextMarshall2(BindingHandle, CContext, pBuff, userRunDownIn, CtxGuard, Flags)
# BindingHandle : void* -> "void*"
# CContext : NDR_SCONTEXT* -> "void*"
# pBuff : void* out -> "void*"
# userRunDownIn : NDR_RUNDOWN -> "void*"
# CtxGuard : void* optional -> "void*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。