ホーム › Security.Cryptography › BCryptQueryContextFunctionConfiguration
BCryptQueryContextFunctionConfiguration
関数CNGコンテキストの指定機能の構成情報を取得する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptQueryContextFunctionConfiguration(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext,
BCRYPT_INTERFACE dwInterface,
LPCWSTR pszFunction,
DWORD* pcbBuffer,
CRYPT_CONTEXT_FUNCTION_CONFIG** ppBuffer // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwTable | BCRYPT_TABLE | in | 対象の構成テーブル(BCRYPT_TABLE)。 |
| pszContext | LPCWSTR | in | 関数構成を問い合わせるコンテキストの識別名。 |
| dwInterface | BCRYPT_INTERFACE | in | 対象インターフェイス(BCRYPT_INTERFACE)。 |
| pszFunction | LPCWSTR | in | 問い合わせる暗号機能(アルゴリズム)の名前。 |
| pcbBuffer | DWORD* | inout | 入力時はバッファサイズ、出力時は必要サイズを保持するポインタ。 |
| ppBuffer | CRYPT_CONTEXT_FUNCTION_CONFIG** | outoptional | 機能構成(CRYPT_CONTEXT_FUNCTION_CONFIG)を受け取るポインタ。BCryptFreeBufferで解放する。 |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptQueryContextFunctionConfiguration(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext,
BCRYPT_INTERFACE dwInterface,
LPCWSTR pszFunction,
DWORD* pcbBuffer,
CRYPT_CONTEXT_FUNCTION_CONFIG** ppBuffer // optional
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptQueryContextFunctionConfiguration(
uint dwTable, // BCRYPT_TABLE
[MarshalAs(UnmanagedType.LPWStr)] string pszContext, // LPCWSTR
uint dwInterface, // BCRYPT_INTERFACE
[MarshalAs(UnmanagedType.LPWStr)] string pszFunction, // LPCWSTR
ref uint pcbBuffer, // DWORD* in/out
IntPtr ppBuffer // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptQueryContextFunctionConfiguration(
dwTable As UInteger, ' BCRYPT_TABLE
<MarshalAs(UnmanagedType.LPWStr)> pszContext As String, ' LPCWSTR
dwInterface As UInteger, ' BCRYPT_INTERFACE
<MarshalAs(UnmanagedType.LPWStr)> pszFunction As String, ' LPCWSTR
ByRef pcbBuffer As UInteger, ' DWORD* in/out
ppBuffer As IntPtr ' CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
) As Integer
End Function' dwTable : BCRYPT_TABLE
' pszContext : LPCWSTR
' dwInterface : BCRYPT_INTERFACE
' pszFunction : LPCWSTR
' pcbBuffer : DWORD* in/out
' ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
Declare PtrSafe Function BCryptQueryContextFunctionConfiguration Lib "bcrypt" ( _
ByVal dwTable As Long, _
ByVal pszContext As LongPtr, _
ByVal dwInterface As Long, _
ByVal pszFunction As LongPtr, _
ByRef pcbBuffer As Long, _
ByVal ppBuffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptQueryContextFunctionConfiguration = ctypes.windll.bcrypt.BCryptQueryContextFunctionConfiguration
BCryptQueryContextFunctionConfiguration.restype = ctypes.c_int
BCryptQueryContextFunctionConfiguration.argtypes = [
wintypes.DWORD, # dwTable : BCRYPT_TABLE
wintypes.LPCWSTR, # pszContext : LPCWSTR
wintypes.DWORD, # dwInterface : BCRYPT_INTERFACE
wintypes.LPCWSTR, # pszFunction : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # pcbBuffer : DWORD* in/out
ctypes.c_void_p, # ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptQueryContextFunctionConfiguration = Fiddle::Function.new(
lib['BCryptQueryContextFunctionConfiguration'],
[
-Fiddle::TYPE_INT, # dwTable : BCRYPT_TABLE
Fiddle::TYPE_VOIDP, # pszContext : LPCWSTR
-Fiddle::TYPE_INT, # dwInterface : BCRYPT_INTERFACE
Fiddle::TYPE_VOIDP, # pszFunction : LPCWSTR
Fiddle::TYPE_VOIDP, # pcbBuffer : DWORD* in/out
Fiddle::TYPE_VOIDP, # ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptQueryContextFunctionConfiguration(
dwTable: u32, // BCRYPT_TABLE
pszContext: *const u16, // LPCWSTR
dwInterface: u32, // BCRYPT_INTERFACE
pszFunction: *const u16, // LPCWSTR
pcbBuffer: *mut u32, // DWORD* in/out
ppBuffer: *mut *mut CRYPT_CONTEXT_FUNCTION_CONFIG // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptQueryContextFunctionConfiguration(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, uint dwInterface, [MarshalAs(UnmanagedType.LPWStr)] string pszFunction, ref uint pcbBuffer, IntPtr ppBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptQueryContextFunctionConfiguration' -Namespace Win32 -PassThru
# $api::BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer)#uselib "bcrypt.dll"
#func global BCryptQueryContextFunctionConfiguration "BCryptQueryContextFunctionConfiguration" sptr, sptr, sptr, sptr, sptr, sptr
; BCryptQueryContextFunctionConfiguration dwTable, pszContext, dwInterface, pszFunction, varptr(pcbBuffer), varptr(ppBuffer) ; 戻り値は stat
; dwTable : BCRYPT_TABLE -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; dwInterface : BCRYPT_INTERFACE -> "sptr"
; pszFunction : LPCWSTR -> "sptr"
; pcbBuffer : DWORD* in/out -> "sptr"
; ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionConfiguration "BCryptQueryContextFunctionConfiguration" int, wstr, int, wstr, var, var ; res = BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pcbBuffer : DWORD* in/out -> "var" ; ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionConfiguration "BCryptQueryContextFunctionConfiguration" int, wstr, int, wstr, sptr, sptr ; res = BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, varptr(pcbBuffer), varptr(ppBuffer)) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pcbBuffer : DWORD* in/out -> "sptr" ; ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS BCryptQueryContextFunctionConfiguration(BCRYPT_TABLE dwTable, LPCWSTR pszContext, BCRYPT_INTERFACE dwInterface, LPCWSTR pszFunction, DWORD* pcbBuffer, CRYPT_CONTEXT_FUNCTION_CONFIG** ppBuffer) #uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionConfiguration "BCryptQueryContextFunctionConfiguration" int, wstr, int, wstr, var, var ; res = BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pcbBuffer : DWORD* in/out -> "var" ; ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS BCryptQueryContextFunctionConfiguration(BCRYPT_TABLE dwTable, LPCWSTR pszContext, BCRYPT_INTERFACE dwInterface, LPCWSTR pszFunction, DWORD* pcbBuffer, CRYPT_CONTEXT_FUNCTION_CONFIG** ppBuffer) #uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionConfiguration "BCryptQueryContextFunctionConfiguration" int, wstr, int, wstr, intptr, intptr ; res = BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, varptr(pcbBuffer), varptr(ppBuffer)) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pcbBuffer : DWORD* in/out -> "intptr" ; ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptQueryContextFunctionConfiguration = bcrypt.NewProc("BCryptQueryContextFunctionConfiguration")
)
// dwTable (BCRYPT_TABLE), pszContext (LPCWSTR), dwInterface (BCRYPT_INTERFACE), pszFunction (LPCWSTR), pcbBuffer (DWORD* in/out), ppBuffer (CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out)
r1, _, err := procBCryptQueryContextFunctionConfiguration.Call(
uintptr(dwTable),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszContext))),
uintptr(dwInterface),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFunction))),
uintptr(pcbBuffer),
uintptr(ppBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptQueryContextFunctionConfiguration(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // BCRYPT_INTERFACE
pszFunction: PWideChar; // LPCWSTR
pcbBuffer: Pointer; // DWORD* in/out
ppBuffer: Pointer // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptQueryContextFunctionConfiguration';result := DllCall("bcrypt\BCryptQueryContextFunctionConfiguration"
, "UInt", dwTable ; BCRYPT_TABLE
, "WStr", pszContext ; LPCWSTR
, "UInt", dwInterface ; BCRYPT_INTERFACE
, "WStr", pszFunction ; LPCWSTR
, "Ptr", pcbBuffer ; DWORD* in/out
, "Ptr", ppBuffer ; CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
, "Int") ; return: NTSTATUS●BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer) = DLL("bcrypt.dll", "int BCryptQueryContextFunctionConfiguration(dword, char*, dword, char*, void*, void*)")
# 呼び出し: BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer)
# dwTable : BCRYPT_TABLE -> "dword"
# pszContext : LPCWSTR -> "char*"
# dwInterface : BCRYPT_INTERFACE -> "dword"
# pszFunction : LPCWSTR -> "char*"
# pcbBuffer : DWORD* in/out -> "void*"
# ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptQueryContextFunctionConfiguration(
dwTable: u32, // BCRYPT_TABLE
pszContext: [*c]const u16, // LPCWSTR
dwInterface: u32, // BCRYPT_INTERFACE
pszFunction: [*c]const u16, // LPCWSTR
pcbBuffer: [*c]u32, // DWORD* in/out
ppBuffer: [*c][*c]CRYPT_CONTEXT_FUNCTION_CONFIG // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
) callconv(std.os.windows.WINAPI) i32;proc BCryptQueryContextFunctionConfiguration(
dwTable: uint32, # BCRYPT_TABLE
pszContext: WideCString, # LPCWSTR
dwInterface: uint32, # BCRYPT_INTERFACE
pszFunction: WideCString, # LPCWSTR
pcbBuffer: ptr uint32, # DWORD* in/out
ppBuffer: ptr CRYPT_CONTEXT_FUNCTION_CONFIG # CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
): int32 {.importc: "BCryptQueryContextFunctionConfiguration", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptQueryContextFunctionConfiguration(
uint dwTable, // BCRYPT_TABLE
const(wchar)* pszContext, // LPCWSTR
uint dwInterface, // BCRYPT_INTERFACE
const(wchar)* pszFunction, // LPCWSTR
uint* pcbBuffer, // DWORD* in/out
CRYPT_CONTEXT_FUNCTION_CONFIG** ppBuffer // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
);ccall((:BCryptQueryContextFunctionConfiguration, "bcrypt.dll"), stdcall, Int32,
(UInt32, Cwstring, UInt32, Cwstring, Ptr{UInt32}, Ptr{CRYPT_CONTEXT_FUNCTION_CONFIG}),
dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer)
# dwTable : BCRYPT_TABLE -> UInt32
# pszContext : LPCWSTR -> Cwstring
# dwInterface : BCRYPT_INTERFACE -> UInt32
# pszFunction : LPCWSTR -> Cwstring
# pcbBuffer : DWORD* in/out -> Ptr{UInt32}
# ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> Ptr{CRYPT_CONTEXT_FUNCTION_CONFIG}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptQueryContextFunctionConfiguration(
uint32_t dwTable,
const uint16_t* pszContext,
uint32_t dwInterface,
const uint16_t* pszFunction,
uint32_t* pcbBuffer,
void* ppBuffer);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer)
-- dwTable : BCRYPT_TABLE
-- pszContext : LPCWSTR
-- dwInterface : BCRYPT_INTERFACE
-- pszFunction : LPCWSTR
-- pcbBuffer : DWORD* in/out
-- ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptQueryContextFunctionConfiguration = lib.func('__stdcall', 'BCryptQueryContextFunctionConfiguration', 'int32_t', ['uint32_t', 'str16', 'uint32_t', 'str16', 'uint32_t *', 'void *']);
// BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer)
// dwTable : BCRYPT_TABLE -> 'uint32_t'
// pszContext : LPCWSTR -> 'str16'
// dwInterface : BCRYPT_INTERFACE -> 'uint32_t'
// pszFunction : LPCWSTR -> 'str16'
// pcbBuffer : DWORD* in/out -> 'uint32_t *'
// ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptQueryContextFunctionConfiguration: { parameters: ["u32", "buffer", "u32", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer)
// dwTable : BCRYPT_TABLE -> "u32"
// pszContext : LPCWSTR -> "buffer"
// dwInterface : BCRYPT_INTERFACE -> "u32"
// pszFunction : LPCWSTR -> "buffer"
// pcbBuffer : DWORD* in/out -> "pointer"
// ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptQueryContextFunctionConfiguration(
uint32_t dwTable,
const uint16_t* pszContext,
uint32_t dwInterface,
const uint16_t* pszFunction,
uint32_t* pcbBuffer,
void* ppBuffer);
C, "bcrypt.dll");
// $ffi->BCryptQueryContextFunctionConfiguration(dwTable, pszContext, dwInterface, pszFunction, pcbBuffer, ppBuffer);
// dwTable : BCRYPT_TABLE
// pszContext : LPCWSTR
// dwInterface : BCRYPT_INTERFACE
// pszFunction : LPCWSTR
// pcbBuffer : DWORD* in/out
// ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** 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 Bcrypt extends StdCallLibrary {
Bcrypt INSTANCE = Native.load("bcrypt", Bcrypt.class);
int BCryptQueryContextFunctionConfiguration(
int dwTable, // BCRYPT_TABLE
WString pszContext, // LPCWSTR
int dwInterface, // BCRYPT_INTERFACE
WString pszFunction, // LPCWSTR
IntByReference pcbBuffer, // DWORD* in/out
Pointer ppBuffer // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptQueryContextFunctionConfiguration = BCryptQueryContextFunctionConfiguration(
dwTable : UInt32, # BCRYPT_TABLE
pszContext : UInt16*, # LPCWSTR
dwInterface : UInt32, # BCRYPT_INTERFACE
pszFunction : UInt16*, # LPCWSTR
pcbBuffer : UInt32*, # DWORD* in/out
ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** # CRYPT_CONTEXT_FUNCTION_CONFIG** 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 BCryptQueryContextFunctionConfigurationNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>);
typedef BCryptQueryContextFunctionConfigurationDart = int Function(int, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>);
final BCryptQueryContextFunctionConfiguration = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptQueryContextFunctionConfigurationNative, BCryptQueryContextFunctionConfigurationDart>('BCryptQueryContextFunctionConfiguration');
// dwTable : BCRYPT_TABLE -> Uint32
// pszContext : LPCWSTR -> Pointer<Utf16>
// dwInterface : BCRYPT_INTERFACE -> Uint32
// pszFunction : LPCWSTR -> Pointer<Utf16>
// pcbBuffer : DWORD* in/out -> Pointer<Uint32>
// ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptQueryContextFunctionConfiguration(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // BCRYPT_INTERFACE
pszFunction: PWideChar; // LPCWSTR
pcbBuffer: Pointer; // DWORD* in/out
ppBuffer: Pointer // CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptQueryContextFunctionConfiguration';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptQueryContextFunctionConfiguration"
c_BCryptQueryContextFunctionConfiguration :: Word32 -> CWString -> Word32 -> CWString -> Ptr Word32 -> Ptr () -> IO Int32
-- dwTable : BCRYPT_TABLE -> Word32
-- pszContext : LPCWSTR -> CWString
-- dwInterface : BCRYPT_INTERFACE -> Word32
-- pszFunction : LPCWSTR -> CWString
-- pcbBuffer : DWORD* in/out -> Ptr Word32
-- ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptquerycontextfunctionconfiguration =
foreign "BCryptQueryContextFunctionConfiguration"
(uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* dwTable : BCRYPT_TABLE -> uint32_t *)
(* pszContext : LPCWSTR -> (ptr uint16_t) *)
(* dwInterface : BCRYPT_INTERFACE -> uint32_t *)
(* pszFunction : LPCWSTR -> (ptr uint16_t) *)
(* pcbBuffer : DWORD* in/out -> (ptr uint32_t) *)
(* ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bcrypt (t "bcrypt.dll"))
(cffi:use-foreign-library bcrypt)
(cffi:defcfun ("BCryptQueryContextFunctionConfiguration" bcrypt-query-context-function-configuration :convention :stdcall) :int32
(dw-table :uint32) ; BCRYPT_TABLE
(psz-context (:string :encoding :utf-16le)) ; LPCWSTR
(dw-interface :uint32) ; BCRYPT_INTERFACE
(psz-function (:string :encoding :utf-16le)) ; LPCWSTR
(pcb-buffer :pointer) ; DWORD* in/out
(pp-buffer :pointer)) ; CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptQueryContextFunctionConfiguration = Win32::API::More->new('bcrypt',
'int BCryptQueryContextFunctionConfiguration(DWORD dwTable, LPCWSTR pszContext, DWORD dwInterface, LPCWSTR pszFunction, LPVOID pcbBuffer, LPVOID ppBuffer)');
# my $ret = $BCryptQueryContextFunctionConfiguration->Call($dwTable, $pszContext, $dwInterface, $pszFunction, $pcbBuffer, $ppBuffer);
# dwTable : BCRYPT_TABLE -> DWORD
# pszContext : LPCWSTR -> LPCWSTR
# dwInterface : BCRYPT_INTERFACE -> DWORD
# pszFunction : LPCWSTR -> LPCWSTR
# pcbBuffer : DWORD* in/out -> LPVOID
# ppBuffer : CRYPT_CONTEXT_FUNCTION_CONFIG** optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。