Win32 API 日本語リファレンス
ホーム › Security.Authentication.Identity › QueryContextAttributesExA

QueryContextAttributesExA

関数
バッファサイズ指定でコンテキスト属性を取得する拡張版である(ANSI版)。
DLLSspiCli.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT QueryContextAttributesExA(
    SecHandle* phContext,
    SECPKG_ATTR ulAttribute,
    void* pBuffer,
    DWORD cbBuffer
);

パラメーター

名前型方向説明
phContextSecHandle*in照会するセキュリティコンテキストへのハンドル。
ulAttributeSECPKG_ATTRin

返されるコンテキストの属性を指定します。このパラメーターには、次のいずれかの値を指定できます。

値 意味
SECPKG_ATTR_ACCESS_TOKEN
18
pBuffer パラメーターには、SecPkgContext_AccessToken 構造体へのポインターが格納されます。

アクセストークンへのハンドルを返します。

SECPKG_ATTR_APP_DATA
0x5e
pBuffer パラメーターには、SecPkgContext_SessionAppData 構造体へのポインターが格納されます。

セッションのアプリケーションデータを返す、または指定します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_AUTHORITY
6
pBuffer パラメーターには、SecPkgContext_Authority 構造体へのポインターが格納されます。

認証を行う機関の名前を照会します。

SECPKG_ATTR_CLIENT_SPECIFIED_TARGET
27
pBuffer パラメーターには、クライアントが指定した最初のターゲットの サービスプリンシパル名 (SPN) を表す SecPkgContext_ClientSpecifiedTarget 構造体へのポインターが格納されます。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

SECPKG_ATTR_CONNECTION_INFO
0x5a
pBuffer パラメーターには、SecPkgContext_ConnectionInfo 構造体へのポインターが格納されます。

確立された接続に関する詳細な情報を返します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_CREDS_2
0x80000086
pBuffer パラメーターには、クライアントの資格情報を指定する SecPkgContext_ClientCreds 構造体へのポインターが格納されます。

クライアントの資格情報がユーザー名とパスワードの場合、バッファーはパックされた KERB_INTERACTIVE_LOGON 構造体です。

クライアントの資格情報がユーザー名とスマートカードの PIN の場合、バッファーはパックされた KERB_CERTIFICATE_LOGON 構造体です。

クライアントの資格情報がオンライン ID の資格情報の場合、バッファーはマーシャリングされた SEC_WINNT_AUTH_IDENTITY_EX2 構造体です。

この属性は CredSSP サーバーでのみサポートされます。

Windows Server 2008 R2、Windows 7、Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

SECPKG_ATTR_DCE_INFO
3
pBuffer パラメーターには、SecPkgContext_DceInfo 構造体へのポインターが格納されます。

DCE サービスで使用される承認データを照会します。

SECPKG_ATTR_ENDPOINT_BINDINGS
26
pBuffer パラメーターには、チャネルバインディング情報を指定する SecPkgContext_Bindings 構造体へのポインターが格納されます。

この属性は Schannel セキュリティパッケージでのみサポートされます。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

SECPKG_ATTR_EAP_KEY_BLOCK
0x5b
pBuffer パラメーターには、SecPkgContext_EapKeyBlock 構造体へのポインターが格納されます。

EAP TLS プロトコルで使用されるキーデータを照会します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_FLAGS
14
pBuffer パラメーターには、SecPkgContext_Flags 構造体へのポインターが格納されます。

ネゴシエートされたコンテキストフラグに関する情報を返します。

SECPKG_ATTR_ISSUER_LIST_EX
0x59
pBuffer パラメーターには、SecPkgContext_IssuerListInfoEx 構造体へのポインターが格納されます。

サーバーが受け入れる証明書発行者の一覧を返します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_KEY_INFO
5
pBuffer パラメーターには、SecPkgContext_KeyInfo 構造体へのポインターが格納されます。

セキュリティコンテキストで使用されるキーに関する情報を照会します。

SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS
30
pBuffer パラメーターには、直近の InitializeSecurityContext 関数の呼び出しによるトークンがクライアントからの最後のトークンであるかどうかを示す SecPkgContext_LastClientTokenStatus 構造体へのポインターが格納されます。

