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

BCryptAddContextFunctionProvider

関数
CNGコンテキストの関数にプロバイダーを追加する。
DLLbcrypt.dll呼出規約winapi

シグネチャ

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

NTSTATUS BCryptAddContextFunctionProvider(
    DWORD dwTable,
    LPCWSTR pszContext,
    DWORD dwInterface,
    LPCWSTR pszFunction,
    LPCWSTR pszProvider,
    DWORD dwPosition
);

パラメーター

名前方向
dwTableDWORDin
pszContextLPCWSTRin
dwInterfaceDWORDin
pszFunctionLPCWSTRin
pszProviderLPCWSTRin
dwPositionDWORDin

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS BCryptAddContextFunctionProvider(
    DWORD dwTable,
    LPCWSTR pszContext,
    DWORD dwInterface,
    LPCWSTR pszFunction,
    LPCWSTR pszProvider,
    DWORD dwPosition
);
[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptAddContextFunctionProvider(
    uint dwTable,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszContext,   // LPCWSTR
    uint dwInterface,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszFunction,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszProvider,   // LPCWSTR
    uint dwPosition   // DWORD
);
<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptAddContextFunctionProvider(
    dwTable As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszContext As String,   ' LPCWSTR
    dwInterface As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszFunction As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszProvider As String,   ' LPCWSTR
    dwPosition As UInteger   ' DWORD
) As Integer
End Function
' dwTable : DWORD
' pszContext : LPCWSTR
' dwInterface : DWORD
' pszFunction : LPCWSTR
' pszProvider : LPCWSTR
' dwPosition : DWORD
Declare PtrSafe Function BCryptAddContextFunctionProvider Lib "bcrypt" ( _
    ByVal dwTable As Long, _
    ByVal pszContext As LongPtr, _
    ByVal dwInterface As Long, _
    ByVal pszFunction As LongPtr, _
    ByVal pszProvider As LongPtr, _
    ByVal dwPosition As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BCryptAddContextFunctionProvider = ctypes.windll.bcrypt.BCryptAddContextFunctionProvider
BCryptAddContextFunctionProvider.restype = ctypes.c_int
BCryptAddContextFunctionProvider.argtypes = [
    wintypes.DWORD,  # dwTable : DWORD
    wintypes.LPCWSTR,  # pszContext : LPCWSTR
    wintypes.DWORD,  # dwInterface : DWORD
    wintypes.LPCWSTR,  # pszFunction : LPCWSTR
    wintypes.LPCWSTR,  # pszProvider : LPCWSTR
    wintypes.DWORD,  # dwPosition : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('bcrypt.dll')
BCryptAddContextFunctionProvider = Fiddle::Function.new(
  lib['BCryptAddContextFunctionProvider'],
  [
    -Fiddle::TYPE_INT,  # dwTable : DWORD
    Fiddle::TYPE_VOIDP,  # pszContext : LPCWSTR
    -Fiddle::TYPE_INT,  # dwInterface : DWORD
    Fiddle::TYPE_VOIDP,  # pszFunction : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszProvider : LPCWSTR
    -Fiddle::TYPE_INT,  # dwPosition : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "bcrypt")]
extern "system" {
    fn BCryptAddContextFunctionProvider(
        dwTable: u32,  // DWORD
        pszContext: *const u16,  // LPCWSTR
        dwInterface: u32,  // DWORD
        pszFunction: *const u16,  // LPCWSTR
        pszProvider: *const u16,  // LPCWSTR
        dwPosition: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptAddContextFunctionProvider(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, uint dwInterface, [MarshalAs(UnmanagedType.LPWStr)] string pszFunction, [MarshalAs(UnmanagedType.LPWStr)] string pszProvider, uint dwPosition);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptAddContextFunctionProvider' -Namespace Win32 -PassThru
# $api::BCryptAddContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider, dwPosition)
#uselib "bcrypt.dll"
#func global BCryptAddContextFunctionProvider "BCryptAddContextFunctionProvider" sptr, sptr, sptr, sptr, sptr, sptr
; BCryptAddContextFunctionProvider dwTable, pszContext, dwInterface, pszFunction, pszProvider, dwPosition   ; 戻り値は stat
; dwTable : DWORD -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; dwInterface : DWORD -> "sptr"
; pszFunction : LPCWSTR -> "sptr"
; pszProvider : LPCWSTR -> "sptr"
; dwPosition : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "bcrypt.dll"
#cfunc global BCryptAddContextFunctionProvider "BCryptAddContextFunctionProvider" int, wstr, int, wstr, wstr, int
; res = BCryptAddContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider, dwPosition)
; dwTable : DWORD -> "int"
; pszContext : LPCWSTR -> "wstr"
; dwInterface : DWORD -> "int"
; pszFunction : LPCWSTR -> "wstr"
; pszProvider : LPCWSTR -> "wstr"
; dwPosition : DWORD -> "int"
; NTSTATUS BCryptAddContextFunctionProvider(DWORD dwTable, LPCWSTR pszContext, DWORD dwInterface, LPCWSTR pszFunction, LPCWSTR pszProvider, DWORD dwPosition)
#uselib "bcrypt.dll"
#cfunc global BCryptAddContextFunctionProvider "BCryptAddContextFunctionProvider" int, wstr, int, wstr, wstr, int
; res = BCryptAddContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider, dwPosition)
; dwTable : DWORD -> "int"
; pszContext : LPCWSTR -> "wstr"
; dwInterface : DWORD -> "int"
; pszFunction : LPCWSTR -> "wstr"
; pszProvider : LPCWSTR -> "wstr"
; dwPosition : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
	procBCryptAddContextFunctionProvider = bcrypt.NewProc("BCryptAddContextFunctionProvider")
)

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