ホーム › Security.Cryptography › BCryptConfigureContextFunction
BCryptConfigureContextFunction
関数CNGコンテキストの指定機能の構成情報を設定する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptConfigureContextFunction(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext,
BCRYPT_INTERFACE dwInterface,
LPCWSTR pszFunction,
CRYPT_CONTEXT_FUNCTION_CONFIG* pConfig
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwTable | BCRYPT_TABLE | in |
| pszContext | LPCWSTR | in |
| dwInterface | BCRYPT_INTERFACE | in |
| pszFunction | LPCWSTR | in |
| pConfig | CRYPT_CONTEXT_FUNCTION_CONFIG* | in |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptConfigureContextFunction(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext,
BCRYPT_INTERFACE dwInterface,
LPCWSTR pszFunction,
CRYPT_CONTEXT_FUNCTION_CONFIG* pConfig
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptConfigureContextFunction(
uint dwTable, // BCRYPT_TABLE
[MarshalAs(UnmanagedType.LPWStr)] string pszContext, // LPCWSTR
uint dwInterface, // BCRYPT_INTERFACE
[MarshalAs(UnmanagedType.LPWStr)] string pszFunction, // LPCWSTR
IntPtr pConfig // CRYPT_CONTEXT_FUNCTION_CONFIG*
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptConfigureContextFunction(
dwTable As UInteger, ' BCRYPT_TABLE
<MarshalAs(UnmanagedType.LPWStr)> pszContext As String, ' LPCWSTR
dwInterface As UInteger, ' BCRYPT_INTERFACE
<MarshalAs(UnmanagedType.LPWStr)> pszFunction As String, ' LPCWSTR
pConfig As IntPtr ' CRYPT_CONTEXT_FUNCTION_CONFIG*
) As Integer
End Function' dwTable : BCRYPT_TABLE
' pszContext : LPCWSTR
' dwInterface : BCRYPT_INTERFACE
' pszFunction : LPCWSTR
' pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG*
Declare PtrSafe Function BCryptConfigureContextFunction Lib "bcrypt" ( _
ByVal dwTable As Long, _
ByVal pszContext As LongPtr, _
ByVal dwInterface As Long, _
ByVal pszFunction As LongPtr, _
ByVal pConfig As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptConfigureContextFunction = ctypes.windll.bcrypt.BCryptConfigureContextFunction
BCryptConfigureContextFunction.restype = ctypes.c_int
BCryptConfigureContextFunction.argtypes = [
wintypes.DWORD, # dwTable : BCRYPT_TABLE
wintypes.LPCWSTR, # pszContext : LPCWSTR
wintypes.DWORD, # dwInterface : BCRYPT_INTERFACE
wintypes.LPCWSTR, # pszFunction : LPCWSTR
ctypes.c_void_p, # pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptConfigureContextFunction = Fiddle::Function.new(
lib['BCryptConfigureContextFunction'],
[
-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, # pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG*
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptConfigureContextFunction(
dwTable: u32, // BCRYPT_TABLE
pszContext: *const u16, // LPCWSTR
dwInterface: u32, // BCRYPT_INTERFACE
pszFunction: *const u16, // LPCWSTR
pConfig: *mut CRYPT_CONTEXT_FUNCTION_CONFIG // CRYPT_CONTEXT_FUNCTION_CONFIG*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptConfigureContextFunction(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, uint dwInterface, [MarshalAs(UnmanagedType.LPWStr)] string pszFunction, IntPtr pConfig);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptConfigureContextFunction' -Namespace Win32 -PassThru
# $api::BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, pConfig)#uselib "bcrypt.dll"
#func global BCryptConfigureContextFunction "BCryptConfigureContextFunction" sptr, sptr, sptr, sptr, sptr
; BCryptConfigureContextFunction dwTable, pszContext, dwInterface, pszFunction, varptr(pConfig) ; 戻り値は stat
; dwTable : BCRYPT_TABLE -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; dwInterface : BCRYPT_INTERFACE -> "sptr"
; pszFunction : LPCWSTR -> "sptr"
; pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "bcrypt.dll" #cfunc global BCryptConfigureContextFunction "BCryptConfigureContextFunction" int, wstr, int, wstr, var ; res = BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, pConfig) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "bcrypt.dll" #cfunc global BCryptConfigureContextFunction "BCryptConfigureContextFunction" int, wstr, int, wstr, sptr ; res = BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, varptr(pConfig)) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS BCryptConfigureContextFunction(BCRYPT_TABLE dwTable, LPCWSTR pszContext, BCRYPT_INTERFACE dwInterface, LPCWSTR pszFunction, CRYPT_CONTEXT_FUNCTION_CONFIG* pConfig) #uselib "bcrypt.dll" #cfunc global BCryptConfigureContextFunction "BCryptConfigureContextFunction" int, wstr, int, wstr, var ; res = BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, pConfig) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS BCryptConfigureContextFunction(BCRYPT_TABLE dwTable, LPCWSTR pszContext, BCRYPT_INTERFACE dwInterface, LPCWSTR pszFunction, CRYPT_CONTEXT_FUNCTION_CONFIG* pConfig) #uselib "bcrypt.dll" #cfunc global BCryptConfigureContextFunction "BCryptConfigureContextFunction" int, wstr, int, wstr, intptr ; res = BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, varptr(pConfig)) ; dwTable : BCRYPT_TABLE -> "int" ; pszContext : LPCWSTR -> "wstr" ; dwInterface : BCRYPT_INTERFACE -> "int" ; pszFunction : LPCWSTR -> "wstr" ; pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptConfigureContextFunction = bcrypt.NewProc("BCryptConfigureContextFunction")
)
// dwTable (BCRYPT_TABLE), pszContext (LPCWSTR), dwInterface (BCRYPT_INTERFACE), pszFunction (LPCWSTR), pConfig (CRYPT_CONTEXT_FUNCTION_CONFIG*)
r1, _, err := procBCryptConfigureContextFunction.Call(
uintptr(dwTable),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszContext))),
uintptr(dwInterface),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFunction))),
uintptr(pConfig),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptConfigureContextFunction(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // BCRYPT_INTERFACE
pszFunction: PWideChar; // LPCWSTR
pConfig: Pointer // CRYPT_CONTEXT_FUNCTION_CONFIG*
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptConfigureContextFunction';result := DllCall("bcrypt\BCryptConfigureContextFunction"
, "UInt", dwTable ; BCRYPT_TABLE
, "WStr", pszContext ; LPCWSTR
, "UInt", dwInterface ; BCRYPT_INTERFACE
, "WStr", pszFunction ; LPCWSTR
, "Ptr", pConfig ; CRYPT_CONTEXT_FUNCTION_CONFIG*
, "Int") ; return: NTSTATUS●BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, pConfig) = DLL("bcrypt.dll", "int BCryptConfigureContextFunction(dword, char*, dword, char*, void*)")
# 呼び出し: BCryptConfigureContextFunction(dwTable, pszContext, dwInterface, pszFunction, pConfig)
# dwTable : BCRYPT_TABLE -> "dword"
# pszContext : LPCWSTR -> "char*"
# dwInterface : BCRYPT_INTERFACE -> "dword"
# pszFunction : LPCWSTR -> "char*"
# pConfig : CRYPT_CONTEXT_FUNCTION_CONFIG* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。