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

NdrCreateServerInterfaceFromStub

関数
スタブからRPCサーバーインターフェイス情報を生成する。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

RPC_STATUS NdrCreateServerInterfaceFromStub(
    IRpcStubBuffer* pStub,
    RPC_SERVER_INTERFACE* pServerIf
);

パラメーター

名前方向説明
pStubIRpcStubBuffer*inサーバースタブを表すIRpcStubBufferインターフェイスへのポインタ。
pServerIfRPC_SERVER_INTERFACE*inout生成したRPCサーバーインターフェイス情報を受け取る出力ポインタ。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS NdrCreateServerInterfaceFromStub(
    IRpcStubBuffer* pStub,
    RPC_SERVER_INTERFACE* pServerIf
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int NdrCreateServerInterfaceFromStub(
    IntPtr pStub,   // IRpcStubBuffer*
    IntPtr pServerIf   // RPC_SERVER_INTERFACE* in/out
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function NdrCreateServerInterfaceFromStub(
    pStub As IntPtr,   ' IRpcStubBuffer*
    pServerIf As IntPtr   ' RPC_SERVER_INTERFACE* in/out
) As Integer
End Function
' pStub : IRpcStubBuffer*
' pServerIf : RPC_SERVER_INTERFACE* in/out
Declare PtrSafe Function NdrCreateServerInterfaceFromStub Lib "rpcrt4" ( _
    ByVal pStub As LongPtr, _
    ByVal pServerIf As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NdrCreateServerInterfaceFromStub = ctypes.windll.rpcrt4.NdrCreateServerInterfaceFromStub
NdrCreateServerInterfaceFromStub.restype = ctypes.c_int
NdrCreateServerInterfaceFromStub.argtypes = [
    ctypes.c_void_p,  # pStub : IRpcStubBuffer*
    ctypes.c_void_p,  # pServerIf : RPC_SERVER_INTERFACE* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
NdrCreateServerInterfaceFromStub = Fiddle::Function.new(
  lib['NdrCreateServerInterfaceFromStub'],
  [
    Fiddle::TYPE_VOIDP,  # pStub : IRpcStubBuffer*
    Fiddle::TYPE_VOIDP,  # pServerIf : RPC_SERVER_INTERFACE* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "rpcrt4")]
extern "system" {
    fn NdrCreateServerInterfaceFromStub(
        pStub: *mut core::ffi::c_void,  // IRpcStubBuffer*
        pServerIf: *mut RPC_SERVER_INTERFACE  // RPC_SERVER_INTERFACE* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll")]
public static extern int NdrCreateServerInterfaceFromStub(IntPtr pStub, IntPtr pServerIf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_NdrCreateServerInterfaceFromStub' -Namespace Win32 -PassThru
# $api::NdrCreateServerInterfaceFromStub(pStub, pServerIf)
#uselib "RPCRT4.dll"
#func global NdrCreateServerInterfaceFromStub "NdrCreateServerInterfaceFromStub" sptr, sptr
; NdrCreateServerInterfaceFromStub pStub, varptr(pServerIf)   ; 戻り値は stat
; pStub : IRpcStubBuffer* -> "sptr"
; pServerIf : RPC_SERVER_INTERFACE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global NdrCreateServerInterfaceFromStub "NdrCreateServerInterfaceFromStub" sptr, var
; res = NdrCreateServerInterfaceFromStub(pStub, pServerIf)
; pStub : IRpcStubBuffer* -> "sptr"
; pServerIf : RPC_SERVER_INTERFACE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS NdrCreateServerInterfaceFromStub(IRpcStubBuffer* pStub, RPC_SERVER_INTERFACE* pServerIf)
#uselib "RPCRT4.dll"
#cfunc global NdrCreateServerInterfaceFromStub "NdrCreateServerInterfaceFromStub" intptr, var
; res = NdrCreateServerInterfaceFromStub(pStub, pServerIf)
; pStub : IRpcStubBuffer* -> "intptr"
; pServerIf : RPC_SERVER_INTERFACE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNdrCreateServerInterfaceFromStub = rpcrt4.NewProc("NdrCreateServerInterfaceFromStub")
)

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

extern "rpcrt4" fn NdrCreateServerInterfaceFromStub(
    pStub: ?*anyopaque, // IRpcStubBuffer*
    pServerIf: [*c]RPC_SERVER_INTERFACE // RPC_SERVER_INTERFACE* in/out
) callconv(std.os.windows.WINAPI) i32;
proc NdrCreateServerInterfaceFromStub(
    pStub: pointer,  # IRpcStubBuffer*
    pServerIf: ptr RPC_SERVER_INTERFACE  # RPC_SERVER_INTERFACE* in/out
): int32 {.importc: "NdrCreateServerInterfaceFromStub", stdcall, dynlib: "RPCRT4.dll".}
pragma(lib, "rpcrt4");
extern(Windows)
int NdrCreateServerInterfaceFromStub(
    void* pStub,   // IRpcStubBuffer*
    RPC_SERVER_INTERFACE* pServerIf   // RPC_SERVER_INTERFACE* in/out
);
ccall((:NdrCreateServerInterfaceFromStub, "RPCRT4.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{RPC_SERVER_INTERFACE}),
      pStub, pServerIf)
# pStub : IRpcStubBuffer* -> Ptr{Cvoid}
# pServerIf : RPC_SERVER_INTERFACE* in/out -> Ptr{RPC_SERVER_INTERFACE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t NdrCreateServerInterfaceFromStub(
    void* pStub,
    void* pServerIf);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.NdrCreateServerInterfaceFromStub(pStub, pServerIf)
-- pStub : IRpcStubBuffer*
-- pServerIf : RPC_SERVER_INTERFACE* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const NdrCreateServerInterfaceFromStub = lib.func('__stdcall', 'NdrCreateServerInterfaceFromStub', 'int32_t', ['void *', 'void *']);
// NdrCreateServerInterfaceFromStub(pStub, pServerIf)
// pStub : IRpcStubBuffer* -> 'void *'
// pServerIf : RPC_SERVER_INTERFACE* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RPCRT4.dll", {
  NdrCreateServerInterfaceFromStub: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.NdrCreateServerInterfaceFromStub(pStub, pServerIf)
// pStub : IRpcStubBuffer* -> "pointer"
// pServerIf : RPC_SERVER_INTERFACE* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t NdrCreateServerInterfaceFromStub(
    void* pStub,
    void* pServerIf);
C, "RPCRT4.dll");
// $ffi->NdrCreateServerInterfaceFromStub(pStub, pServerIf);
// pStub : IRpcStubBuffer*
// pServerIf : RPC_SERVER_INTERFACE* in/out
// 構造体/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);
    int NdrCreateServerInterfaceFromStub(
        Pointer pStub,   // IRpcStubBuffer*
        Pointer pServerIf   // RPC_SERVER_INTERFACE* in/out
    );
}
@[Link("rpcrt4")]
lib LibRPCRT4
  fun NdrCreateServerInterfaceFromStub = NdrCreateServerInterfaceFromStub(
    pStub : Void*,   # IRpcStubBuffer*
    pServerIf : RPC_SERVER_INTERFACE*   # RPC_SERVER_INTERFACE* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef NdrCreateServerInterfaceFromStubNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef NdrCreateServerInterfaceFromStubDart = int Function(Pointer<Void>, Pointer<Void>);
final NdrCreateServerInterfaceFromStub = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<NdrCreateServerInterfaceFromStubNative, NdrCreateServerInterfaceFromStubDart>('NdrCreateServerInterfaceFromStub');
// pStub : IRpcStubBuffer* -> Pointer<Void>
// pServerIf : RPC_SERVER_INTERFACE* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NdrCreateServerInterfaceFromStub(
  pStub: Pointer;   // IRpcStubBuffer*
  pServerIf: Pointer   // RPC_SERVER_INTERFACE* in/out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'NdrCreateServerInterfaceFromStub';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NdrCreateServerInterfaceFromStub"
  c_NdrCreateServerInterfaceFromStub :: Ptr () -> Ptr () -> IO Int32
-- pStub : IRpcStubBuffer* -> Ptr ()
-- pServerIf : RPC_SERVER_INTERFACE* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ndrcreateserverinterfacefromstub =
  foreign "NdrCreateServerInterfaceFromStub"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* pStub : IRpcStubBuffer* -> (ptr void) *)
(* pServerIf : RPC_SERVER_INTERFACE* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("NdrCreateServerInterfaceFromStub" ndr-create-server-interface-from-stub :convention :stdcall) :int32
  (p-stub :pointer)   ; IRpcStubBuffer*
  (p-server-if :pointer))   ; RPC_SERVER_INTERFACE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NdrCreateServerInterfaceFromStub = Win32::API::More->new('RPCRT4',
    'int NdrCreateServerInterfaceFromStub(LPVOID pStub, LPVOID pServerIf)');
# my $ret = $NdrCreateServerInterfaceFromStub->Call($pStub, $pServerIf);
# pStub : IRpcStubBuffer* -> LPVOID
# pServerIf : RPC_SERVER_INTERFACE* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型