ホーム › Security.Authentication.Identity › SaslGetContextOption
SaslGetContextOption
関数SASLコンテキストのオプション値を取得する。
シグネチャ
// SECUR32.dll
#include <windows.h>
HRESULT SaslGetContextOption(
SecHandle* ContextHandle,
DWORD Option,
void* Value,
DWORD Size,
DWORD* Needed // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ContextHandle | SecHandle* | in | オプションを取得する対象のSASLセキュリティコンテキストハンドルへのポインタ。 |
| Option | DWORD | in | 取得するSASLオプションの識別子。 |
| Value | void* | out | 出力。取得したオプション値を受け取るバッファへのポインタ。 |
| Size | DWORD | in | Valueバッファのサイズをバイト単位で指定する。 |
| Needed | DWORD* | outoptional | 出力。実際に必要なバイト数を受け取るDWORDへのポインタ。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// SECUR32.dll
#include <windows.h>
HRESULT SaslGetContextOption(
SecHandle* ContextHandle,
DWORD Option,
void* Value,
DWORD Size,
DWORD* Needed // optional
);[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int SaslGetContextOption(
IntPtr ContextHandle, // SecHandle*
uint Option, // DWORD
IntPtr Value, // void* out
uint Size, // DWORD
IntPtr Needed // DWORD* optional, out
);<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function SaslGetContextOption(
ContextHandle As IntPtr, ' SecHandle*
[Option] As UInteger, ' DWORD
Value As IntPtr, ' void* out
Size As UInteger, ' DWORD
Needed As IntPtr ' DWORD* optional, out
) As Integer
End Function' ContextHandle : SecHandle*
' Option : DWORD
' Value : void* out
' Size : DWORD
' Needed : DWORD* optional, out
Declare PtrSafe Function SaslGetContextOption Lib "secur32" ( _
ByVal ContextHandle As LongPtr, _
ByVal Option As Long, _
ByVal Value As LongPtr, _
ByVal Size As Long, _
ByVal Needed As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SaslGetContextOption = ctypes.windll.secur32.SaslGetContextOption
SaslGetContextOption.restype = ctypes.c_int
SaslGetContextOption.argtypes = [
ctypes.c_void_p, # ContextHandle : SecHandle*
wintypes.DWORD, # Option : DWORD
ctypes.POINTER(None), # Value : void* out
wintypes.DWORD, # Size : DWORD
ctypes.POINTER(wintypes.DWORD), # Needed : DWORD* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SECUR32.dll')
SaslGetContextOption = Fiddle::Function.new(
lib['SaslGetContextOption'],
[
Fiddle::TYPE_VOIDP, # ContextHandle : SecHandle*
-Fiddle::TYPE_INT, # Option : DWORD
Fiddle::TYPE_VOIDP, # Value : void* out
-Fiddle::TYPE_INT, # Size : DWORD
Fiddle::TYPE_VOIDP, # Needed : DWORD* optional, out
],
Fiddle::TYPE_INT)#[link(name = "secur32")]
extern "system" {
fn SaslGetContextOption(
ContextHandle: *mut SecHandle, // SecHandle*
Option: u32, // DWORD
Value: *mut (), // void* out
Size: u32, // DWORD
Needed: *mut u32 // DWORD* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SECUR32.dll")]
public static extern int SaslGetContextOption(IntPtr ContextHandle, uint Option, IntPtr Value, uint Size, IntPtr Needed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SaslGetContextOption' -Namespace Win32 -PassThru
# $api::SaslGetContextOption(ContextHandle, Option, Value, Size, Needed)#uselib "SECUR32.dll"
#func global SaslGetContextOption "SaslGetContextOption" sptr, sptr, sptr, sptr, sptr
; SaslGetContextOption varptr(ContextHandle), Option, Value, Size, varptr(Needed) ; 戻り値は stat
; ContextHandle : SecHandle* -> "sptr"
; Option : DWORD -> "sptr"
; Value : void* out -> "sptr"
; Size : DWORD -> "sptr"
; Needed : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SECUR32.dll" #cfunc global SaslGetContextOption "SaslGetContextOption" var, int, sptr, int, var ; res = SaslGetContextOption(ContextHandle, Option, Value, Size, Needed) ; ContextHandle : SecHandle* -> "var" ; Option : DWORD -> "int" ; Value : void* out -> "sptr" ; Size : DWORD -> "int" ; Needed : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SECUR32.dll" #cfunc global SaslGetContextOption "SaslGetContextOption" sptr, int, sptr, int, sptr ; res = SaslGetContextOption(varptr(ContextHandle), Option, Value, Size, varptr(Needed)) ; ContextHandle : SecHandle* -> "sptr" ; Option : DWORD -> "int" ; Value : void* out -> "sptr" ; Size : DWORD -> "int" ; Needed : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SaslGetContextOption(SecHandle* ContextHandle, DWORD Option, void* Value, DWORD Size, DWORD* Needed) #uselib "SECUR32.dll" #cfunc global SaslGetContextOption "SaslGetContextOption" var, int, intptr, int, var ; res = SaslGetContextOption(ContextHandle, Option, Value, Size, Needed) ; ContextHandle : SecHandle* -> "var" ; Option : DWORD -> "int" ; Value : void* out -> "intptr" ; Size : DWORD -> "int" ; Needed : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SaslGetContextOption(SecHandle* ContextHandle, DWORD Option, void* Value, DWORD Size, DWORD* Needed) #uselib "SECUR32.dll" #cfunc global SaslGetContextOption "SaslGetContextOption" intptr, int, intptr, int, intptr ; res = SaslGetContextOption(varptr(ContextHandle), Option, Value, Size, varptr(Needed)) ; ContextHandle : SecHandle* -> "intptr" ; Option : DWORD -> "int" ; Value : void* out -> "intptr" ; Size : DWORD -> "int" ; Needed : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
secur32 = windows.NewLazySystemDLL("SECUR32.dll")
procSaslGetContextOption = secur32.NewProc("SaslGetContextOption")
)
// ContextHandle (SecHandle*), Option (DWORD), Value (void* out), Size (DWORD), Needed (DWORD* optional, out)
r1, _, err := procSaslGetContextOption.Call(
uintptr(ContextHandle),
uintptr(Option),
uintptr(Value),
uintptr(Size),
uintptr(Needed),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SaslGetContextOption(
ContextHandle: Pointer; // SecHandle*
Option: DWORD; // DWORD
Value: Pointer; // void* out
Size: DWORD; // DWORD
Needed: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'SECUR32.dll' name 'SaslGetContextOption';result := DllCall("SECUR32\SaslGetContextOption"
, "Ptr", ContextHandle ; SecHandle*
, "UInt", Option ; DWORD
, "Ptr", Value ; void* out
, "UInt", Size ; DWORD
, "Ptr", Needed ; DWORD* optional, out
, "Int") ; return: HRESULT●SaslGetContextOption(ContextHandle, Option, Value, Size, Needed) = DLL("SECUR32.dll", "int SaslGetContextOption(void*, dword, void*, dword, void*)")
# 呼び出し: SaslGetContextOption(ContextHandle, Option, Value, Size, Needed)
# ContextHandle : SecHandle* -> "void*"
# Option : DWORD -> "dword"
# Value : void* out -> "void*"
# Size : DWORD -> "dword"
# Needed : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "secur32" fn SaslGetContextOption(
ContextHandle: [*c]SecHandle, // SecHandle*
Option: u32, // DWORD
Value: ?*anyopaque, // void* out
Size: u32, // DWORD
Needed: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc SaslGetContextOption(
ContextHandle: ptr SecHandle, # SecHandle*
Option: uint32, # DWORD
Value: pointer, # void* out
Size: uint32, # DWORD
Needed: ptr uint32 # DWORD* optional, out
): int32 {.importc: "SaslGetContextOption", stdcall, dynlib: "SECUR32.dll".}pragma(lib, "secur32");
extern(Windows)
int SaslGetContextOption(
SecHandle* ContextHandle, // SecHandle*
uint Option, // DWORD
void* Value, // void* out
uint Size, // DWORD
uint* Needed // DWORD* optional, out
);ccall((:SaslGetContextOption, "SECUR32.dll"), stdcall, Int32,
(Ptr{SecHandle}, UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt32}),
ContextHandle, Option, Value, Size, Needed)
# ContextHandle : SecHandle* -> Ptr{SecHandle}
# Option : DWORD -> UInt32
# Value : void* out -> Ptr{Cvoid}
# Size : DWORD -> UInt32
# Needed : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SaslGetContextOption(
void* ContextHandle,
uint32_t Option,
void* Value,
uint32_t Size,
uint32_t* Needed);
]]
local secur32 = ffi.load("secur32")
-- secur32.SaslGetContextOption(ContextHandle, Option, Value, Size, Needed)
-- ContextHandle : SecHandle*
-- Option : DWORD
-- Value : void* out
-- Size : DWORD
-- Needed : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SECUR32.dll');
const SaslGetContextOption = lib.func('__stdcall', 'SaslGetContextOption', 'int32_t', ['void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t *']);
// SaslGetContextOption(ContextHandle, Option, Value, Size, Needed)
// ContextHandle : SecHandle* -> 'void *'
// Option : DWORD -> 'uint32_t'
// Value : void* out -> 'void *'
// Size : DWORD -> 'uint32_t'
// Needed : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SECUR32.dll", {
SaslGetContextOption: { parameters: ["pointer", "u32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SaslGetContextOption(ContextHandle, Option, Value, Size, Needed)
// ContextHandle : SecHandle* -> "pointer"
// Option : DWORD -> "u32"
// Value : void* out -> "pointer"
// Size : DWORD -> "u32"
// Needed : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SaslGetContextOption(
void* ContextHandle,
uint32_t Option,
void* Value,
uint32_t Size,
uint32_t* Needed);
C, "SECUR32.dll");
// $ffi->SaslGetContextOption(ContextHandle, Option, Value, Size, Needed);
// ContextHandle : SecHandle*
// Option : DWORD
// Value : void* out
// Size : DWORD
// Needed : DWORD* 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 SaslGetContextOption(
Pointer ContextHandle, // SecHandle*
int Option, // DWORD
Pointer Value, // void* out
int Size, // DWORD
IntByReference Needed // DWORD* optional, out
);
}@[Link("secur32")]
lib LibSECUR32
fun SaslGetContextOption = SaslGetContextOption(
ContextHandle : SecHandle*, # SecHandle*
Option : UInt32, # DWORD
Value : Void*, # void* out
Size : UInt32, # DWORD
Needed : UInt32* # DWORD* 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 SaslGetContextOptionNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Uint32>);
typedef SaslGetContextOptionDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Uint32>);
final SaslGetContextOption = DynamicLibrary.open('SECUR32.dll')
.lookupFunction<SaslGetContextOptionNative, SaslGetContextOptionDart>('SaslGetContextOption');
// ContextHandle : SecHandle* -> Pointer<Void>
// Option : DWORD -> Uint32
// Value : void* out -> Pointer<Void>
// Size : DWORD -> Uint32
// Needed : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SaslGetContextOption(
ContextHandle: Pointer; // SecHandle*
Option: DWORD; // DWORD
Value: Pointer; // void* out
Size: DWORD; // DWORD
Needed: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'SECUR32.dll' name 'SaslGetContextOption';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SaslGetContextOption"
c_SaslGetContextOption :: Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr Word32 -> IO Int32
-- ContextHandle : SecHandle* -> Ptr ()
-- Option : DWORD -> Word32
-- Value : void* out -> Ptr ()
-- Size : DWORD -> Word32
-- Needed : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let saslgetcontextoption =
foreign "SaslGetContextOption"
((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* ContextHandle : SecHandle* -> (ptr void) *)
(* Option : DWORD -> uint32_t *)
(* Value : void* out -> (ptr void) *)
(* Size : DWORD -> uint32_t *)
(* Needed : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library secur32 (t "SECUR32.dll"))
(cffi:use-foreign-library secur32)
(cffi:defcfun ("SaslGetContextOption" sasl-get-context-option :convention :stdcall) :int32
(context-handle :pointer) ; SecHandle*
(option :uint32) ; DWORD
(value :pointer) ; void* out
(size :uint32) ; DWORD
(needed :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SaslGetContextOption = Win32::API::More->new('SECUR32',
'int SaslGetContextOption(LPVOID ContextHandle, DWORD Option, LPVOID Value, DWORD Size, LPVOID Needed)');
# my $ret = $SaslGetContextOption->Call($ContextHandle, $Option, $Value, $Size, $Needed);
# ContextHandle : SecHandle* -> LPVOID
# Option : DWORD -> DWORD
# Value : void* out -> LPVOID
# Size : DWORD -> DWORD
# Needed : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型