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

SaslAcceptSecurityContext

関数
SASL用サーバー側セキュリティコンテキストを受け入れ確立する。
DLLSECUR32.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

HRESULT SaslAcceptSecurityContext(
    SecHandle* phCredential,   // optional
    SecHandle* phContext,   // optional
    SecBufferDesc* pInput,   // optional
    ASC_REQ_FLAGS fContextReq,
    DWORD TargetDataRep,
    SecHandle* phNewContext,   // optional
    SecBufferDesc* pOutput,   // optional
    DWORD* pfContextAttr,
    LONGLONG* ptsExpiry   // optional
);

パラメーター

名前方向説明
phCredentialSecHandle*inoptionalAcquireCredentialsHandleで取得したサーバー側資格情報ハンドルへのポインタ。
phContextSecHandle*inoptional継続中のセキュリティコンテキストハンドルへのポインタ。初回呼び出し時はNULL。
pInputSecBufferDesc*inoptionalクライアントから受信した入力トークンを保持するSecBufferDescへのポインタ。
fContextReqASC_REQ_FLAGSinコンテキストに要求する属性を示すASC_REQ_FLAGSフラグ。
TargetDataRepDWORDinクライアントのデータ表現形式を示す値(SECURITY_NATIVE_DREP等)。
phNewContextSecHandle*inoutoptional出力。新規または更新されたセキュリティコンテキストハンドルを受け取るポインタ。
pOutputSecBufferDesc*inoutoptional出力。クライアントへ返す出力トークンを受け取るSecBufferDescへのポインタ。
pfContextAttrDWORD*out出力。確立されたコンテキストの属性フラグを受け取るDWORDへのポインタ。
ptsExpiryLONGLONG*outoptional出力。コンテキストの有効期限を受け取るポインタ。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SaslAcceptSecurityContext(
    SecHandle* phCredential,   // optional
    SecHandle* phContext,   // optional
    SecBufferDesc* pInput,   // optional
    ASC_REQ_FLAGS fContextReq,
    DWORD TargetDataRep,
    SecHandle* phNewContext,   // optional
    SecBufferDesc* pOutput,   // optional
    DWORD* pfContextAttr,
    LONGLONG* ptsExpiry   // optional
);
[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int SaslAcceptSecurityContext(
    IntPtr phCredential,   // SecHandle* optional
    IntPtr phContext,   // SecHandle* optional
    IntPtr pInput,   // SecBufferDesc* optional
    uint fContextReq,   // ASC_REQ_FLAGS
    uint TargetDataRep,   // DWORD
    IntPtr phNewContext,   // SecHandle* optional, in/out
    IntPtr pOutput,   // SecBufferDesc* optional, in/out
    out uint pfContextAttr,   // DWORD* out
    IntPtr ptsExpiry   // LONGLONG* optional, out
);
<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function SaslAcceptSecurityContext(
    phCredential As IntPtr,   ' SecHandle* optional
    phContext As IntPtr,   ' SecHandle* optional
    pInput As IntPtr,   ' SecBufferDesc* optional
    fContextReq As UInteger,   ' ASC_REQ_FLAGS
    TargetDataRep As UInteger,   ' DWORD
    phNewContext As IntPtr,   ' SecHandle* optional, in/out
    pOutput As IntPtr,   ' SecBufferDesc* optional, in/out
    <Out> ByRef pfContextAttr As UInteger,   ' DWORD* out
    ptsExpiry As IntPtr   ' LONGLONG* optional, out
) As Integer
End Function
' phCredential : SecHandle* optional
' phContext : SecHandle* optional
' pInput : SecBufferDesc* optional
' fContextReq : ASC_REQ_FLAGS
' TargetDataRep : DWORD
' phNewContext : SecHandle* optional, in/out
' pOutput : SecBufferDesc* optional, in/out
' pfContextAttr : DWORD* out
' ptsExpiry : LONGLONG* optional, out
Declare PtrSafe Function SaslAcceptSecurityContext Lib "secur32" ( _
    ByVal phCredential As LongPtr, _
    ByVal phContext As LongPtr, _
    ByVal pInput As LongPtr, _
    ByVal fContextReq As Long, _
    ByVal TargetDataRep As Long, _
    ByVal phNewContext As LongPtr, _
    ByVal pOutput As LongPtr, _
    ByRef pfContextAttr As Long, _
    ByVal ptsExpiry As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SaslAcceptSecurityContext = ctypes.windll.secur32.SaslAcceptSecurityContext
SaslAcceptSecurityContext.restype = ctypes.c_int
SaslAcceptSecurityContext.argtypes = [
    ctypes.c_void_p,  # phCredential : SecHandle* optional
    ctypes.c_void_p,  # phContext : SecHandle* optional
    ctypes.c_void_p,  # pInput : SecBufferDesc* optional
    wintypes.DWORD,  # fContextReq : ASC_REQ_FLAGS
    wintypes.DWORD,  # TargetDataRep : DWORD
    ctypes.c_void_p,  # phNewContext : SecHandle* optional, in/out
    ctypes.c_void_p,  # pOutput : SecBufferDesc* optional, in/out
    ctypes.POINTER(wintypes.DWORD),  # pfContextAttr : DWORD* out
    ctypes.POINTER(ctypes.c_longlong),  # ptsExpiry : LONGLONG* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	secur32 = windows.NewLazySystemDLL("SECUR32.dll")
	procSaslAcceptSecurityContext = secur32.NewProc("SaslAcceptSecurityContext")
)

// phCredential (SecHandle* optional), phContext (SecHandle* optional), pInput (SecBufferDesc* optional), fContextReq (ASC_REQ_FLAGS), TargetDataRep (DWORD), phNewContext (SecHandle* optional, in/out), pOutput (SecBufferDesc* optional, in/out), pfContextAttr (DWORD* out), ptsExpiry (LONGLONG* optional, out)
r1, _, err := procSaslAcceptSecurityContext.Call(
	uintptr(phCredential),
	uintptr(phContext),
	uintptr(pInput),
	uintptr(fContextReq),
	uintptr(TargetDataRep),
	uintptr(phNewContext),
	uintptr(pOutput),
	uintptr(pfContextAttr),
	uintptr(ptsExpiry),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SaslAcceptSecurityContext(
  phCredential: Pointer;   // SecHandle* optional
  phContext: Pointer;   // SecHandle* optional
  pInput: Pointer;   // SecBufferDesc* optional
  fContextReq: DWORD;   // ASC_REQ_FLAGS
  TargetDataRep: DWORD;   // DWORD
  phNewContext: Pointer;   // SecHandle* optional, in/out
  pOutput: Pointer;   // SecBufferDesc* optional, in/out
  pfContextAttr: Pointer;   // DWORD* out
  ptsExpiry: Pointer   // LONGLONG* optional, out
): Integer; stdcall;
  external 'SECUR32.dll' name 'SaslAcceptSecurityContext';
result := DllCall("SECUR32\SaslAcceptSecurityContext"
    , "Ptr", phCredential   ; SecHandle* optional
    , "Ptr", phContext   ; SecHandle* optional
    , "Ptr", pInput   ; SecBufferDesc* optional
    , "UInt", fContextReq   ; ASC_REQ_FLAGS
    , "UInt", TargetDataRep   ; DWORD
    , "Ptr", phNewContext   ; SecHandle* optional, in/out
    , "Ptr", pOutput   ; SecBufferDesc* optional, in/out
    , "Ptr", pfContextAttr   ; DWORD* out
    , "Ptr", ptsExpiry   ; LONGLONG* optional, out
    , "Int")   ; return: HRESULT
●SaslAcceptSecurityContext(phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry) = DLL("SECUR32.dll", "int SaslAcceptSecurityContext(void*, void*, void*, dword, dword, void*, void*, void*, void*)")
# 呼び出し: SaslAcceptSecurityContext(phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry)
# phCredential : SecHandle* optional -> "void*"
# phContext : SecHandle* optional -> "void*"
# pInput : SecBufferDesc* optional -> "void*"
# fContextReq : ASC_REQ_FLAGS -> "dword"
# TargetDataRep : DWORD -> "dword"
# phNewContext : SecHandle* optional, in/out -> "void*"
# pOutput : SecBufferDesc* optional, in/out -> "void*"
# pfContextAttr : DWORD* out -> "void*"
# ptsExpiry : LONGLONG* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "secur32" fn SaslAcceptSecurityContext(
    phCredential: [*c]SecHandle, // SecHandle* optional
    phContext: [*c]SecHandle, // SecHandle* optional
    pInput: [*c]SecBufferDesc, // SecBufferDesc* optional
    fContextReq: u32, // ASC_REQ_FLAGS
    TargetDataRep: u32, // DWORD
    phNewContext: [*c]SecHandle, // SecHandle* optional, in/out
    pOutput: [*c]SecBufferDesc, // SecBufferDesc* optional, in/out
    pfContextAttr: [*c]u32, // DWORD* out
    ptsExpiry: [*c]i64 // LONGLONG* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc SaslAcceptSecurityContext(
    phCredential: ptr SecHandle,  # SecHandle* optional
    phContext: ptr SecHandle,  # SecHandle* optional
    pInput: ptr SecBufferDesc,  # SecBufferDesc* optional
    fContextReq: uint32,  # ASC_REQ_FLAGS
    TargetDataRep: uint32,  # DWORD
    phNewContext: ptr SecHandle,  # SecHandle* optional, in/out
    pOutput: ptr SecBufferDesc,  # SecBufferDesc* optional, in/out
    pfContextAttr: ptr uint32,  # DWORD* out
    ptsExpiry: ptr int64  # LONGLONG* optional, out
): int32 {.importc: "SaslAcceptSecurityContext", stdcall, dynlib: "SECUR32.dll".}
pragma(lib, "secur32");
extern(Windows)
int SaslAcceptSecurityContext(
    SecHandle* phCredential,   // SecHandle* optional
    SecHandle* phContext,   // SecHandle* optional
    SecBufferDesc* pInput,   // SecBufferDesc* optional
    uint fContextReq,   // ASC_REQ_FLAGS
    uint TargetDataRep,   // DWORD
    SecHandle* phNewContext,   // SecHandle* optional, in/out
    SecBufferDesc* pOutput,   // SecBufferDesc* optional, in/out
    uint* pfContextAttr,   // DWORD* out
    long* ptsExpiry   // LONGLONG* optional, out
);
ccall((:SaslAcceptSecurityContext, "SECUR32.dll"), stdcall, Int32,
      (Ptr{SecHandle}, Ptr{SecHandle}, Ptr{SecBufferDesc}, UInt32, UInt32, Ptr{SecHandle}, Ptr{SecBufferDesc}, Ptr{UInt32}, Ptr{Int64}),
      phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry)
# phCredential : SecHandle* optional -> Ptr{SecHandle}
# phContext : SecHandle* optional -> Ptr{SecHandle}
# pInput : SecBufferDesc* optional -> Ptr{SecBufferDesc}
# fContextReq : ASC_REQ_FLAGS -> UInt32
# TargetDataRep : DWORD -> UInt32
# phNewContext : SecHandle* optional, in/out -> Ptr{SecHandle}
# pOutput : SecBufferDesc* optional, in/out -> Ptr{SecBufferDesc}
# pfContextAttr : DWORD* out -> Ptr{UInt32}
# ptsExpiry : LONGLONG* optional, out -> Ptr{Int64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SaslAcceptSecurityContext(
    void* phCredential,
    void* phContext,
    void* pInput,
    uint32_t fContextReq,
    uint32_t TargetDataRep,
    void* phNewContext,
    void* pOutput,
    uint32_t* pfContextAttr,
    int64_t* ptsExpiry);
]]
local secur32 = ffi.load("secur32")
-- secur32.SaslAcceptSecurityContext(phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry)
-- phCredential : SecHandle* optional
-- phContext : SecHandle* optional
-- pInput : SecBufferDesc* optional
-- fContextReq : ASC_REQ_FLAGS
-- TargetDataRep : DWORD
-- phNewContext : SecHandle* optional, in/out
-- pOutput : SecBufferDesc* optional, in/out
-- pfContextAttr : DWORD* out
-- ptsExpiry : LONGLONG* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SECUR32.dll');
const SaslAcceptSecurityContext = lib.func('__stdcall', 'SaslAcceptSecurityContext', 'int32_t', ['void *', 'void *', 'void *', 'uint32_t', 'uint32_t', 'void *', 'void *', 'uint32_t *', 'int64_t *']);
// SaslAcceptSecurityContext(phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry)
// phCredential : SecHandle* optional -> 'void *'
// phContext : SecHandle* optional -> 'void *'
// pInput : SecBufferDesc* optional -> 'void *'
// fContextReq : ASC_REQ_FLAGS -> 'uint32_t'
// TargetDataRep : DWORD -> 'uint32_t'
// phNewContext : SecHandle* optional, in/out -> 'void *'
// pOutput : SecBufferDesc* optional, in/out -> 'void *'
// pfContextAttr : DWORD* out -> 'uint32_t *'
// ptsExpiry : LONGLONG* optional, out -> 'int64_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SECUR32.dll", {
  SaslAcceptSecurityContext: { parameters: ["pointer", "pointer", "pointer", "u32", "u32", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SaslAcceptSecurityContext(phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry)
// phCredential : SecHandle* optional -> "pointer"
// phContext : SecHandle* optional -> "pointer"
// pInput : SecBufferDesc* optional -> "pointer"
// fContextReq : ASC_REQ_FLAGS -> "u32"
// TargetDataRep : DWORD -> "u32"
// phNewContext : SecHandle* optional, in/out -> "pointer"
// pOutput : SecBufferDesc* optional, in/out -> "pointer"
// pfContextAttr : DWORD* out -> "pointer"
// ptsExpiry : LONGLONG* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SaslAcceptSecurityContext(
    void* phCredential,
    void* phContext,
    void* pInput,
    uint32_t fContextReq,
    uint32_t TargetDataRep,
    void* phNewContext,
    void* pOutput,
    uint32_t* pfContextAttr,
    int64_t* ptsExpiry);
C, "SECUR32.dll");
// $ffi->SaslAcceptSecurityContext(phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsExpiry);
// phCredential : SecHandle* optional
// phContext : SecHandle* optional
// pInput : SecBufferDesc* optional
// fContextReq : ASC_REQ_FLAGS
// TargetDataRep : DWORD
// phNewContext : SecHandle* optional, in/out
// pOutput : SecBufferDesc* optional, in/out
// pfContextAttr : DWORD* out
// ptsExpiry : LONGLONG* optional, 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 Secur32 extends StdCallLibrary {
    Secur32 INSTANCE = Native.load("secur32", Secur32.class);
    int SaslAcceptSecurityContext(
        Pointer phCredential,   // SecHandle* optional
        Pointer phContext,   // SecHandle* optional
        Pointer pInput,   // SecBufferDesc* optional
        int fContextReq,   // ASC_REQ_FLAGS
        int TargetDataRep,   // DWORD
        Pointer phNewContext,   // SecHandle* optional, in/out
        Pointer pOutput,   // SecBufferDesc* optional, in/out
        IntByReference pfContextAttr,   // DWORD* out
        LongByReference ptsExpiry   // LONGLONG* optional, out
    );
}
@[Link("secur32")]
lib LibSECUR32
  fun SaslAcceptSecurityContext = SaslAcceptSecurityContext(
    phCredential : SecHandle*,   # SecHandle* optional
    phContext : SecHandle*,   # SecHandle* optional
    pInput : SecBufferDesc*,   # SecBufferDesc* optional
    fContextReq : UInt32,   # ASC_REQ_FLAGS
    TargetDataRep : UInt32,   # DWORD
    phNewContext : SecHandle*,   # SecHandle* optional, in/out
    pOutput : SecBufferDesc*,   # SecBufferDesc* optional, in/out
    pfContextAttr : UInt32*,   # DWORD* out
    ptsExpiry : Int64*   # LONGLONG* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SaslAcceptSecurityContextNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Int64>);
typedef SaslAcceptSecurityContextDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Int64>);
final SaslAcceptSecurityContext = DynamicLibrary.open('SECUR32.dll')
    .lookupFunction<SaslAcceptSecurityContextNative, SaslAcceptSecurityContextDart>('SaslAcceptSecurityContext');
