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

RpcServerInqCallAttributesA

関数
サーバー側で現在のRPC呼び出しの属性を照会する(ANSI版)。
DLLRPCRT4.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// RPCRT4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcServerInqCallAttributesA(
    void* ClientBinding,   // optional
    void* RpcCallAttributes
);

パラメーター

名前方向説明
ClientBindingvoid*inoptional省略可能。サーバールーチン内で明示的バインドを使用する場合、ClientBinding はマネージャールーチンの呼び出しに使用されたバインディングハンドルです。「解説」を参照してください。
RpcCallAttributesvoid*inout呼び出し属性を受け取る RPC_CALL_ATTRIBUTES_V2 構造体です。

戻り値の型: RPC_STATUS

公式ドキュメント

RpcServerInqCallAttributes 関数は、クライアントのセキュリティコンテキスト属性を取得する RPC サーバー呼び出しです。(ANSI)

戻り値

成功した場合は RPC_S_OK を返し、RpcCallAttributes が設定されます。ERROR_MORE_DATA が返された場合は、RpcCallAttributes 内の 1 つ以上のフィールドの長さが不足しており、設定できなかったことを示します。ERROR_MORE_DATA の処理方法の詳細については、 RPC_CALL_ATTRIBUTES_V2 の「解説」を参照してください。

失敗した場合、RpcCallAttributes の内容は未定義であり、RPC によって部分的に変更されている可能性があります。

注意 有効なエラーコードの一覧については、 RPC Return Values を参照してください。

