ホーム › Security.Cryptography › BCryptQueryContextFunctionProperty
BCryptQueryContextFunctionProperty
関数CNGコンテキスト機能のプロパティ値を取得する。
シグネチャ
// 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 |
| dwInterface | BCRYPT_INTERFACE | in |
| pszFunction | LPCWSTR | in |
| pszProperty | LPCWSTR | in |
| pcbValue | DWORD* | inout |
| ppbValue | BYTE** | outoptional |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// 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)。