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