RpcServerInqCallAttributesW
関数シグネチャ
// RPCRT4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcServerInqCallAttributesW(
void* ClientBinding, // optional
void* RpcCallAttributes
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ClientBinding | void* | inoptional | 省略可能です。サーバールーチン内で明示的バインドを使用する場合、ClientBinding はマネージャールーチンの呼び出しに使用されたバインドハンドルです。「解説」を参照してください。 |
| RpcCallAttributes | void* | inout | 呼び出し属性を受け取る RPC_CALL_ATTRIBUTES_V2 構造体です。 |
戻り値の型: RPC_STATUS
公式ドキュメント
RpcServerInqCallAttributes 関数は、クライアントのセキュリティコンテキスト属性を取得する RPC サーバー呼び出しです。(Unicode)
戻り値
成功した場合は RPC_S_OK を返し、RpcCallAttributes が設定されます。ERROR_MORE_DATA が返された場合は、RpcCallAttributes 内の 1 つ以上のフィールドの長さが不足しており、設定できなかったことを示します。ERROR_MORE_DATA の処理方法の詳細については、 RPC_CALL_ATTRIBUTES_V2 の「解説」を参照してください。
失敗した場合、RpcCallAttributes の内容は未定義であり、RPC によって部分的に変更されている可能性があります。
解説(Remarks)
RpcServerInqCallAttributes 関数は、サフィックス付きの識別子を持つ新しい関数を導入することなく新機能を取り込めるように、バージョン管理方式を採用しています。たとえば、ヘッダー内の単純な #define で識別される RPC_CALL_ATTRIBUTES_V2 の第 2 バージョンでは、RpcServerInqCallAttributesEx という関数をリリースすることなく、将来のバージョンの RpcServerInqCallAttributes 関数に組み込まれる新機能を実現するためのメンバーを追加できます。
RpcServerInqCallAttributes 関数をサーバールーチンの外部で呼び出す場合で、その関数呼び出しが非同期 RPC 呼び出しのセキュリティコンテキスト属性を照会するときは、非同期ハンドルから RpcAsyncGetCallHandle 関数を呼び出すことで ClientBinding を取得できます。
RpcServerInqCallAttributes 関数は、ncadg_* などのデータグラムプロトコルシーケンスではサポートされません。データグラムプロトコルシーケンス上で実行される呼び出しに対して使用した場合は、RPC_S_CANNOT_SUPPORT が返されます。
RpcServerInqCallAttributes 関数はスレッドセーフです。
例
RPC_CALL_ATTRIBUTES CallAttributes; // これは RPC_CALL_ATTRIBUTES_V1 に対応します
memset(&CallAttributes, 0, sizeof(CallAttributes));
CallAttributes.Version = RPC_CALL_ATTRIBUTES_VERSION; // 1 に対応します
CallAttributes.Flags = ;//....
Status = RpcServerInqCallAttributes(0, &ClientContextAttributes);
rpcasync.h ヘッダーは、UNICODE プリプロセッサ定数の定義に応じて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして RpcServerInqCallAttributes を定義します。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因になることがあります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// RPCRT4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcServerInqCallAttributesW(
void* ClientBinding, // optional
void* RpcCallAttributes
);[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcServerInqCallAttributesW(
IntPtr ClientBinding, // void* optional
IntPtr RpcCallAttributes // void* in/out
);<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcServerInqCallAttributesW(
ClientBinding As IntPtr, ' void* optional
RpcCallAttributes As IntPtr ' void* in/out
) As Integer
End Function' ClientBinding : void* optional
' RpcCallAttributes : void* in/out
Declare PtrSafe Function RpcServerInqCallAttributesW Lib "rpcrt4" ( _
ByVal ClientBinding As LongPtr, _
ByVal RpcCallAttributes As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcServerInqCallAttributesW = ctypes.windll.rpcrt4.RpcServerInqCallAttributesW
RpcServerInqCallAttributesW.restype = ctypes.c_int
RpcServerInqCallAttributesW.argtypes = [
ctypes.POINTER(None), # ClientBinding : void* optional
ctypes.POINTER(None), # RpcCallAttributes : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
RpcServerInqCallAttributesW = Fiddle::Function.new(
lib['RpcServerInqCallAttributesW'],
[
Fiddle::TYPE_VOIDP, # ClientBinding : void* optional
Fiddle::TYPE_VOIDP, # RpcCallAttributes : void* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rpcrt4")]
extern "system" {
fn RpcServerInqCallAttributesW(
ClientBinding: *mut (), // void* optional
RpcCallAttributes: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcServerInqCallAttributesW(IntPtr ClientBinding, IntPtr RpcCallAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcServerInqCallAttributesW' -Namespace Win32 -PassThru
# $api::RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)#uselib "RPCRT4.dll"
#func global RpcServerInqCallAttributesW "RpcServerInqCallAttributesW" wptr, wptr
; RpcServerInqCallAttributesW ClientBinding, RpcCallAttributes ; 戻り値は stat
; ClientBinding : void* optional -> "wptr"
; RpcCallAttributes : void* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCRT4.dll"
#cfunc global RpcServerInqCallAttributesW "RpcServerInqCallAttributesW" sptr, sptr
; res = RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)
; ClientBinding : void* optional -> "sptr"
; RpcCallAttributes : void* in/out -> "sptr"; RPC_STATUS RpcServerInqCallAttributesW(void* ClientBinding, void* RpcCallAttributes)
#uselib "RPCRT4.dll"
#cfunc global RpcServerInqCallAttributesW "RpcServerInqCallAttributesW" intptr, intptr
; res = RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)
; ClientBinding : void* optional -> "intptr"
; RpcCallAttributes : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procRpcServerInqCallAttributesW = rpcrt4.NewProc("RpcServerInqCallAttributesW")
)
// ClientBinding (void* optional), RpcCallAttributes (void* in/out)
r1, _, err := procRpcServerInqCallAttributesW.Call(
uintptr(ClientBinding),
uintptr(RpcCallAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcServerInqCallAttributesW(
ClientBinding: Pointer; // void* optional
RpcCallAttributes: Pointer // void* in/out
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcServerInqCallAttributesW';result := DllCall("RPCRT4\RpcServerInqCallAttributesW"
, "Ptr", ClientBinding ; void* optional
, "Ptr", RpcCallAttributes ; void* in/out
, "Int") ; return: RPC_STATUS●RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes) = DLL("RPCRT4.dll", "int RpcServerInqCallAttributesW(void*, void*)")
# 呼び出し: RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)
# ClientBinding : void* optional -> "void*"
# RpcCallAttributes : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "rpcrt4" fn RpcServerInqCallAttributesW(
ClientBinding: ?*anyopaque, // void* optional
RpcCallAttributes: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc RpcServerInqCallAttributesW(
ClientBinding: pointer, # void* optional
RpcCallAttributes: pointer # void* in/out
): int32 {.importc: "RpcServerInqCallAttributesW", stdcall, dynlib: "RPCRT4.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "rpcrt4");
extern(Windows)
int RpcServerInqCallAttributesW(
void* ClientBinding, // void* optional
void* RpcCallAttributes // void* in/out
);ccall((:RpcServerInqCallAttributesW, "RPCRT4.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}),
ClientBinding, RpcCallAttributes)
# ClientBinding : void* optional -> Ptr{Cvoid}
# RpcCallAttributes : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcServerInqCallAttributesW(
void* ClientBinding,
void* RpcCallAttributes);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)
-- ClientBinding : void* optional
-- RpcCallAttributes : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcServerInqCallAttributesW = lib.func('__stdcall', 'RpcServerInqCallAttributesW', 'int32_t', ['void *', 'void *']);
// RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)
// ClientBinding : void* optional -> 'void *'
// RpcCallAttributes : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCRT4.dll", {
RpcServerInqCallAttributesW: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes)
// ClientBinding : void* optional -> "pointer"
// RpcCallAttributes : void* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcServerInqCallAttributesW(
void* ClientBinding,
void* RpcCallAttributes);
C, "RPCRT4.dll");
// $ffi->RpcServerInqCallAttributesW(ClientBinding, RpcCallAttributes);
// ClientBinding : void* optional
// RpcCallAttributes : void* 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, W32APIOptions.UNICODE_OPTIONS);
int RpcServerInqCallAttributesW(
Pointer ClientBinding, // void* optional
Pointer RpcCallAttributes // void* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("rpcrt4")]
lib LibRPCRT4
fun RpcServerInqCallAttributesW = RpcServerInqCallAttributesW(
ClientBinding : Void*, # void* optional
RpcCallAttributes : Void* # void* 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 RpcServerInqCallAttributesWNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef RpcServerInqCallAttributesWDart = int Function(Pointer<Void>, Pointer<Void>);
final RpcServerInqCallAttributesW = DynamicLibrary.open('RPCRT4.dll')
.lookupFunction<RpcServerInqCallAttributesWNative, RpcServerInqCallAttributesWDart>('RpcServerInqCallAttributesW');
// ClientBinding : void* optional -> Pointer<Void>
// RpcCallAttributes : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcServerInqCallAttributesW(
ClientBinding: Pointer; // void* optional
RpcCallAttributes: Pointer // void* in/out
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcServerInqCallAttributesW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcServerInqCallAttributesW"
c_RpcServerInqCallAttributesW :: Ptr () -> Ptr () -> IO Int32
-- ClientBinding : void* optional -> Ptr ()
-- RpcCallAttributes : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcserverinqcallattributesw =
foreign "RpcServerInqCallAttributesW"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* ClientBinding : void* optional -> (ptr void) *)
(* RpcCallAttributes : void* 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 ("RpcServerInqCallAttributesW" rpc-server-inq-call-attributes-w :convention :stdcall) :int32
(client-binding :pointer) ; void* optional
(rpc-call-attributes :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcServerInqCallAttributesW = Win32::API::More->new('RPCRT4',
'int RpcServerInqCallAttributesW(LPVOID ClientBinding, LPVOID RpcCallAttributes)');
# my $ret = $RpcServerInqCallAttributesW->Call($ClientBinding, $RpcCallAttributes);
# ClientBinding : void* optional -> LPVOID
# RpcCallAttributes : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f RpcServerInqCallAttributesA (ANSI版) — サーバー側で現在のRPC呼び出しの属性を照会する(ANSI版)。