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

SslGetMaximumKeySize

関数
Schannelがサポートする最大鍵サイズを取得する。
DLLSCHANNEL.dll呼出規約winapi

シグネチャ

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

DWORD SslGetMaximumKeySize(
    DWORD Reserved
);

パラメーター

名前方向説明
ReservedDWORDin予約済みパラメータ。0を指定する。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD SslGetMaximumKeySize(
    DWORD Reserved
);
[DllImport("SCHANNEL.dll", ExactSpelling = true)]
static extern uint SslGetMaximumKeySize(
    uint Reserved   // DWORD
);
<DllImport("SCHANNEL.dll", ExactSpelling:=True)>
Public Shared Function SslGetMaximumKeySize(
    Reserved As UInteger   ' DWORD
) As UInteger
End Function
' Reserved : DWORD
Declare PtrSafe Function SslGetMaximumKeySize Lib "schannel" ( _
    ByVal Reserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SslGetMaximumKeySize = ctypes.windll.schannel.SslGetMaximumKeySize
SslGetMaximumKeySize.restype = wintypes.DWORD
SslGetMaximumKeySize.argtypes = [
    wintypes.DWORD,  # Reserved : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SCHANNEL.dll')
SslGetMaximumKeySize = Fiddle::Function.new(
  lib['SslGetMaximumKeySize'],
  [
    -Fiddle::TYPE_INT,  # Reserved : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "schannel")]
extern "system" {
    fn SslGetMaximumKeySize(
        Reserved: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SCHANNEL.dll")]
public static extern uint SslGetMaximumKeySize(uint Reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SCHANNEL_SslGetMaximumKeySize' -Namespace Win32 -PassThru
# $api::SslGetMaximumKeySize(Reserved)
#uselib "SCHANNEL.dll"
#func global SslGetMaximumKeySize "SslGetMaximumKeySize" sptr
; SslGetMaximumKeySize Reserved   ; 戻り値は stat
; Reserved : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SCHANNEL.dll"
#cfunc global SslGetMaximumKeySize "SslGetMaximumKeySize" int
; res = SslGetMaximumKeySize(Reserved)
; Reserved : DWORD -> "int"
; DWORD SslGetMaximumKeySize(DWORD Reserved)
#uselib "SCHANNEL.dll"
#cfunc global SslGetMaximumKeySize "SslGetMaximumKeySize" int
; res = SslGetMaximumKeySize(Reserved)
; Reserved : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	schannel = windows.NewLazySystemDLL("SCHANNEL.dll")
	procSslGetMaximumKeySize = schannel.NewProc("SslGetMaximumKeySize")
)

// Reserved (DWORD)
r1, _, err := procSslGetMaximumKeySize.Call(
	uintptr(Reserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SslGetMaximumKeySize(
  Reserved: DWORD   // DWORD
): DWORD; stdcall;
  external 'SCHANNEL.dll' name 'SslGetMaximumKeySize';
result := DllCall("SCHANNEL\SslGetMaximumKeySize"
    , "UInt", Reserved   ; DWORD
    , "UInt")   ; return: DWORD
●SslGetMaximumKeySize(Reserved) = DLL("SCHANNEL.dll", "dword SslGetMaximumKeySize(dword)")
# 呼び出し: SslGetMaximumKeySize(Reserved)
# Reserved : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef SslGetMaximumKeySizeNative = Uint32 Function(Uint32);
typedef SslGetMaximumKeySizeDart = int Function(int);
final SslGetMaximumKeySize = DynamicLibrary.open('SCHANNEL.dll')
    .lookupFunction<SslGetMaximumKeySizeNative, SslGetMaximumKeySizeDart>('SslGetMaximumKeySize');
// Reserved : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SslGetMaximumKeySize(
  Reserved: DWORD   // DWORD
): DWORD; stdcall;
  external 'SCHANNEL.dll' name 'SslGetMaximumKeySize';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SslGetMaximumKeySize"
  c_SslGetMaximumKeySize :: Word32 -> IO Word32
-- Reserved : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sslgetmaximumkeysize =
  foreign "SslGetMaximumKeySize"
    (uint32_t @-> returning uint32_t)
(* Reserved : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library schannel (t "SCHANNEL.dll"))
(cffi:use-foreign-library schannel)

(cffi:defcfun ("SslGetMaximumKeySize" ssl-get-maximum-key-size :convention :stdcall) :uint32
  (reserved :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SslGetMaximumKeySize = Win32::API::More->new('SCHANNEL',
    'DWORD SslGetMaximumKeySize(DWORD Reserved)');
# my $ret = $SslGetMaximumKeySize->Call($Reserved);
# Reserved : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。