ホーム › Security.Cryptography › BCryptDestroyHash
BCryptDestroyHash
関数CNGのハッシュオブジェクトを破棄する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptDestroyHash(
BCRYPT_HASH_HANDLE hHash
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hHash | BCRYPT_HASH_HANDLE | inout | 破棄するハッシュオブジェクトまたは MAC オブジェクトのハンドル。このハンドルは BCryptCreateHash 関数を使用して取得します。 |
戻り値の型: NTSTATUS
公式ドキュメント
ハッシュオブジェクトまたはメッセージ認証コード (MAC) オブジェクトを破棄します。
戻り値
関数の成功または失敗を示すステータスコードを返します。
返される可能性のあるコードには、以下が含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| STATUS_SUCCESS | 関数は成功しました。 |
| STATUS_INVALID_HANDLE | hHash パラメーターのアルゴリズムハンドルが無効です。 |
解説(Remarks)
サポートされているアルゴリズムプロバイダーを使用する場合、BCryptDestroyHash はユーザーモードまたはカーネルモードのいずれからでも呼び出すことができます。カーネルモードの呼び出し元は、PASSIVE_LEVEL IRQL または DISPATCH_LEVEL IRQL のいずれかで実行できます。現在の IRQL レベルが DISPATCH_LEVEL の場合、hHash パラメーターで指定するハンドルは、BCRYPT_PROV_DISPATCH フラグを使用して開かれたプロバイダーによって返されたアルゴリズムハンドルから派生したものでなければなりません。
この関数をカーネルモードで呼び出すには、Driver Development Kit (DDK) の一部である Cng.lib を使用します。Windows Server 2008 および Windows Vista: この関数をカーネルモードで呼び出すには、Ksecdd.lib を使用します。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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 BCryptDestroyHash(
BCRYPT_HASH_HANDLE hHash
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptDestroyHash(
IntPtr hHash // BCRYPT_HASH_HANDLE in/out
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptDestroyHash(
hHash As IntPtr ' BCRYPT_HASH_HANDLE in/out
) As Integer
End Function' hHash : BCRYPT_HASH_HANDLE in/out
Declare PtrSafe Function BCryptDestroyHash Lib "bcrypt" ( _
ByVal hHash As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptDestroyHash = ctypes.windll.bcrypt.BCryptDestroyHash
BCryptDestroyHash.restype = ctypes.c_int
BCryptDestroyHash.argtypes = [
wintypes.HANDLE, # hHash : BCRYPT_HASH_HANDLE in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptDestroyHash = Fiddle::Function.new(
lib['BCryptDestroyHash'],
[
Fiddle::TYPE_VOIDP, # hHash : BCRYPT_HASH_HANDLE in/out
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptDestroyHash(
hHash: *mut core::ffi::c_void // BCRYPT_HASH_HANDLE in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptDestroyHash(IntPtr hHash);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptDestroyHash' -Namespace Win32 -PassThru
# $api::BCryptDestroyHash(hHash)#uselib "bcrypt.dll"
#func global BCryptDestroyHash "BCryptDestroyHash" sptr
; BCryptDestroyHash hHash ; 戻り値は stat
; hHash : BCRYPT_HASH_HANDLE in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "bcrypt.dll"
#cfunc global BCryptDestroyHash "BCryptDestroyHash" sptr
; res = BCryptDestroyHash(hHash)
; hHash : BCRYPT_HASH_HANDLE in/out -> "sptr"; NTSTATUS BCryptDestroyHash(BCRYPT_HASH_HANDLE hHash)
#uselib "bcrypt.dll"
#cfunc global BCryptDestroyHash "BCryptDestroyHash" intptr
; res = BCryptDestroyHash(hHash)
; hHash : BCRYPT_HASH_HANDLE in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptDestroyHash = bcrypt.NewProc("BCryptDestroyHash")
)
// hHash (BCRYPT_HASH_HANDLE in/out)
r1, _, err := procBCryptDestroyHash.Call(
uintptr(hHash),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptDestroyHash(
hHash: THandle // BCRYPT_HASH_HANDLE in/out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptDestroyHash';result := DllCall("bcrypt\BCryptDestroyHash"
, "Ptr", hHash ; BCRYPT_HASH_HANDLE in/out
, "Int") ; return: NTSTATUS●BCryptDestroyHash(hHash) = DLL("bcrypt.dll", "int BCryptDestroyHash(void*)")
# 呼び出し: BCryptDestroyHash(hHash)
# hHash : BCRYPT_HASH_HANDLE in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptDestroyHash(
hHash: ?*anyopaque // BCRYPT_HASH_HANDLE in/out
) callconv(std.os.windows.WINAPI) i32;proc BCryptDestroyHash(
hHash: pointer # BCRYPT_HASH_HANDLE in/out
): int32 {.importc: "BCryptDestroyHash", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptDestroyHash(
void* hHash // BCRYPT_HASH_HANDLE in/out
);ccall((:BCryptDestroyHash, "bcrypt.dll"), stdcall, Int32,
(Ptr{Cvoid},),
hHash)
# hHash : BCRYPT_HASH_HANDLE in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptDestroyHash(
void* hHash);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptDestroyHash(hHash)
-- hHash : BCRYPT_HASH_HANDLE in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptDestroyHash = lib.func('__stdcall', 'BCryptDestroyHash', 'int32_t', ['void *']);
// BCryptDestroyHash(hHash)
// hHash : BCRYPT_HASH_HANDLE in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptDestroyHash: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.BCryptDestroyHash(hHash)
// hHash : BCRYPT_HASH_HANDLE in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptDestroyHash(
void* hHash);
C, "bcrypt.dll");
// $ffi->BCryptDestroyHash(hHash);
// hHash : BCRYPT_HASH_HANDLE in/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 BCryptDestroyHash(
Pointer hHash // BCRYPT_HASH_HANDLE in/out
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptDestroyHash = BCryptDestroyHash(
hHash : Void* # BCRYPT_HASH_HANDLE in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BCryptDestroyHashNative = Int32 Function(Pointer<Void>);
typedef BCryptDestroyHashDart = int Function(Pointer<Void>);
final BCryptDestroyHash = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptDestroyHashNative, BCryptDestroyHashDart>('BCryptDestroyHash');
// hHash : BCRYPT_HASH_HANDLE in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptDestroyHash(
hHash: THandle // BCRYPT_HASH_HANDLE in/out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptDestroyHash';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptDestroyHash"
c_BCryptDestroyHash :: Ptr () -> IO Int32
-- hHash : BCRYPT_HASH_HANDLE in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptdestroyhash =
foreign "BCryptDestroyHash"
((ptr void) @-> returning int32_t)
(* hHash : BCRYPT_HASH_HANDLE in/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 ("BCryptDestroyHash" bcrypt-destroy-hash :convention :stdcall) :int32
(h-hash :pointer)) ; BCRYPT_HASH_HANDLE in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptDestroyHash = Win32::API::More->new('bcrypt',
'int BCryptDestroyHash(HANDLE hHash)');
# my $ret = $BCryptDestroyHash->Call($hHash);
# hHash : BCRYPT_HASH_HANDLE in/out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。