この値は Negotiate、Kerberos、NTLM の各セキュリティパッケージでのみサポートされます。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

SECPKG_ATTR_LIFESPAN
2
pBuffer パラメーターには、SecPkgContext_Lifespan 構造体へのポインターが格納されます。

コンテキストの有効期間を照会します。

SECPKG_ATTR_LOCAL_CERT_CONTEXT
0x54
pBuffer パラメーターには、PCCERT_CONTEXT 構造体へのポインターが格納されます。

ローカルのエンド証明書を含む証明書コンテキストを検索します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_LOCAL_CRED
pBuffer パラメーターには、SecPkgContext_LocalCredentialInfo 構造体へのポインターが格納されます。(廃止)

SECPKG_ATTR_LOCAL_CERT_CONTEXT に置き換えられました。

SECPKG_ATTR_NAMES
1
pBuffer パラメーターには、SecPkgContext_Names 構造体へのポインターが格納されます。

コンテキストに関連付けられている名前を照会します。

SECPKG_ATTR_NATIVE_NAMES
13
pBuffer パラメーターには、SecPkgContext_NativeNames 構造体へのポインターが格納されます。

送信チケットのプリンシパル名 (CNAME) を返します。

SECPKG_ATTR_NEGOTIATION_INFO
12
pBuffer パラメーターには、SecPkgContext_NegotiationInfo 構造体へのポインターが格納されます。

ネゴシエーション処理で使用されるセキュリティパッケージに関する情報と、そのパッケージの使用に関する現在のネゴシエーションの状態を返します。

SECPKG_ATTR_PACKAGE_INFO
10
pBuffer パラメーターには、SecPkgContext_PackageInfo 構造体へのポインターが格納されます。

使用中の SSP に関する情報を返します。

SECPKG_ATTR_PASSWORD_EXPIRY
8
pBuffer パラメーターには、SecPkgContext_PasswordExpiry 構造体へのポインターが格納されます。

パスワードの有効期限に関する情報を返します。

SECPKG_ATTR_REMOTE_CERT_CONTEXT
0x53
pBuffer パラメーターには、PCCERT_CONTEXT 構造体へのポインターが格納されます。

サーバーから提供されたエンド証明書を含む証明書コンテキストを検索します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_ROOT_STORE
0x55
pBuffer パラメーターには、HCERTCONTEXT へのポインターが格納されます。 ルートストアから提供された証明書を含む証明書コンテキストを検索します。
SECPKG_ATTR_SESSION_KEY
9
pBuffer パラメーターには、SecPkgContext_SessionKey 構造体へのポインターが格納されます。

セッションキーに関する情報を返します。

SECPKG_ATTR_SESSION_INFO
0x5d
pBuffer パラメーターには、SecPkgContext_SessionInfo 構造体へのポインターが格納されます。

セッションに関する情報を返します。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_SIZES
0
pBuffer パラメーターには、SecPkgContext_Sizes 構造体へのポインターが格納されます。

メッセージ単位の関数で使用される構造体のサイズを照会します。

SECPKG_ATTR_STREAM_SIZES
4
pBuffer パラメーターには、SecPkgContext_StreamSizes 構造体へのポインターが格納されます。

メッセージ単位の関数で使用されるストリームの各部分のサイズを照会します。

この属性は Schannel セキュリティパッケージでのみサポートされます。

SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES
124
pBuffer パラメーターには、SecPkgContext_SubjectAttributes 構造体へのポインターが格納されます。

この値は、接続のセキュリティ属性に関する情報を返します。

この値は CredSSP サーバーでのみサポートされます。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

SECPKG_ATTR_SUPPORTED_SIGNATURES
0x66
pBuffer パラメーターには、SecPkgContext_SupportedSignatures 構造体へのポインターが格納されます。

この値は、その接続でサポートされる署名の種類に関する情報を返します。

この値は Schannel セキュリティパッケージでのみサポートされます。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

SECPKG_ATTR_TARGET_INFORMATION
17
pBuffer パラメーターには、SecPkgContext_TargetInformation 構造体へのポインターが格納されます。

リモートサーバーの名前に関する情報を返します。

SECPKG_ATTR_UNIQUE_BINDINGS
25
pBuffer パラメーターには、チャネルバインディング情報を指定する SecPkgContext_Bindings 構造体へのポインターが格納されます。

