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