ホーム › Security.Cryptography › BCryptRegisterConfigChangeNotify
BCryptRegisterConfigChangeNotify
関数CNG構成変更の通知を受け取るイベントを登録する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptRegisterConfigChangeNotify(
HANDLE* phEvent
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| phEvent | HANDLE* | out | 構成変更通知に使うイベントハンドルを受け取る出力ポインタ。シグナルで変更を検知する。 |
戻り値の型: NTSTATUS
公式ドキュメント
ユーザーモードの CNG 構成変更イベントハンドラーを作成します。
戻り値
関数の成功または失敗を示すステータスコードを返します。
返される可能性のあるコードには、以下が含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数は成功しました。 | |
| phEvent パラメーターが有効ではありません。 | |
| メモリの割り当てに失敗しました。 |
解説(Remarks)
phEvent パラメーターが指す変数で返されるハンドルは、CNG 構成の変更が発生したときにシグナル状態になります。
BCryptRegisterConfigChangeNotify(HANDLE*) はユーザーモードでのみ呼び出すことができます。カーネルモードで実行されるコードは、BCryptRegisterConfigChangeNotify(PRKEVENT) を呼び出す必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptRegisterConfigChangeNotify(
HANDLE* phEvent
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptRegisterConfigChangeNotify(
IntPtr phEvent // HANDLE* out
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptRegisterConfigChangeNotify(
phEvent As IntPtr ' HANDLE* out
) As Integer
End Function' phEvent : HANDLE* out
Declare PtrSafe Function BCryptRegisterConfigChangeNotify Lib "bcrypt" ( _
ByVal phEvent As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptRegisterConfigChangeNotify = ctypes.windll.bcrypt.BCryptRegisterConfigChangeNotify
BCryptRegisterConfigChangeNotify.restype = ctypes.c_int
BCryptRegisterConfigChangeNotify.argtypes = [
ctypes.c_void_p, # phEvent : HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptRegisterConfigChangeNotify = Fiddle::Function.new(
lib['BCryptRegisterConfigChangeNotify'],
[
Fiddle::TYPE_VOIDP, # phEvent : HANDLE* out
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptRegisterConfigChangeNotify(
phEvent: *mut *mut core::ffi::c_void // HANDLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptRegisterConfigChangeNotify(IntPtr phEvent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptRegisterConfigChangeNotify' -Namespace Win32 -PassThru
# $api::BCryptRegisterConfigChangeNotify(phEvent)#uselib "bcrypt.dll"
#func global BCryptRegisterConfigChangeNotify "BCryptRegisterConfigChangeNotify" sptr
; BCryptRegisterConfigChangeNotify phEvent ; 戻り値は stat
; phEvent : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "bcrypt.dll"
#cfunc global BCryptRegisterConfigChangeNotify "BCryptRegisterConfigChangeNotify" sptr
; res = BCryptRegisterConfigChangeNotify(phEvent)
; phEvent : HANDLE* out -> "sptr"; NTSTATUS BCryptRegisterConfigChangeNotify(HANDLE* phEvent)
#uselib "bcrypt.dll"
#cfunc global BCryptRegisterConfigChangeNotify "BCryptRegisterConfigChangeNotify" intptr
; res = BCryptRegisterConfigChangeNotify(phEvent)
; phEvent : HANDLE* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptRegisterConfigChangeNotify = bcrypt.NewProc("BCryptRegisterConfigChangeNotify")
)
// phEvent (HANDLE* out)
r1, _, err := procBCryptRegisterConfigChangeNotify.Call(
uintptr(phEvent),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptRegisterConfigChangeNotify(
phEvent: Pointer // HANDLE* out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptRegisterConfigChangeNotify';result := DllCall("bcrypt\BCryptRegisterConfigChangeNotify"
, "Ptr", phEvent ; HANDLE* out
, "Int") ; return: NTSTATUS●BCryptRegisterConfigChangeNotify(phEvent) = DLL("bcrypt.dll", "int BCryptRegisterConfigChangeNotify(void*)")
# 呼び出し: BCryptRegisterConfigChangeNotify(phEvent)
# phEvent : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptRegisterConfigChangeNotify(
phEvent: ?*anyopaque // HANDLE* out
) callconv(std.os.windows.WINAPI) i32;proc BCryptRegisterConfigChangeNotify(
phEvent: pointer # HANDLE* out
): int32 {.importc: "BCryptRegisterConfigChangeNotify", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptRegisterConfigChangeNotify(
void* phEvent // HANDLE* out
);ccall((:BCryptRegisterConfigChangeNotify, "bcrypt.dll"), stdcall, Int32,
(Ptr{Cvoid},),
phEvent)
# phEvent : HANDLE* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptRegisterConfigChangeNotify(
void* phEvent);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptRegisterConfigChangeNotify(phEvent)
-- phEvent : HANDLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptRegisterConfigChangeNotify = lib.func('__stdcall', 'BCryptRegisterConfigChangeNotify', 'int32_t', ['void *']);
// BCryptRegisterConfigChangeNotify(phEvent)
// phEvent : HANDLE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptRegisterConfigChangeNotify: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.BCryptRegisterConfigChangeNotify(phEvent)
// phEvent : HANDLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptRegisterConfigChangeNotify(
void* phEvent);
C, "bcrypt.dll");
// $ffi->BCryptRegisterConfigChangeNotify(phEvent);
// phEvent : HANDLE* out
// 構造体/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 BCryptRegisterConfigChangeNotify(
Pointer phEvent // HANDLE* out
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptRegisterConfigChangeNotify = BCryptRegisterConfigChangeNotify(
phEvent : Void* # HANDLE* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BCryptRegisterConfigChangeNotifyNative = Int32 Function(Pointer<Void>);
typedef BCryptRegisterConfigChangeNotifyDart = int Function(Pointer<Void>);
final BCryptRegisterConfigChangeNotify = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptRegisterConfigChangeNotifyNative, BCryptRegisterConfigChangeNotifyDart>('BCryptRegisterConfigChangeNotify');
// phEvent : HANDLE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptRegisterConfigChangeNotify(
phEvent: Pointer // HANDLE* out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptRegisterConfigChangeNotify';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptRegisterConfigChangeNotify"
c_BCryptRegisterConfigChangeNotify :: Ptr () -> IO Int32
-- phEvent : HANDLE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptregisterconfigchangenotify =
foreign "BCryptRegisterConfigChangeNotify"
((ptr void) @-> returning int32_t)
(* phEvent : HANDLE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bcrypt (t "bcrypt.dll"))
(cffi:use-foreign-library bcrypt)
(cffi:defcfun ("BCryptRegisterConfigChangeNotify" bcrypt-register-config-change-notify :convention :stdcall) :int32
(ph-event :pointer)) ; HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptRegisterConfigChangeNotify = Win32::API::More->new('bcrypt',
'int BCryptRegisterConfigChangeNotify(HANDLE phEvent)');
# my $ret = $BCryptRegisterConfigChangeNotify->Call($phEvent);
# phEvent : HANDLE* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f BCryptUnregisterConfigChangeNotify — CNG構成変更通知のイベント登録を解除する。