この値は Schannel セキュリティパッケージでのみサポートされます。

Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP: この値はサポートされません。

pBuffervoid*out属性を受け取る構造体へのポインター。指す構造体の型は、ulAttribute パラメーターに指定した値によって異なります。
cbBufferDWORDinpBuffer パラメーターのサイズ (バイト単位)。

戻り値の型: HRESULT

公式ドキュメント

QueryContextAttributesExA (ANSI) 関数 (sspi.h) を使用すると、トランスポートアプリケーションがセキュリティコンテキストの特定の属性をセキュリティパッケージに照会できます。

戻り値

関数が成功した場合、戻り値は SEC_E_OK です。

関数が失敗した場合、戻り値は 0 以外のエラーコードです。

解説(Remarks)

メモ

sspi.h ヘッダーは QueryContextAttributesEx を、UNICODE プリプロセッサ定数の定義に応じてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスの使用と、エンコーディング中立でないコードを混在させると、不整合が生じてコンパイルエラーや実行時エラーの原因となる場合があります。詳細については、「Conventions for Function Prototypes」を参照してください。

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

各言語での呼び出し定義

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

HRESULT QueryContextAttributesExA(
    SecHandle* phContext,
    SECPKG_ATTR ulAttribute,
    void* pBuffer,
    DWORD cbBuffer
);
[DllImport("SspiCli.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int QueryContextAttributesExA(
    IntPtr phContext,   // SecHandle*
    uint ulAttribute,   // SECPKG_ATTR
    IntPtr pBuffer,   // void* out
    uint cbBuffer   // DWORD
);
<DllImport("SspiCli.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function QueryContextAttributesExA(
    phContext As IntPtr,   ' SecHandle*
    ulAttribute As UInteger,   ' SECPKG_ATTR
    pBuffer As IntPtr,   ' void* out
    cbBuffer As UInteger   ' DWORD
) As Integer
End Function
' phContext : SecHandle*
' ulAttribute : SECPKG_ATTR
' pBuffer : void* out
' cbBuffer : DWORD
Declare PtrSafe Function QueryContextAttributesExA Lib "sspicli" ( _
    ByVal phContext As LongPtr, _
    ByVal ulAttribute As Long, _
    ByVal pBuffer As LongPtr, _
    ByVal cbBuffer As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

QueryContextAttributesExA = ctypes.windll.sspicli.QueryContextAttributesExA
QueryContextAttributesExA.restype = ctypes.c_int
QueryContextAttributesExA.argtypes = [
    ctypes.c_void_p,  # phContext : SecHandle*
    wintypes.DWORD,  # ulAttribute : SECPKG_ATTR
    ctypes.POINTER(None),  # pBuffer : void* out
    wintypes.DWORD,  # cbBuffer : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SspiCli.dll')
QueryContextAttributesExA = Fiddle::Function.new(
  lib['QueryContextAttributesExA'],
  [
    Fiddle::TYPE_VOIDP,  # phContext : SecHandle*
    -Fiddle::TYPE_INT,  # ulAttribute : SECPKG_ATTR
    Fiddle::TYPE_VOIDP,  # pBuffer : void* out
    -Fiddle::TYPE_INT,  # cbBuffer : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "sspicli")]
extern "system" {
    fn QueryContextAttributesExA(
        phContext: *mut SecHandle,  // SecHandle*
        ulAttribute: u32,  // SECPKG_ATTR
        pBuffer: *mut (),  // void* out
        cbBuffer: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SspiCli.dll", CharSet = CharSet.Ansi)]
public static extern int QueryContextAttributesExA(IntPtr phContext, uint ulAttribute, IntPtr pBuffer, uint cbBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SspiCli_QueryContextAttributesExA' -Namespace Win32 -PassThru
# $api::QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
#uselib "SspiCli.dll"
#func global QueryContextAttributesExA "QueryContextAttributesExA" sptr, sptr, sptr, sptr
; QueryContextAttributesExA varptr(phContext), ulAttribute, pBuffer, cbBuffer   ; 戻り値は stat
; phContext : SecHandle* -> "sptr"
; ulAttribute : SECPKG_ATTR -> "sptr"
; pBuffer : void* out -> "sptr"
; cbBuffer : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SspiCli.dll"
#cfunc global QueryContextAttributesExA "QueryContextAttributesExA" var, int, sptr, int
; res = QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
; phContext : SecHandle* -> "var"
; ulAttribute : SECPKG_ATTR -> "int"
; pBuffer : void* out -> "sptr"
; cbBuffer : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT QueryContextAttributesExA(SecHandle* phContext, SECPKG_ATTR ulAttribute, void* pBuffer, DWORD cbBuffer)
#uselib "SspiCli.dll"
#cfunc global QueryContextAttributesExA "QueryContextAttributesExA" var, int, intptr, int
; res = QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
; phContext : SecHandle* -> "var"
; ulAttribute : SECPKG_ATTR -> "int"
; pBuffer : void* out -> "intptr"
; cbBuffer : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	sspicli = windows.NewLazySystemDLL("SspiCli.dll")
	procQueryContextAttributesExA = sspicli.NewProc("QueryContextAttributesExA")
)

// phContext (SecHandle*), ulAttribute (SECPKG_ATTR), pBuffer (void* out), cbBuffer (DWORD)
r1, _, err := procQueryContextAttributesExA.Call(
	uintptr(phContext),
	uintptr(ulAttribute),
	uintptr(pBuffer),
	uintptr(cbBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function QueryContextAttributesExA(
  phContext: Pointer;   // SecHandle*
  ulAttribute: DWORD;   // SECPKG_ATTR
  pBuffer: Pointer;   // void* out
  cbBuffer: DWORD   // DWORD
): Integer; stdcall;
  external 'SspiCli.dll' name 'QueryContextAttributesExA';
result := DllCall("SspiCli\QueryContextAttributesExA"
    , "Ptr", phContext   ; SecHandle*
    , "UInt", ulAttribute   ; SECPKG_ATTR
    , "Ptr", pBuffer   ; void* out
    , "UInt", cbBuffer   ; DWORD
    , "Int")   ; return: HRESULT
●QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer) = DLL("SspiCli.dll", "int QueryContextAttributesExA(void*, dword, void*, dword)")
# 呼び出し: QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
# phContext : SecHandle* -> "void*"
# ulAttribute : SECPKG_ATTR -> "dword"
# pBuffer : void* out -> "void*"
# cbBuffer : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "sspicli" fn QueryContextAttributesExA(
    phContext: [*c]SecHandle, // SecHandle*
    ulAttribute: u32, // SECPKG_ATTR
    pBuffer: ?*anyopaque, // void* out
    cbBuffer: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc QueryContextAttributesExA(
    phContext: ptr SecHandle,  # SecHandle*
    ulAttribute: uint32,  # SECPKG_ATTR
    pBuffer: pointer,  # void* out
    cbBuffer: uint32  # DWORD
): int32 {.importc: "QueryContextAttributesExA", stdcall, dynlib: "SspiCli.dll".}
pragma(lib, "sspicli");
extern(Windows)
int QueryContextAttributesExA(
    SecHandle* phContext,   // SecHandle*
    uint ulAttribute,   // SECPKG_ATTR
    void* pBuffer,   // void* out
    uint cbBuffer   // DWORD
);
ccall((:QueryContextAttributesExA, "SspiCli.dll"), stdcall, Int32,
      (Ptr{SecHandle}, UInt32, Ptr{Cvoid}, UInt32),
      phContext, ulAttribute, pBuffer, cbBuffer)
# phContext : SecHandle* -> Ptr{SecHandle}
# ulAttribute : SECPKG_ATTR -> UInt32
# pBuffer : void* out -> Ptr{Cvoid}
# cbBuffer : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t QueryContextAttributesExA(
    void* phContext,
    uint32_t ulAttribute,
    void* pBuffer,
    uint32_t cbBuffer);
]]
local sspicli = ffi.load("sspicli")
-- sspicli.QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
-- phContext : SecHandle*
-- ulAttribute : SECPKG_ATTR
-- pBuffer : void* out
-- cbBuffer : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SspiCli.dll');
const QueryContextAttributesExA = lib.func('__stdcall', 'QueryContextAttributesExA', 'int32_t', ['void *', 'uint32_t', 'void *', 'uint32_t']);
// QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
// phContext : SecHandle* -> 'void *'
// ulAttribute : SECPKG_ATTR -> 'uint32_t'
// pBuffer : void* out -> 'void *'
// cbBuffer : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SspiCli.dll", {
  QueryContextAttributesExA: { parameters: ["pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer)
// phContext : SecHandle* -> "pointer"
// ulAttribute : SECPKG_ATTR -> "u32"
// pBuffer : void* out -> "pointer"
// cbBuffer : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t QueryContextAttributesExA(
    void* phContext,
    uint32_t ulAttribute,
    void* pBuffer,
    uint32_t cbBuffer);
C, "SspiCli.dll");
// $ffi->QueryContextAttributesExA(phContext, ulAttribute, pBuffer, cbBuffer);
// phContext : SecHandle*
// ulAttribute : SECPKG_ATTR
// pBuffer : void* out
// cbBuffer : DWORD
// 構造体/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 Sspicli extends StdCallLibrary {
    Sspicli INSTANCE = Native.load("sspicli", Sspicli.class, W32APIOptions.ASCII_OPTIONS);
    int QueryContextAttributesExA(
        Pointer phContext,   // SecHandle*
        int ulAttribute,   // SECPKG_ATTR
        Pointer pBuffer,   // void* out
        int cbBuffer   // DWORD
    );
}
@[Link("sspicli")]
lib LibSspiCli
  fun QueryContextAttributesExA = QueryContextAttributesExA(
    phContext : SecHandle*,   # SecHandle*
    ulAttribute : UInt32,   # SECPKG_ATTR
    pBuffer : Void*,   # void* out
    cbBuffer : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef QueryContextAttributesExANative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32);
typedef QueryContextAttributesExADart = int Function(Pointer<Void>, int, Pointer<Void>, int);
final QueryContextAttributesExA = DynamicLibrary.open('SspiCli.dll')
    .lookupFunction<QueryContextAttributesExANative, QueryContextAttributesExADart>('QueryContextAttributesExA');
// phContext : SecHandle* -> Pointer<Void>
// ulAttribute : SECPKG_ATTR -> Uint32
// pBuffer : void* out -> Pointer<Void>
// cbBuffer : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function QueryContextAttributesExA(
  phContext: Pointer;   // SecHandle*
  ulAttribute: DWORD;   // SECPKG_ATTR
  pBuffer: Pointer;   // void* out
  cbBuffer: DWORD   // DWORD
): Integer; stdcall;
  external 'SspiCli.dll' name 'QueryContextAttributesExA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "QueryContextAttributesExA"
  c_QueryContextAttributesExA :: Ptr () -> Word32 -> Ptr () -> Word32 -> IO Int32
-- phContext : SecHandle* -> Ptr ()
-- ulAttribute : SECPKG_ATTR -> Word32
-- pBuffer : void* out -> Ptr ()
-- cbBuffer : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let querycontextattributesexa =
  foreign "QueryContextAttributesExA"
    ((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* phContext : SecHandle* -> (ptr void) *)
(* ulAttribute : SECPKG_ATTR -> uint32_t *)
(* pBuffer : void* out -> (ptr void) *)
(* cbBuffer : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library sspicli (t "SspiCli.dll"))
(cffi:use-foreign-library sspicli)

(cffi:defcfun ("QueryContextAttributesExA" query-context-attributes-ex-a :convention :stdcall) :int32
  (ph-context :pointer)   ; SecHandle*
  (ul-attribute :uint32)   ; SECPKG_ATTR
  (p-buffer :pointer)   ; void* out
  (cb-buffer :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $QueryContextAttributesExA = Win32::API::More->new('SspiCli',
    'int QueryContextAttributesExA(LPVOID phContext, DWORD ulAttribute, LPVOID pBuffer, DWORD cbBuffer)');
# my $ret = $QueryContextAttributesExA->Call($phContext, $ulAttribute, $pBuffer, $cbBuffer);
# phContext : SecHandle* -> LPVOID
# ulAttribute : SECPKG_ATTR -> DWORD
# pBuffer : void* out -> LPVOID
# cbBuffer : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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