// phCredential : SecHandle* optional -> Pointer<Void>
// phContext : SecHandle* optional -> Pointer<Void>
// pInput : SecBufferDesc* optional -> Pointer<Void>
// fContextReq : ASC_REQ_FLAGS -> Uint32
// TargetDataRep : DWORD -> Uint32
// phNewContext : SecHandle* optional, in/out -> Pointer<Void>
// pOutput : SecBufferDesc* optional, in/out -> Pointer<Void>
// pfContextAttr : DWORD* out -> Pointer<Uint32>
// ptsExpiry : LONGLONG* optional, out -> Pointer<Int64>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SaslAcceptSecurityContext(
  phCredential: Pointer;   // SecHandle* optional
  phContext: Pointer;   // SecHandle* optional
  pInput: Pointer;   // SecBufferDesc* optional
  fContextReq: DWORD;   // ASC_REQ_FLAGS
  TargetDataRep: DWORD;   // DWORD
  phNewContext: Pointer;   // SecHandle* optional, in/out
  pOutput: Pointer;   // SecBufferDesc* optional, in/out
  pfContextAttr: Pointer;   // DWORD* out
  ptsExpiry: Pointer   // LONGLONG* optional, out
): Integer; stdcall;
  external 'SECUR32.dll' name 'SaslAcceptSecurityContext';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SaslAcceptSecurityContext"
  c_SaslAcceptSecurityContext :: Ptr () -> Ptr () -> Ptr () -> Word32 -> Word32 -> Ptr () -> Ptr () -> Ptr Word32 -> Ptr Int64 -> IO Int32
