Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SslFreeCertificate

SslFreeCertificate

関数
SslCrackCertificateで取得した証明書構造体を解放する。
DLLSCHANNEL.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

void SslFreeCertificate(
    X509Certificate* pCertificate
);

パラメーター

名前方向説明
pCertificateX509Certificate*inoutSslCrackCertificateで取得したX509Certificate構造体へのポインタ。解放対象。

戻り値の型: void

各言語での呼び出し定義

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

void SslFreeCertificate(
    X509Certificate* pCertificate
);
[DllImport("SCHANNEL.dll", ExactSpelling = true)]
static extern void SslFreeCertificate(
    IntPtr pCertificate   // X509Certificate* in/out
);
<DllImport("SCHANNEL.dll", ExactSpelling:=True)>
Public Shared Sub SslFreeCertificate(
    pCertificate As IntPtr   ' X509Certificate* in/out
)
End Sub
' pCertificate : X509Certificate* in/out
Declare PtrSafe Sub SslFreeCertificate Lib "schannel" ( _
    ByVal pCertificate As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SslFreeCertificate = ctypes.windll.schannel.SslFreeCertificate
SslFreeCertificate.restype = None
SslFreeCertificate.argtypes = [
    ctypes.c_void_p,  # pCertificate : X509Certificate* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SCHANNEL.dll')
SslFreeCertificate = Fiddle::Function.new(
  lib['SslFreeCertificate'],
  [
    Fiddle::TYPE_VOIDP,  # pCertificate : X509Certificate* in/out
  ],
  Fiddle::TYPE_VOID)
#[link(name = "schannel")]
extern "system" {
    fn SslFreeCertificate(
        pCertificate: *mut X509Certificate  // X509Certificate* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SCHANNEL.dll")]
public static extern void SslFreeCertificate(IntPtr pCertificate);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SCHANNEL_SslFreeCertificate' -Namespace Win32 -PassThru
# $api::SslFreeCertificate(pCertificate)
#uselib "SCHANNEL.dll"
#func global SslFreeCertificate "SslFreeCertificate" sptr
; SslFreeCertificate varptr(pCertificate)
; pCertificate : X509Certificate* in/out -> "sptr"
出力引数:
#uselib "SCHANNEL.dll"
#func global SslFreeCertificate "SslFreeCertificate" var
; SslFreeCertificate pCertificate
; pCertificate : X509Certificate* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void SslFreeCertificate(X509Certificate* pCertificate)
#uselib "SCHANNEL.dll"
#func global SslFreeCertificate "SslFreeCertificate" var
; SslFreeCertificate pCertificate
; pCertificate : X509Certificate* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	schannel = windows.NewLazySystemDLL("SCHANNEL.dll")
	procSslFreeCertificate = schannel.NewProc("SslFreeCertificate")
)

// pCertificate (X509Certificate* in/out)
r1, _, err := procSslFreeCertificate.Call(
	uintptr(pCertificate),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure SslFreeCertificate(
  pCertificate: Pointer   // X509Certificate* in/out
); stdcall;
  external 'SCHANNEL.dll' name 'SslFreeCertificate';
result := DllCall("SCHANNEL\SslFreeCertificate"
    , "Ptr", pCertificate   ; X509Certificate* in/out
    , "Int")   ; return: void
●SslFreeCertificate(pCertificate) = DLL("SCHANNEL.dll", "int SslFreeCertificate(void*)")
# 呼び出し: SslFreeCertificate(pCertificate)
# pCertificate : X509Certificate* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "schannel" fn SslFreeCertificate(
    pCertificate: [*c]X509Certificate // X509Certificate* in/out
) callconv(std.os.windows.WINAPI) void;
proc SslFreeCertificate(
    pCertificate: ptr X509Certificate  # X509Certificate* in/out
) {.importc: "SslFreeCertificate", stdcall, dynlib: "SCHANNEL.dll".}
pragma(lib, "schannel");
extern(Windows)
void SslFreeCertificate(
    X509Certificate* pCertificate   // X509Certificate* in/out
);
ccall((:SslFreeCertificate, "SCHANNEL.dll"), stdcall, Cvoid,
      (Ptr{X509Certificate},),
      pCertificate)
# pCertificate : X509Certificate* in/out -> Ptr{X509Certificate}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void SslFreeCertificate(
    void* pCertificate);
]]
local schannel = ffi.load("schannel")
-- schannel.SslFreeCertificate(pCertificate)
-- pCertificate : X509Certificate* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SCHANNEL.dll');
const SslFreeCertificate = lib.func('__stdcall', 'SslFreeCertificate', 'void', ['void *']);
// SslFreeCertificate(pCertificate)
// pCertificate : X509Certificate* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SCHANNEL.dll", {
  SslFreeCertificate: { parameters: ["pointer"], result: "void" },
});
// lib.symbols.SslFreeCertificate(pCertificate)
// pCertificate : X509Certificate* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void SslFreeCertificate(
    void* pCertificate);
C, "SCHANNEL.dll");
// $ffi->SslFreeCertificate(pCertificate);
// pCertificate : X509Certificate* 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 Schannel extends StdCallLibrary {
    Schannel INSTANCE = Native.load("schannel", Schannel.class);
    void SslFreeCertificate(
        Pointer pCertificate   // X509Certificate* in/out
    );
}
@[Link("schannel")]
lib LibSCHANNEL
  fun SslFreeCertificate = SslFreeCertificate(
    pCertificate : X509Certificate*   # X509Certificate* in/out
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SslFreeCertificateNative = Void Function(Pointer<Void>);
typedef SslFreeCertificateDart = void Function(Pointer<Void>);
final SslFreeCertificate = DynamicLibrary.open('SCHANNEL.dll')
    .lookupFunction<SslFreeCertificateNative, SslFreeCertificateDart>('SslFreeCertificate');
// pCertificate : X509Certificate* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure SslFreeCertificate(
  pCertificate: Pointer   // X509Certificate* in/out
); stdcall;
  external 'SCHANNEL.dll' name 'SslFreeCertificate';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SslFreeCertificate"
  c_SslFreeCertificate :: Ptr () -> IO ()
-- pCertificate : X509Certificate* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sslfreecertificate =
  foreign "SslFreeCertificate"
    ((ptr void) @-> returning void)
(* pCertificate : X509Certificate* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library schannel (t "SCHANNEL.dll"))
(cffi:use-foreign-library schannel)

(cffi:defcfun ("SslFreeCertificate" ssl-free-certificate :convention :stdcall) :void
  (p-certificate :pointer))   ; X509Certificate* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SslFreeCertificate = Win32::API::More->new('SCHANNEL',
    'void SslFreeCertificate(LPVOID pCertificate)');
# my $ret = $SslFreeCertificate->Call($pCertificate);
# pCertificate : X509Certificate* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型