解説(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;  // this maps to RPC_CALL_ATTRIBUTES_V1

memset(&CallAttributes, 0, sizeof(CallAttributes));
CallAttributes.Version = RPC_CALL_ATTRIBUTES_VERSION;    // maps to 1
CallAttributes.Flags = ;//....
Status = RpcServerInqCallAttributes(0, &ClientContextAttributes);
メモ

rpcasync.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして RpcServerInqCallAttributes を定義しています。エンコーディング中立でないコードでエンコーディング中立のエイリアスを使用すると、不整合が生じてコンパイルエラーまたは実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// RPCRT4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcServerInqCallAttributesA(
    void* ClientBinding,   // optional
    void* RpcCallAttributes
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcServerInqCallAttributesA(
    IntPtr ClientBinding,   // void* optional
    IntPtr RpcCallAttributes   // void* in/out
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcServerInqCallAttributesA(
    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 RpcServerInqCallAttributesA Lib "rpcrt4" ( _
    ByVal ClientBinding As LongPtr, _
    ByVal RpcCallAttributes As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcServerInqCallAttributesA = ctypes.windll.rpcrt4.RpcServerInqCallAttributesA
RpcServerInqCallAttributesA.restype = ctypes.c_int
RpcServerInqCallAttributesA.argtypes = [
    ctypes.POINTER(None),  # ClientBinding : void* optional
    ctypes.POINTER(None),  # RpcCallAttributes : void* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
RpcServerInqCallAttributesA = Fiddle::Function.new(
  lib['RpcServerInqCallAttributesA'],
  [
    Fiddle::TYPE_VOIDP,  # ClientBinding : void* optional
    Fiddle::TYPE_VOIDP,  # RpcCallAttributes : void* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcServerInqCallAttributesA(
        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.Ansi)]
public static extern int RpcServerInqCallAttributesA(IntPtr ClientBinding, IntPtr RpcCallAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcServerInqCallAttributesA' -Namespace Win32 -PassThru
# $api::RpcServerInqCallAttributesA(ClientBinding, RpcCallAttributes)
#uselib "RPCRT4.dll"
#func global RpcServerInqCallAttributesA "RpcServerInqCallAttributesA" sptr, sptr
; RpcServerInqCallAttributesA ClientBinding, RpcCallAttributes   ; 戻り値は stat
; ClientBinding : void* optional -> "sptr"
; RpcCallAttributes : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RPCRT4.dll"
#cfunc global RpcServerInqCallAttributesA "RpcServerInqCallAttributesA" sptr, sptr
; res = RpcServerInqCallAttributesA(ClientBinding, RpcCallAttributes)
; ClientBinding : void* optional -> "sptr"
; RpcCallAttributes : void* in/out -> "sptr"
; RPC_STATUS RpcServerInqCallAttributesA(void* ClientBinding, void* RpcCallAttributes)
#uselib "RPCRT4.dll"
#cfunc global RpcServerInqCallAttributesA "RpcServerInqCallAttributesA" intptr, intptr
; res = RpcServerInqCallAttributesA(ClientBinding, RpcCallAttributes)
; ClientBinding : void* optional -> "intptr"
; RpcCallAttributes : void* in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcServerInqCallAttributesA = rpcrt4.NewProc("RpcServerInqCallAttributesA")
)

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

extern "rpcrt4" fn RpcServerInqCallAttributesA(
    ClientBinding: ?*anyopaque, // void* optional
    RpcCallAttributes: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;
proc RpcServerInqCallAttributesA(
    ClientBinding: pointer,  # void* optional
    RpcCallAttributes: pointer  # void* in/out
): int32 {.importc: "RpcServerInqCallAttributesA", stdcall, dynlib: "RPCRT4.dll".}
pragma(lib, "rpcrt4");
extern(Windows)
int RpcServerInqCallAttributesA(
    void* ClientBinding,   // void* optional
    void* RpcCallAttributes   // void* in/out
);
ccall((:RpcServerInqCallAttributesA, "RPCRT4.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}),
      ClientBinding, RpcCallAttributes)
# ClientBinding : void* optional -> Ptr{Cvoid}
# RpcCallAttributes : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcServerInqCallAttributesA(
    void* ClientBinding,
    void* RpcCallAttributes);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcServerInqCallAttributesA(ClientBinding, RpcCallAttributes)
-- ClientBinding : void* optional
-- RpcCallAttributes : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcServerInqCallAttributesA = lib.func('__stdcall', 'RpcServerInqCallAttributesA', 'int32_t', ['void *', 'void *']);
// RpcServerInqCallAttributesA(ClientBinding, RpcCallAttributes)
// ClientBinding : void* optional -> 'void *'
// RpcCallAttributes : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RPCRT4.dll", {
  RpcServerInqCallAttributesA: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.RpcServerInqCallAttributesA(ClientBinding, RpcCallAttributes)
// ClientBinding : void* optional -> "pointer"
// RpcCallAttributes : void* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcServerInqCallAttributesA(
    void* ClientBinding,
    void* RpcCallAttributes);
C, "RPCRT4.dll");
// $ffi->RpcServerInqCallAttributesA(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.ASCII_OPTIONS);
    int RpcServerInqCallAttributesA(
        Pointer ClientBinding,   // void* optional
        Pointer RpcCallAttributes   // void* in/out
    );
}
@[Link("rpcrt4")]
lib LibRPCRT4
  fun RpcServerInqCallAttributesA = RpcServerInqCallAttributesA(
    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 RpcServerInqCallAttributesANative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef RpcServerInqCallAttributesADart = int Function(Pointer<Void>, Pointer<Void>);
final RpcServerInqCallAttributesA = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<RpcServerInqCallAttributesANative, RpcServerInqCallAttributesADart>('RpcServerInqCallAttributesA');
// ClientBinding : void* optional -> Pointer<Void>
// RpcCallAttributes : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RpcServerInqCallAttributesA(
  ClientBinding: Pointer;   // void* optional
  RpcCallAttributes: Pointer   // void* in/out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcServerInqCallAttributesA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcServerInqCallAttributesA"
  c_RpcServerInqCallAttributesA :: 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 rpcserverinqcallattributesa =
  foreign "RpcServerInqCallAttributesA"
    ((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 ("RpcServerInqCallAttributesA" rpc-server-inq-call-attributes-a :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 $RpcServerInqCallAttributesA = Win32::API::More->new('RPCRT4',
    'int RpcServerInqCallAttributesA(LPVOID ClientBinding, LPVOID RpcCallAttributes)');
# my $ret = $RpcServerInqCallAttributesA->Call($ClientBinding, $RpcCallAttributes);
# ClientBinding : void* optional -> LPVOID
# RpcCallAttributes : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
公式の関連項目
使用する型