-- phCredential : SecHandle* optional -> Ptr ()
-- phContext : SecHandle* optional -> Ptr ()
-- pInput : SecBufferDesc* optional -> Ptr ()
-- fContextReq : ASC_REQ_FLAGS -> Word32
-- TargetDataRep : DWORD -> Word32
-- phNewContext : SecHandle* optional, in/out -> Ptr ()
-- pOutput : SecBufferDesc* optional, in/out -> Ptr ()
-- pfContextAttr : DWORD* out -> Ptr Word32
-- ptsExpiry : LONGLONG* optional, out -> Ptr Int64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let saslacceptsecuritycontext =
  foreign "SaslAcceptSecurityContext"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr int64_t) @-> returning int32_t)
(* phCredential : SecHandle* optional -> (ptr void) *)
(* phContext : SecHandle* optional -> (ptr void) *)
(* pInput : SecBufferDesc* optional -> (ptr void) *)
(* fContextReq : ASC_REQ_FLAGS -> uint32_t *)
(* TargetDataRep : DWORD -> uint32_t *)
(* phNewContext : SecHandle* optional, in/out -> (ptr void) *)
(* pOutput : SecBufferDesc* optional, in/out -> (ptr void) *)
(* pfContextAttr : DWORD* out -> (ptr uint32_t) *)
(* ptsExpiry : LONGLONG* optional, out -> (ptr int64_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library secur32 (t "SECUR32.dll"))
(cffi:use-foreign-library secur32)

(cffi:defcfun ("SaslAcceptSecurityContext" sasl-accept-security-context :convention :stdcall) :int32
  (ph-credential :pointer)   ; SecHandle* optional
  (ph-context :pointer)   ; SecHandle* optional
  (p-input :pointer)   ; SecBufferDesc* optional
  (f-context-req :uint32)   ; ASC_REQ_FLAGS
  (target-data-rep :uint32)   ; DWORD
  (ph-new-context :pointer)   ; SecHandle* optional, in/out
  (p-output :pointer)   ; SecBufferDesc* optional, in/out
  (pf-context-attr :pointer)   ; DWORD* out
  (pts-expiry :pointer))   ; LONGLONG* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SaslAcceptSecurityContext = Win32::API::More->new('SECUR32',
    'int SaslAcceptSecurityContext(LPVOID phCredential, LPVOID phContext, LPVOID pInput, DWORD fContextReq, DWORD TargetDataRep, LPVOID phNewContext, LPVOID pOutput, LPVOID pfContextAttr, LPVOID ptsExpiry)');
# my $ret = $SaslAcceptSecurityContext->Call($phCredential, $phContext, $pInput, $fContextReq, $TargetDataRep, $phNewContext, $pOutput, $pfContextAttr, $ptsExpiry);
# phCredential : SecHandle* optional -> LPVOID
# phContext : SecHandle* optional -> LPVOID
# pInput : SecBufferDesc* optional -> LPVOID
# fContextReq : ASC_REQ_FLAGS -> DWORD
# TargetDataRep : DWORD -> DWORD
# phNewContext : SecHandle* optional, in/out -> LPVOID
# pOutput : SecBufferDesc* optional, in/out -> LPVOID
# pfContextAttr : DWORD* out -> LPVOID
# ptsExpiry : LONGLONG* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型