Win32 API 日本語リファレンス
ホームSecurity.Cryptography › BCryptQueryContextConfiguration

BCryptQueryContextConfiguration

関数
指定したCNGコンテキストの構成情報を取得する。
DLLbcrypt.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

NTSTATUS BCryptQueryContextConfiguration(
    BCRYPT_TABLE dwTable,
    LPCWSTR pszContext,
    DWORD* pcbBuffer,
    CRYPT_CONTEXT_CONFIG** ppBuffer   // optional
);

パラメーター

名前方向
dwTableBCRYPT_TABLEin
pszContextLPCWSTRin
pcbBufferDWORD*inout
ppBufferCRYPT_CONTEXT_CONFIG**outoptional

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS BCryptQueryContextConfiguration(
    BCRYPT_TABLE dwTable,
    LPCWSTR pszContext,
    DWORD* pcbBuffer,
    CRYPT_CONTEXT_CONFIG** ppBuffer   // optional
);
[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptQueryContextConfiguration(
    uint dwTable,   // BCRYPT_TABLE
    [MarshalAs(UnmanagedType.LPWStr)] string pszContext,   // LPCWSTR
    ref uint pcbBuffer,   // DWORD* in/out
    IntPtr ppBuffer   // CRYPT_CONTEXT_CONFIG** optional, out
);
<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptQueryContextConfiguration(
    dwTable As UInteger,   ' BCRYPT_TABLE
    <MarshalAs(UnmanagedType.LPWStr)> pszContext As String,   ' LPCWSTR
    ByRef pcbBuffer As UInteger,   ' DWORD* in/out
    ppBuffer As IntPtr   ' CRYPT_CONTEXT_CONFIG** optional, out
) As Integer
End Function
' dwTable : BCRYPT_TABLE
' pszContext : LPCWSTR
' pcbBuffer : DWORD* in/out
' ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out
Declare PtrSafe Function BCryptQueryContextConfiguration Lib "bcrypt" ( _
    ByVal dwTable As Long, _
    ByVal pszContext 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

BCryptQueryContextConfiguration = ctypes.windll.bcrypt.BCryptQueryContextConfiguration
BCryptQueryContextConfiguration.restype = ctypes.c_int
BCryptQueryContextConfiguration.argtypes = [
    wintypes.DWORD,  # dwTable : BCRYPT_TABLE
    wintypes.LPCWSTR,  # pszContext : LPCWSTR
    ctypes.POINTER(wintypes.DWORD),  # pcbBuffer : DWORD* in/out
    ctypes.c_void_p,  # ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('bcrypt.dll')
BCryptQueryContextConfiguration = Fiddle::Function.new(
  lib['BCryptQueryContextConfiguration'],
  [
    -Fiddle::TYPE_INT,  # dwTable : BCRYPT_TABLE
    Fiddle::TYPE_VOIDP,  # pszContext : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pcbBuffer : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "bcrypt")]
extern "system" {
    fn BCryptQueryContextConfiguration(
        dwTable: u32,  // BCRYPT_TABLE
        pszContext: *const u16,  // LPCWSTR
        pcbBuffer: *mut u32,  // DWORD* in/out
        ppBuffer: *mut *mut CRYPT_CONTEXT_CONFIG  // CRYPT_CONTEXT_CONFIG** optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptQueryContextConfiguration(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, ref uint pcbBuffer, IntPtr ppBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptQueryContextConfiguration' -Namespace Win32 -PassThru
# $api::BCryptQueryContextConfiguration(dwTable, pszContext, pcbBuffer, ppBuffer)
#uselib "bcrypt.dll"
#func global BCryptQueryContextConfiguration "BCryptQueryContextConfiguration" sptr, sptr, sptr, sptr
; BCryptQueryContextConfiguration dwTable, pszContext, varptr(pcbBuffer), varptr(ppBuffer)   ; 戻り値は stat
; dwTable : BCRYPT_TABLE -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; pcbBuffer : DWORD* in/out -> "sptr"
; ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "bcrypt.dll"
#cfunc global BCryptQueryContextConfiguration "BCryptQueryContextConfiguration" int, wstr, var, var
; res = BCryptQueryContextConfiguration(dwTable, pszContext, pcbBuffer, ppBuffer)
; dwTable : BCRYPT_TABLE -> "int"
; pszContext : LPCWSTR -> "wstr"
; pcbBuffer : DWORD* in/out -> "var"
; ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; NTSTATUS BCryptQueryContextConfiguration(BCRYPT_TABLE dwTable, LPCWSTR pszContext, DWORD* pcbBuffer, CRYPT_CONTEXT_CONFIG** ppBuffer)
#uselib "bcrypt.dll"
#cfunc global BCryptQueryContextConfiguration "BCryptQueryContextConfiguration" int, wstr, var, var
; res = BCryptQueryContextConfiguration(dwTable, pszContext, pcbBuffer, ppBuffer)
; dwTable : BCRYPT_TABLE -> "int"
; pszContext : LPCWSTR -> "wstr"
; pcbBuffer : DWORD* in/out -> "var"
; ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
	procBCryptQueryContextConfiguration = bcrypt.NewProc("BCryptQueryContextConfiguration")
)

// dwTable (BCRYPT_TABLE), pszContext (LPCWSTR), pcbBuffer (DWORD* in/out), ppBuffer (CRYPT_CONTEXT_CONFIG** optional, out)
r1, _, err := procBCryptQueryContextConfiguration.Call(
	uintptr(dwTable),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszContext))),
	uintptr(pcbBuffer),
	uintptr(ppBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function BCryptQueryContextConfiguration(
  dwTable: DWORD;   // BCRYPT_TABLE
  pszContext: PWideChar;   // LPCWSTR
  pcbBuffer: Pointer;   // DWORD* in/out
  ppBuffer: Pointer   // CRYPT_CONTEXT_CONFIG** optional, out
): Integer; stdcall;
  external 'bcrypt.dll' name 'BCryptQueryContextConfiguration';
result := DllCall("bcrypt\BCryptQueryContextConfiguration"
    , "UInt", dwTable   ; BCRYPT_TABLE
    , "WStr", pszContext   ; LPCWSTR
    , "Ptr", pcbBuffer   ; DWORD* in/out
    , "Ptr", ppBuffer   ; CRYPT_CONTEXT_CONFIG** optional, out
    , "Int")   ; return: NTSTATUS
●BCryptQueryContextConfiguration(dwTable, pszContext, pcbBuffer, ppBuffer) = DLL("bcrypt.dll", "int BCryptQueryContextConfiguration(dword, char*, void*, void*)")
# 呼び出し: BCryptQueryContextConfiguration(dwTable, pszContext, pcbBuffer, ppBuffer)
# dwTable : BCRYPT_TABLE -> "dword"
# pszContext : LPCWSTR -> "char*"
# pcbBuffer : DWORD* in/out -> "void*"
# ppBuffer : CRYPT_CONTEXT_CONFIG** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。