ホーム › Security.Cryptography › BCryptRemoveContextFunctionProvider
BCryptRemoveContextFunctionProvider
関数CNGコンテキストの関数からプロバイダーを削除する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptRemoveContextFunctionProvider(
DWORD dwTable,
LPCWSTR pszContext,
DWORD dwInterface,
LPCWSTR pszFunction,
LPCWSTR pszProvider
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwTable | DWORD | in | 対象の構成テーブルを示す値(CRYPT_LOCAL等)。 |
| pszContext | LPCWSTR | in | 対象のコンテキスト名。 |
| dwInterface | DWORD | in | 対象のインターフェイス識別子。 |
| pszFunction | LPCWSTR | in | 関数(アルゴリズム)名。 |
| pszProvider | LPCWSTR | in | 関連付けを解除するプロバイダ名。 |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptRemoveContextFunctionProvider(
DWORD dwTable,
LPCWSTR pszContext,
DWORD dwInterface,
LPCWSTR pszFunction,
LPCWSTR pszProvider
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptRemoveContextFunctionProvider(
uint dwTable, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pszContext, // LPCWSTR
uint dwInterface, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pszFunction, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszProvider // LPCWSTR
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptRemoveContextFunctionProvider(
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
) As Integer
End Function' dwTable : DWORD
' pszContext : LPCWSTR
' dwInterface : DWORD
' pszFunction : LPCWSTR
' pszProvider : LPCWSTR
Declare PtrSafe Function BCryptRemoveContextFunctionProvider Lib "bcrypt" ( _
ByVal dwTable As Long, _
ByVal pszContext As LongPtr, _
ByVal dwInterface As Long, _
ByVal pszFunction As LongPtr, _
ByVal pszProvider As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptRemoveContextFunctionProvider = ctypes.windll.bcrypt.BCryptRemoveContextFunctionProvider
BCryptRemoveContextFunctionProvider.restype = ctypes.c_int
BCryptRemoveContextFunctionProvider.argtypes = [
wintypes.DWORD, # dwTable : DWORD
wintypes.LPCWSTR, # pszContext : LPCWSTR
wintypes.DWORD, # dwInterface : DWORD
wintypes.LPCWSTR, # pszFunction : LPCWSTR
wintypes.LPCWSTR, # pszProvider : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptRemoveContextFunctionProvider = Fiddle::Function.new(
lib['BCryptRemoveContextFunctionProvider'],
[
-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)#[link(name = "bcrypt")]
extern "system" {
fn BCryptRemoveContextFunctionProvider(
dwTable: u32, // DWORD
pszContext: *const u16, // LPCWSTR
dwInterface: u32, // DWORD
pszFunction: *const u16, // LPCWSTR
pszProvider: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptRemoveContextFunctionProvider(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, uint dwInterface, [MarshalAs(UnmanagedType.LPWStr)] string pszFunction, [MarshalAs(UnmanagedType.LPWStr)] string pszProvider);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptRemoveContextFunctionProvider' -Namespace Win32 -PassThru
# $api::BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)#uselib "bcrypt.dll"
#func global BCryptRemoveContextFunctionProvider "BCryptRemoveContextFunctionProvider" sptr, sptr, sptr, sptr, sptr
; BCryptRemoveContextFunctionProvider dwTable, pszContext, dwInterface, pszFunction, pszProvider ; 戻り値は stat
; dwTable : DWORD -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; dwInterface : DWORD -> "sptr"
; pszFunction : LPCWSTR -> "sptr"
; pszProvider : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "bcrypt.dll"
#cfunc global BCryptRemoveContextFunctionProvider "BCryptRemoveContextFunctionProvider" int, wstr, int, wstr, wstr
; res = BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)
; dwTable : DWORD -> "int"
; pszContext : LPCWSTR -> "wstr"
; dwInterface : DWORD -> "int"
; pszFunction : LPCWSTR -> "wstr"
; pszProvider : LPCWSTR -> "wstr"; NTSTATUS BCryptRemoveContextFunctionProvider(DWORD dwTable, LPCWSTR pszContext, DWORD dwInterface, LPCWSTR pszFunction, LPCWSTR pszProvider)
#uselib "bcrypt.dll"
#cfunc global BCryptRemoveContextFunctionProvider "BCryptRemoveContextFunctionProvider" int, wstr, int, wstr, wstr
; res = BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)
; dwTable : DWORD -> "int"
; pszContext : LPCWSTR -> "wstr"
; dwInterface : DWORD -> "int"
; pszFunction : LPCWSTR -> "wstr"
; pszProvider : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptRemoveContextFunctionProvider = bcrypt.NewProc("BCryptRemoveContextFunctionProvider")
)
// dwTable (DWORD), pszContext (LPCWSTR), dwInterface (DWORD), pszFunction (LPCWSTR), pszProvider (LPCWSTR)
r1, _, err := procBCryptRemoveContextFunctionProvider.Call(
uintptr(dwTable),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszContext))),
uintptr(dwInterface),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFunction))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszProvider))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptRemoveContextFunctionProvider(
dwTable: DWORD; // DWORD
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // DWORD
pszFunction: PWideChar; // LPCWSTR
pszProvider: PWideChar // LPCWSTR
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptRemoveContextFunctionProvider';result := DllCall("bcrypt\BCryptRemoveContextFunctionProvider"
, "UInt", dwTable ; DWORD
, "WStr", pszContext ; LPCWSTR
, "UInt", dwInterface ; DWORD
, "WStr", pszFunction ; LPCWSTR
, "WStr", pszProvider ; LPCWSTR
, "Int") ; return: NTSTATUS●BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider) = DLL("bcrypt.dll", "int BCryptRemoveContextFunctionProvider(dword, char*, dword, char*, char*)")
# 呼び出し: BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)
# dwTable : DWORD -> "dword"
# pszContext : LPCWSTR -> "char*"
# dwInterface : DWORD -> "dword"
# pszFunction : LPCWSTR -> "char*"
# pszProvider : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptRemoveContextFunctionProvider(
dwTable: u32, // DWORD
pszContext: [*c]const u16, // LPCWSTR
dwInterface: u32, // DWORD
pszFunction: [*c]const u16, // LPCWSTR
pszProvider: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc BCryptRemoveContextFunctionProvider(
dwTable: uint32, # DWORD
pszContext: WideCString, # LPCWSTR
dwInterface: uint32, # DWORD
pszFunction: WideCString, # LPCWSTR
pszProvider: WideCString # LPCWSTR
): int32 {.importc: "BCryptRemoveContextFunctionProvider", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptRemoveContextFunctionProvider(
uint dwTable, // DWORD
const(wchar)* pszContext, // LPCWSTR
uint dwInterface, // DWORD
const(wchar)* pszFunction, // LPCWSTR
const(wchar)* pszProvider // LPCWSTR
);ccall((:BCryptRemoveContextFunctionProvider, "bcrypt.dll"), stdcall, Int32,
(UInt32, Cwstring, UInt32, Cwstring, Cwstring),
dwTable, pszContext, dwInterface, pszFunction, pszProvider)
# dwTable : DWORD -> UInt32
# pszContext : LPCWSTR -> Cwstring
# dwInterface : DWORD -> UInt32
# pszFunction : LPCWSTR -> Cwstring
# pszProvider : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptRemoveContextFunctionProvider(
uint32_t dwTable,
const uint16_t* pszContext,
uint32_t dwInterface,
const uint16_t* pszFunction,
const uint16_t* pszProvider);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)
-- dwTable : DWORD
-- pszContext : LPCWSTR
-- dwInterface : DWORD
-- pszFunction : LPCWSTR
-- pszProvider : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptRemoveContextFunctionProvider = lib.func('__stdcall', 'BCryptRemoveContextFunctionProvider', 'int32_t', ['uint32_t', 'str16', 'uint32_t', 'str16', 'str16']);
// BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)
// dwTable : DWORD -> 'uint32_t'
// pszContext : LPCWSTR -> 'str16'
// dwInterface : DWORD -> 'uint32_t'
// pszFunction : LPCWSTR -> 'str16'
// pszProvider : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptRemoveContextFunctionProvider: { parameters: ["u32", "buffer", "u32", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider)
// dwTable : DWORD -> "u32"
// pszContext : LPCWSTR -> "buffer"
// dwInterface : DWORD -> "u32"
// pszFunction : LPCWSTR -> "buffer"
// pszProvider : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptRemoveContextFunctionProvider(
uint32_t dwTable,
const uint16_t* pszContext,
uint32_t dwInterface,
const uint16_t* pszFunction,
const uint16_t* pszProvider);
C, "bcrypt.dll");
// $ffi->BCryptRemoveContextFunctionProvider(dwTable, pszContext, dwInterface, pszFunction, pszProvider);
// dwTable : DWORD
// pszContext : LPCWSTR
// dwInterface : DWORD
// pszFunction : LPCWSTR
// pszProvider : LPCWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Bcrypt extends StdCallLibrary {
Bcrypt INSTANCE = Native.load("bcrypt", Bcrypt.class);
int BCryptRemoveContextFunctionProvider(
int dwTable, // DWORD
WString pszContext, // LPCWSTR
int dwInterface, // DWORD
WString pszFunction, // LPCWSTR
WString pszProvider // LPCWSTR
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptRemoveContextFunctionProvider = BCryptRemoveContextFunctionProvider(
dwTable : UInt32, # DWORD
pszContext : UInt16*, # LPCWSTR
dwInterface : UInt32, # DWORD
pszFunction : UInt16*, # LPCWSTR
pszProvider : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BCryptRemoveContextFunctionProviderNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Utf16>);
typedef BCryptRemoveContextFunctionProviderDart = int Function(int, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Utf16>);
final BCryptRemoveContextFunctionProvider = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptRemoveContextFunctionProviderNative, BCryptRemoveContextFunctionProviderDart>('BCryptRemoveContextFunctionProvider');
// dwTable : DWORD -> Uint32
// pszContext : LPCWSTR -> Pointer<Utf16>
// dwInterface : DWORD -> Uint32
// pszFunction : LPCWSTR -> Pointer<Utf16>
// pszProvider : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptRemoveContextFunctionProvider(
dwTable: DWORD; // DWORD
pszContext: PWideChar; // LPCWSTR
dwInterface: DWORD; // DWORD
pszFunction: PWideChar; // LPCWSTR
pszProvider: PWideChar // LPCWSTR
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptRemoveContextFunctionProvider';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptRemoveContextFunctionProvider"
c_BCryptRemoveContextFunctionProvider :: Word32 -> CWString -> Word32 -> CWString -> CWString -> IO Int32
-- dwTable : DWORD -> Word32
-- pszContext : LPCWSTR -> CWString
-- dwInterface : DWORD -> Word32
-- pszFunction : LPCWSTR -> CWString
-- pszProvider : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptremovecontextfunctionprovider =
foreign "BCryptRemoveContextFunctionProvider"
(uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* dwTable : DWORD -> uint32_t *)
(* pszContext : LPCWSTR -> (ptr uint16_t) *)
(* dwInterface : DWORD -> uint32_t *)
(* pszFunction : LPCWSTR -> (ptr uint16_t) *)
(* pszProvider : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bcrypt (t "bcrypt.dll"))
(cffi:use-foreign-library bcrypt)
(cffi:defcfun ("BCryptRemoveContextFunctionProvider" bcrypt-remove-context-function-provider :convention :stdcall) :int32
(dw-table :uint32) ; DWORD
(psz-context (:string :encoding :utf-16le)) ; LPCWSTR
(dw-interface :uint32) ; DWORD
(psz-function (:string :encoding :utf-16le)) ; LPCWSTR
(psz-provider (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptRemoveContextFunctionProvider = Win32::API::More->new('bcrypt',
'int BCryptRemoveContextFunctionProvider(DWORD dwTable, LPCWSTR pszContext, DWORD dwInterface, LPCWSTR pszFunction, LPCWSTR pszProvider)');
# my $ret = $BCryptRemoveContextFunctionProvider->Call($dwTable, $pszContext, $dwInterface, $pszFunction, $pszProvider);
# dwTable : DWORD -> DWORD
# pszContext : LPCWSTR -> LPCWSTR
# dwInterface : DWORD -> DWORD
# pszFunction : LPCWSTR -> LPCWSTR
# pszProvider : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。