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

NDRSContextMarshallEx

関数
バインディング指定でサーバーコンテキストをマーシャリングする拡張版。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

void NDRSContextMarshallEx(
    void* BindingHandle,
    NDR_SCONTEXT* CContext,
    void* pBuff,
    NDR_RUNDOWN userRunDownIn
);

パラメーター

名前方向説明
BindingHandlevoid*inコンテキストに関連付けるサーバー側バインディングハンドル。
CContextNDR_SCONTEXT*inマーシャリングするサーバー側コンテキストハンドル(NDR_SCONTEXT)。
pBuffvoid*outコンテキストをシリアライズして書き込む出力バッファへのポインタ。
userRunDownInNDR_RUNDOWNinコンテキストのランダウンコールバック関数(NDR_RUNDOWN)。NULL可。

戻り値の型: void

各言語での呼び出し定義

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

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

NDRSContextMarshallEx = ctypes.windll.rpcrt4.NDRSContextMarshallEx
NDRSContextMarshallEx.restype = None
NDRSContextMarshallEx.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
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNDRSContextMarshallEx = rpcrt4.NewProc("NDRSContextMarshallEx")
)

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

extern "rpcrt4" fn NDRSContextMarshallEx(
    BindingHandle: ?*anyopaque, // void*
    CContext: [*c]NDR_SCONTEXT, // NDR_SCONTEXT*
    pBuff: ?*anyopaque, // void* out
    userRunDownIn: ?*anyopaque // NDR_RUNDOWN
) callconv(std.os.windows.WINAPI) void;
proc NDRSContextMarshallEx(
    BindingHandle: pointer,  # void*
    CContext: ptr NDR_SCONTEXT,  # NDR_SCONTEXT*
    pBuff: pointer,  # void* out
    userRunDownIn: pointer  # NDR_RUNDOWN
) {.importc: "NDRSContextMarshallEx", stdcall, dynlib: "RPCRT4.dll".}
pragma(lib, "rpcrt4");
extern(Windows)
void NDRSContextMarshallEx(
    void* BindingHandle,   // void*
    NDR_SCONTEXT* CContext,   // NDR_SCONTEXT*
    void* pBuff,   // void* out
    void* userRunDownIn   // NDR_RUNDOWN
);
ccall((:NDRSContextMarshallEx, "RPCRT4.dll"), stdcall, Cvoid,
      (Ptr{Cvoid}, Ptr{NDR_SCONTEXT}, Ptr{Cvoid}, Ptr{Cvoid}),
      BindingHandle, CContext, pBuff, userRunDownIn)
# BindingHandle : void* -> Ptr{Cvoid}
# CContext : NDR_SCONTEXT* -> Ptr{NDR_SCONTEXT}
# pBuff : void* out -> Ptr{Cvoid}
# userRunDownIn : NDR_RUNDOWN -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void NDRSContextMarshallEx(
    void* BindingHandle,
    void* CContext,
    void* pBuff,
    void* userRunDownIn);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.NDRSContextMarshallEx(BindingHandle, CContext, pBuff, userRunDownIn)
-- BindingHandle : void*
-- CContext : NDR_SCONTEXT*
-- pBuff : void* out
-- userRunDownIn : NDR_RUNDOWN
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const NDRSContextMarshallEx = lib.func('__stdcall', 'NDRSContextMarshallEx', 'void', ['void *', 'void *', 'void *', 'void *']);
// NDRSContextMarshallEx(BindingHandle, CContext, pBuff, userRunDownIn)
// BindingHandle : void* -> 'void *'
// CContext : NDR_SCONTEXT* -> 'void *'
// pBuff : void* out -> 'void *'
// userRunDownIn : NDR_RUNDOWN -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("RPCRT4.dll", {
  NDRSContextMarshallEx: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "void" },
});
// lib.symbols.NDRSContextMarshallEx(BindingHandle, CContext, pBuff, userRunDownIn)
// BindingHandle : void* -> "pointer"
// CContext : NDR_SCONTEXT* -> "pointer"
// pBuff : void* out -> "pointer"
// userRunDownIn : NDR_RUNDOWN -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void NDRSContextMarshallEx(
    void* BindingHandle,
    void* CContext,
    void* pBuff,
    void* userRunDownIn);
C, "RPCRT4.dll");
// $ffi->NDRSContextMarshallEx(BindingHandle, CContext, pBuff, userRunDownIn);
// BindingHandle : void*
// CContext : NDR_SCONTEXT*
// pBuff : void* out
// userRunDownIn : NDR_RUNDOWN
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Rpcrt4 extends StdCallLibrary {
    Rpcrt4 INSTANCE = Native.load("rpcrt4", Rpcrt4.class);
    void NDRSContextMarshallEx(
        Pointer BindingHandle,   // void*
        Pointer CContext,   // NDR_SCONTEXT*
        Pointer pBuff,   // void* out
        Callback userRunDownIn   // NDR_RUNDOWN
    );
}
@[Link("rpcrt4")]
lib LibRPCRT4
  fun NDRSContextMarshallEx = NDRSContextMarshallEx(
    BindingHandle : Void*,   # void*
    CContext : NDR_SCONTEXT*,   # NDR_SCONTEXT*
    pBuff : Void*,   # void* out
    userRunDownIn : Void*   # NDR_RUNDOWN
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef NDRSContextMarshallExNative = Void Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef NDRSContextMarshallExDart = void Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final NDRSContextMarshallEx = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<NDRSContextMarshallExNative, NDRSContextMarshallExDart>('NDRSContextMarshallEx');
// BindingHandle : void* -> Pointer<Void>
// CContext : NDR_SCONTEXT* -> Pointer<Void>
// pBuff : void* out -> Pointer<Void>
// userRunDownIn : NDR_RUNDOWN -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure NDRSContextMarshallEx(
  BindingHandle: Pointer;   // void*
  CContext: Pointer;   // NDR_SCONTEXT*
  pBuff: Pointer;   // void* out
  userRunDownIn: Pointer   // NDR_RUNDOWN
); stdcall;
  external 'RPCRT4.dll' name 'NDRSContextMarshallEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NDRSContextMarshallEx"
  c_NDRSContextMarshallEx :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO ()
-- BindingHandle : void* -> Ptr ()
-- CContext : NDR_SCONTEXT* -> Ptr ()
-- pBuff : void* out -> Ptr ()
-- userRunDownIn : NDR_RUNDOWN -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ndrscontextmarshallex =
  foreign "NDRSContextMarshallEx"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning void)
(* BindingHandle : void* -> (ptr void) *)
(* CContext : NDR_SCONTEXT* -> (ptr void) *)
(* pBuff : void* out -> (ptr void) *)
(* userRunDownIn : NDR_RUNDOWN -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("NDRSContextMarshallEx" ndrscontext-marshall-ex :convention :stdcall) :void
  (binding-handle :pointer)   ; void*
  (ccontext :pointer)   ; NDR_SCONTEXT*
  (p-buff :pointer)   ; void* out
  (user-run-down-in :pointer))   ; NDR_RUNDOWN
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NDRSContextMarshallEx = Win32::API::More->new('RPCRT4',
    'void NDRSContextMarshallEx(LPVOID BindingHandle, LPVOID CContext, LPVOID pBuff, LPVOID userRunDownIn)');
# my $ret = $NDRSContextMarshallEx->Call($BindingHandle, $CContext, $pBuff, $userRunDownIn);
# BindingHandle : void* -> LPVOID
# CContext : NDR_SCONTEXT* -> LPVOID
# pBuff : void* out -> LPVOID
# userRunDownIn : NDR_RUNDOWN -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

類似 API
使用する型