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

BCryptSetContextFunctionProperty

関数
CNGコンテキスト機能のプロパティ値を設定する。
DLLbcrypt.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

NTSTATUS BCryptSetContextFunctionProperty(
    BCRYPT_TABLE dwTable,
    LPCWSTR pszContext,
    BCRYPT_INTERFACE dwInterface,
    LPCWSTR pszFunction,
    LPCWSTR pszProperty,
    DWORD cbValue,
    BYTE* pbValue   // optional
);

パラメーター

名前方向
dwTableBCRYPT_TABLEin
pszContextLPCWSTRin
dwInterfaceBCRYPT_INTERFACEin
pszFunctionLPCWSTRin
pszPropertyLPCWSTRin
cbValueDWORDin
pbValueBYTE*inoptional

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS BCryptSetContextFunctionProperty(
    BCRYPT_TABLE dwTable,
    LPCWSTR pszContext,
    BCRYPT_INTERFACE dwInterface,
    LPCWSTR pszFunction,
    LPCWSTR pszProperty,
    DWORD cbValue,
    BYTE* pbValue   // optional
);
[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptSetContextFunctionProperty(
    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
    uint cbValue,   // DWORD
    IntPtr pbValue   // BYTE* optional
);
<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptSetContextFunctionProperty(
    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
    cbValue As UInteger,   ' DWORD
    pbValue As IntPtr   ' BYTE* optional
) As Integer
End Function
' dwTable : BCRYPT_TABLE
' pszContext : LPCWSTR
' dwInterface : BCRYPT_INTERFACE
' pszFunction : LPCWSTR
' pszProperty : LPCWSTR
' cbValue : DWORD
' pbValue : BYTE* optional
Declare PtrSafe Function BCryptSetContextFunctionProperty Lib "bcrypt" ( _
    ByVal dwTable As Long, _
    ByVal pszContext As LongPtr, _
    ByVal dwInterface As Long, _
    ByVal pszFunction As LongPtr, _
    ByVal pszProperty As LongPtr, _
    ByVal cbValue As Long, _
    ByVal pbValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BCryptSetContextFunctionProperty = ctypes.windll.bcrypt.BCryptSetContextFunctionProperty
BCryptSetContextFunctionProperty.restype = ctypes.c_int
BCryptSetContextFunctionProperty.argtypes = [
    wintypes.DWORD,  # dwTable : BCRYPT_TABLE
    wintypes.LPCWSTR,  # pszContext : LPCWSTR
    wintypes.DWORD,  # dwInterface : BCRYPT_INTERFACE
    wintypes.LPCWSTR,  # pszFunction : LPCWSTR
    wintypes.LPCWSTR,  # pszProperty : LPCWSTR
    wintypes.DWORD,  # cbValue : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pbValue : BYTE* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
	procBCryptSetContextFunctionProperty = bcrypt.NewProc("BCryptSetContextFunctionProperty")
)

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