BCryptQueryContextFunctionProperty
関数シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptQueryContextFunctionProperty(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext,
BCRYPT_INTERFACE dwInterface,
LPCWSTR pszFunction,
LPCWSTR pszProperty,
DWORD* pcbValue,
BYTE** ppbValue // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| dwTable | BCRYPT_TABLE | in | コンテキストが存在する構成テーブルを指定します。次のいずれかの値を指定できます。
| ||||||
| pszContext | LPCWSTR | in | プロパティを取得する対象のコンテキストの識別子を含む、null 終端の Unicode 文字列へのポインターです。 | ||||||
| dwInterface | BCRYPT_INTERFACE | in | 関数が存在する暗号化インターフェイスを指定します。次のいずれかの値を指定できます。 | ||||||
| pszFunction | LPCWSTR | in | プロパティを取得する対象の暗号化関数の識別子を含む、null 終端の Unicode 文字列へのポインターです。 | ||||||
| pszProperty | LPCWSTR | in | 取得するプロパティの識別子を含む、null 終端の Unicode 文字列へのポインターです。 | ||||||
| pcbValue | DWORD* | inout | ULONG 型変数のアドレスです。呼び出し時には、ppbValue が指すバッファーのサイズ (バイト単位) を格納します。このサイズがプロパティ値を保持するのに十分でない場合、この関数は STATUS_BUFFER_TOO_SMALL で失敗します。 この関数が戻った後、この変数には ppbValue バッファーにコピーされたバイト数が格納されます。 | ||||||
| ppbValue | BYTE** | outoptional | プロパティデータを受け取るバッファーへのポインターのアドレスです。このバッファーのサイズと形式は、取得するプロパティの形式によって異なります。pcbValue パラメーターが指す値が、このバッファーのサイズを表します。 このパラメーターが指す値が NULL の場合、この関数は必要なメモリを割り当てます。このメモリが不要になったら、このポインターを BCryptFreeBuffer 関数に渡して解放する必要があります。 このパラメーターが NULL の場合、この関数は必要なサイズ (バイト単位) を pcbValue パラメーターが指す変数に格納し、STATUS_BUFFER_TOO_SMALL を返します。 |
戻り値の型: NTSTATUS
公式ドキュメント
既存の CNG コンテキスト内にある暗号化関数について、指定された名前のプロパティの値を取得します。
戻り値
関数の成功または失敗を示すステータスコードを返します。
返される可能性のあるコードには、次のものが含まれますが、これらに限定されません。
| 戻りコード | 説明 |
|---|---|
| 関数は成功しました。 | |
| ppbValue パラメーターが NULL ではなく、かつ pcbValue パラメーターが指す値が、コンテキストのセットを保持するのに十分な大きさではありません。 | |
| 1 つ以上のパラメーターが無効です。 | |
| メモリ割り当てエラーが発生しました。 | |
| 指定されたコンテキスト、関数、またはプロパティが見つかりませんでした。 |
解説(Remarks)
BCryptQueryContextFunctionProperty はユーザーモードでのみ呼び出すことができます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptQueryContextFunctionProperty(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext,
BCRYPT_INTERFACE dwInterface,
LPCWSTR pszFunction,
LPCWSTR pszProperty,
DWORD* pcbValue,
BYTE** ppbValue // optional
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptQueryContextFunctionProperty(
uint dwTable, // BCRYPT_TABLE
[MarshalAs(UnmanagedType.LPWStr)] string pszContext, // LPCWSTR
uint dwInterface, // BCRYPT_INTERFACE
[MarshalAs(UnmanagedType.LPWStr)] string pszFunction, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszProperty, // LPCWSTR
ref uint pcbValue, // DWORD* in/out
IntPtr ppbValue // BYTE** optional, out
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptQueryContextFunctionProperty(
dwTable As UInteger, ' BCRYPT_TABLE
<MarshalAs(UnmanagedType.LPWStr)> pszContext As String, ' LPCWSTR
dwInterface As UInteger, ' BCRYPT_INTERFACE
<MarshalAs(UnmanagedType.LPWStr)> pszFunction As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszProperty As String, ' LPCWSTR
ByRef pcbValue As UInteger, ' DWORD* in/out
ppbValue As IntPtr ' BYTE** optional, out
) As Integer
End Function' dwTable : BCRYPT_TABLE
' pszContext : LPCWSTR
' dwInterface : BCRYPT_INTERFACE
' pszFunction : LPCWSTR
' pszProperty : LPCWSTR
' pcbValue : DWORD* in/out
' ppbValue : BYTE** optional, out
Declare PtrSafe Function BCryptQueryContextFunctionProperty Lib "bcrypt" ( _
ByVal dwTable As Long, _
ByVal pszContext As LongPtr, _
ByVal dwInterface As Long, _
ByVal pszFunction As LongPtr, _
ByVal pszProperty As LongPtr, _
ByRef pcbValue As Long, _
ByVal ppbValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptQueryContextFunctionProperty = ctypes.windll.bcrypt.BCryptQueryContextFunctionProperty
BCryptQueryContextFunctionProperty.restype = ctypes.c_int
BCryptQueryContextFunctionProperty.argtypes = [
wintypes.DWORD, # dwTable : BCRYPT_TABLE
wintypes.LPCWSTR, # pszContext : LPCWSTR
wintypes.DWORD, # dwInterface : BCRYPT_INTERFACE
wintypes.LPCWSTR, # pszFunction : LPCWSTR
wintypes.LPCWSTR, # pszProperty : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # pcbValue : DWORD* in/out
ctypes.c_void_p, # ppbValue : BYTE** optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptQueryContextFunctionProperty = Fiddle::Function.new(
lib['BCryptQueryContextFunctionProperty'],
[
-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, # pszProperty : LPCWSTR
Fiddle::TYPE_VOIDP, # pcbValue : DWORD* in/out
Fiddle::TYPE_VOIDP, # ppbValue : BYTE** optional, out
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptQueryContextFunctionProperty(
dwTable: u32, // BCRYPT_TABLE
pszContext: *const u16, // LPCWSTR
dwInterface: u32, // BCRYPT_INTERFACE
pszFunction: *const u16, // LPCWSTR
pszProperty: *const u16, // LPCWSTR
pcbValue: *mut u32, // DWORD* in/out
ppbValue: *mut *mut u8 // BYTE** optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptQueryContextFunctionProperty(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, uint dwInterface, [MarshalAs(UnmanagedType.LPWStr)] string pszFunction, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, ref uint pcbValue, IntPtr ppbValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptQueryContextFunctionProperty' -Namespace Win32 -PassThru
# $api::BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue)#uselib "bcrypt.dll"
#func global BCryptQueryContextFunctionProperty "BCryptQueryContextFunctionProperty" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; BCryptQueryContextFunctionProperty dwTable, pszContext, dwInterface, pszFunction, pszProperty, varptr(pcbValue), varptr(ppbValue) ; 戻り値は stat
; dwTable : BCRYPT_TABLE -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; dwInterface : BCRYPT_INTERFACE -> "sptr"
; pszFunction : LPCWSTR -> "sptr"
; pszProperty : LPCWSTR -> "sptr"
; pcbValue : DWORD* in/out -> "sptr"
; ppbValue : BYTE** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionProperty "BCryptQueryContextFunctionProperty" int, wstr, int, wstr, wstr, var, var ; res = BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pszProperty : LPCWSTR -> "wstr" ; pcbValue : DWORD* in/out -> "var" ; ppbValue : BYTE** optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionProperty "BCryptQueryContextFunctionProperty" int, wstr, int, wstr, wstr, sptr, sptr ; res = BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, varptr(pcbValue), varptr(ppbValue)) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pszProperty : LPCWSTR -> "wstr" ; pcbValue : DWORD* in/out -> "sptr" ; ppbValue : BYTE** optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; NTSTATUS BCryptQueryContextFunctionProperty(BCRYPT_TABLE dwTable, LPCWSTR pszContext, BCRYPT_INTERFACE dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, DWORD* pcbValue, BYTE** ppbValue) #uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionProperty "BCryptQueryContextFunctionProperty" int, wstr, int, wstr, wstr, var, var ; res = BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pszProperty : LPCWSTR -> "wstr" ; pcbValue : DWORD* in/out -> "var" ; ppbValue : BYTE** optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS BCryptQueryContextFunctionProperty(BCRYPT_TABLE dwTable, LPCWSTR pszContext, BCRYPT_INTERFACE dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, DWORD* pcbValue, BYTE** ppbValue) #uselib "bcrypt.dll" #cfunc global BCryptQueryContextFunctionProperty "BCryptQueryContextFunctionProperty" int, wstr, int, wstr, wstr, intptr, intptr ; res = BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, varptr(pcbValue), varptr(ppbValue)) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pszProperty : LPCWSTR -> "wstr" ; pcbValue : DWORD* in/out -> "intptr" ; ppbValue : BYTE** optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptQueryContextFunctionProperty = bcrypt.NewProc("BCryptQueryContextFunctionProperty")
)
// dwTable (BCRYPT_TABLE), pszContext (LPCWSTR), dwInterface (BCRYPT_INTERFACE), pszFunction (LPCWSTR), pszProperty (LPCWSTR), pcbValue (DWORD* in/out), ppbValue (BYTE** optional, out)
r1, _, err := procBCryptQueryContextFunctionProperty.Call(
uintptr(dwTable),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszContext))),
uintptr(dwInterface),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFunction))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszProperty))),
uintptr(pcbValue),
uintptr(ppbValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptQueryContextFunctionProperty(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // BCRYPT_INTERFACE
pszFunction: PWideChar; // LPCWSTR
pszProperty: PWideChar; // LPCWSTR
pcbValue: Pointer; // DWORD* in/out
ppbValue: Pointer // BYTE** optional, out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptQueryContextFunctionProperty';result := DllCall("bcrypt\BCryptQueryContextFunctionProperty"
, "UInt", dwTable ; BCRYPT_TABLE
, "WStr", pszContext ; LPCWSTR
, "UInt", dwInterface ; BCRYPT_INTERFACE
, "WStr", pszFunction ; LPCWSTR
, "WStr", pszProperty ; LPCWSTR
, "Ptr", pcbValue ; DWORD* in/out
, "Ptr", ppbValue ; BYTE** optional, out
, "Int") ; return: NTSTATUS●BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue) = DLL("bcrypt.dll", "int BCryptQueryContextFunctionProperty(dword, char*, dword, char*, char*, void*, void*)")
# 呼び出し: BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue)
# dwTable : BCRYPT_TABLE -> "dword"
# pszContext : LPCWSTR -> "char*"
# dwInterface : BCRYPT_INTERFACE -> "dword"
# pszFunction : LPCWSTR -> "char*"
# pszProperty : LPCWSTR -> "char*"
# pcbValue : DWORD* in/out -> "void*"
# ppbValue : BYTE** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptQueryContextFunctionProperty(
dwTable: u32, // BCRYPT_TABLE
pszContext: [*c]const u16, // LPCWSTR
dwInterface: u32, // BCRYPT_INTERFACE
pszFunction: [*c]const u16, // LPCWSTR
pszProperty: [*c]const u16, // LPCWSTR
pcbValue: [*c]u32, // DWORD* in/out
ppbValue: [*c][*c]u8 // BYTE** optional, out
) callconv(std.os.windows.WINAPI) i32;proc BCryptQueryContextFunctionProperty(
dwTable: uint32, # BCRYPT_TABLE
pszContext: WideCString, # LPCWSTR
dwInterface: uint32, # BCRYPT_INTERFACE
pszFunction: WideCString, # LPCWSTR
pszProperty: WideCString, # LPCWSTR
pcbValue: ptr uint32, # DWORD* in/out
ppbValue: ptr uint8 # BYTE** optional, out
): int32 {.importc: "BCryptQueryContextFunctionProperty", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptQueryContextFunctionProperty(
uint dwTable, // BCRYPT_TABLE
const(wchar)* pszContext, // LPCWSTR
uint dwInterface, // BCRYPT_INTERFACE
const(wchar)* pszFunction, // LPCWSTR
const(wchar)* pszProperty, // LPCWSTR
uint* pcbValue, // DWORD* in/out
ubyte** ppbValue // BYTE** optional, out
);ccall((:BCryptQueryContextFunctionProperty, "bcrypt.dll"), stdcall, Int32,
(UInt32, Cwstring, UInt32, Cwstring, Cwstring, Ptr{UInt32}, Ptr{UInt8}),
dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue)
# dwTable : BCRYPT_TABLE -> UInt32
# pszContext : LPCWSTR -> Cwstring
# dwInterface : BCRYPT_INTERFACE -> UInt32
# pszFunction : LPCWSTR -> Cwstring
# pszProperty : LPCWSTR -> Cwstring
# pcbValue : DWORD* in/out -> Ptr{UInt32}
# ppbValue : BYTE** optional, out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptQueryContextFunctionProperty(
uint32_t dwTable,
const uint16_t* pszContext,
uint32_t dwInterface,
const uint16_t* pszFunction,
const uint16_t* pszProperty,
uint32_t* pcbValue,
uint8_t** ppbValue);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue)
-- dwTable : BCRYPT_TABLE
-- pszContext : LPCWSTR
-- dwInterface : BCRYPT_INTERFACE
-- pszFunction : LPCWSTR
-- pszProperty : LPCWSTR
-- pcbValue : DWORD* in/out
-- ppbValue : BYTE** optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptQueryContextFunctionProperty = lib.func('__stdcall', 'BCryptQueryContextFunctionProperty', 'int32_t', ['uint32_t', 'str16', 'uint32_t', 'str16', 'str16', 'uint32_t *', 'uint8_t *']);
// BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue)
// dwTable : BCRYPT_TABLE -> 'uint32_t'
// pszContext : LPCWSTR -> 'str16'
// dwInterface : BCRYPT_INTERFACE -> 'uint32_t'
// pszFunction : LPCWSTR -> 'str16'
// pszProperty : LPCWSTR -> 'str16'
// pcbValue : DWORD* in/out -> 'uint32_t *'
// ppbValue : BYTE** optional, out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptQueryContextFunctionProperty: { parameters: ["u32", "buffer", "u32", "buffer", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue)
// dwTable : BCRYPT_TABLE -> "u32"
// pszContext : LPCWSTR -> "buffer"
// dwInterface : BCRYPT_INTERFACE -> "u32"
// pszFunction : LPCWSTR -> "buffer"
// pszProperty : LPCWSTR -> "buffer"
// pcbValue : DWORD* in/out -> "pointer"
// ppbValue : BYTE** optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptQueryContextFunctionProperty(
uint32_t dwTable,
const uint16_t* pszContext,
uint32_t dwInterface,
const uint16_t* pszFunction,
const uint16_t* pszProperty,
uint32_t* pcbValue,
uint8_t** ppbValue);
C, "bcrypt.dll");
// $ffi->BCryptQueryContextFunctionProperty(dwTable, pszContext, dwInterface, pszFunction, pszProperty, pcbValue, ppbValue);
// dwTable : BCRYPT_TABLE
// pszContext : LPCWSTR
// dwInterface : BCRYPT_INTERFACE
// pszFunction : LPCWSTR
// pszProperty : LPCWSTR
// pcbValue : DWORD* in/out
// ppbValue : BYTE** 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 BCryptQueryContextFunctionProperty(
int dwTable, // BCRYPT_TABLE
WString pszContext, // LPCWSTR
int dwInterface, // BCRYPT_INTERFACE
WString pszFunction, // LPCWSTR
WString pszProperty, // LPCWSTR
IntByReference pcbValue, // DWORD* in/out
Pointer ppbValue // BYTE** optional, out
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptQueryContextFunctionProperty = BCryptQueryContextFunctionProperty(
dwTable : UInt32, # BCRYPT_TABLE
pszContext : UInt16*, # LPCWSTR
dwInterface : UInt32, # BCRYPT_INTERFACE
pszFunction : UInt16*, # LPCWSTR
pszProperty : UInt16*, # LPCWSTR
pcbValue : UInt32*, # DWORD* in/out
ppbValue : UInt8** # BYTE** 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 BCryptQueryContextFunctionPropertyNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Uint8>);
typedef BCryptQueryContextFunctionPropertyDart = int Function(int, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Uint8>);
final BCryptQueryContextFunctionProperty = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptQueryContextFunctionPropertyNative, BCryptQueryContextFunctionPropertyDart>('BCryptQueryContextFunctionProperty');
// dwTable : BCRYPT_TABLE -> Uint32
// pszContext : LPCWSTR -> Pointer<Utf16>
// dwInterface : BCRYPT_INTERFACE -> Uint32
// pszFunction : LPCWSTR -> Pointer<Utf16>
// pszProperty : LPCWSTR -> Pointer<Utf16>
// pcbValue : DWORD* in/out -> Pointer<Uint32>
// ppbValue : BYTE** optional, out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptQueryContextFunctionProperty(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // BCRYPT_INTERFACE
pszFunction: PWideChar; // LPCWSTR
pszProperty: PWideChar; // LPCWSTR
pcbValue: Pointer; // DWORD* in/out
ppbValue: Pointer // BYTE** optional, out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptQueryContextFunctionProperty';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptQueryContextFunctionProperty"
c_BCryptQueryContextFunctionProperty :: Word32 -> CWString -> Word32 -> CWString -> CWString -> Ptr Word32 -> Ptr Word8 -> IO Int32
-- dwTable : BCRYPT_TABLE -> Word32
-- pszContext : LPCWSTR -> CWString
-- dwInterface : BCRYPT_INTERFACE -> Word32
-- pszFunction : LPCWSTR -> CWString
-- pszProperty : LPCWSTR -> CWString
-- pcbValue : DWORD* in/out -> Ptr Word32
-- ppbValue : BYTE** optional, out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptquerycontextfunctionproperty =
foreign "BCryptQueryContextFunctionProperty"
(uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint8_t) @-> returning int32_t)
(* dwTable : BCRYPT_TABLE -> uint32_t *)
(* pszContext : LPCWSTR -> (ptr uint16_t) *)
(* dwInterface : BCRYPT_INTERFACE -> uint32_t *)
(* pszFunction : LPCWSTR -> (ptr uint16_t) *)
(* pszProperty : LPCWSTR -> (ptr uint16_t) *)
(* pcbValue : DWORD* in/out -> (ptr uint32_t) *)
(* ppbValue : BYTE** optional, out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bcrypt (t "bcrypt.dll"))
(cffi:use-foreign-library bcrypt)
(cffi:defcfun ("BCryptQueryContextFunctionProperty" bcrypt-query-context-function-property :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
(psz-property (:string :encoding :utf-16le)) ; LPCWSTR
(pcb-value :pointer) ; DWORD* in/out
(ppb-value :pointer)) ; BYTE** optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptQueryContextFunctionProperty = Win32::API::More->new('bcrypt',
'int BCryptQueryContextFunctionProperty(DWORD dwTable, LPCWSTR pszContext, DWORD dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, LPVOID pcbValue, LPVOID ppbValue)');
# my $ret = $BCryptQueryContextFunctionProperty->Call($dwTable, $pszContext, $dwInterface, $pszFunction, $pszProperty, $pcbValue, $ppbValue);
# dwTable : BCRYPT_TABLE -> DWORD
# pszContext : LPCWSTR -> LPCWSTR
# dwInterface : BCRYPT_INTERFACE -> DWORD
# pszFunction : LPCWSTR -> LPCWSTR
# pszProperty : LPCWSTR -> LPCWSTR
# pcbValue : DWORD* in/out -> LPVOID
# ppbValue : BYTE** optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。