Win32 API 日本語リファレンス
ホームSecurity.Cryptography › CertFindCRLInStore

CertFindCRLInStore

関数
指定条件に合致するCRLをストアから検索する。
DLLCRYPT32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

CRL_CONTEXT* CertFindCRLInStore(
    HCERTSTORE hCertStore,
    CERT_QUERY_ENCODING_TYPE dwCertEncodingType,
    DWORD dwFindFlags,
    DWORD dwFindType,
    const void* pvFindPara,   // optional
    CRL_CONTEXT* pPrevCrlContext   // optional
);

パラメーター

名前方向説明
hCertStoreHCERTSTOREin検索対象となる証明書ストアのハンドル。
dwCertEncodingTypeCERT_QUERY_ENCODING_TYPEinこのパラメーターは現在使用されていません。ゼロに設定する必要があります。
dwFindFlagsDWORDin

dwFindTypeCRL_FIND_ISSUED_BY の場合、既定では発行者名の照合のみが行われます。次のフラグを使用すると、追加のフィルタリングを行えます。

意味
CRL_FIND_ISSUED_BY_AKI_FLAG
Authority Key Identifier (AKI) 拡張を持つ CRL かどうかを確認します。CRL が AKI を持つ場合、その AKI が発行者と一致する CRL のみが返されます。
注意 AKI 拡張はオブジェクト識別子 (OID) 値 szOID_AUTHORITY_KEY_IDENTIFIER2 と、それに対応するデータ構造を持ちます。
CRL_FIND_ISSUED_BY_SIGNATURE_FLAG
発行者の証明書に含まれる公開キーを使用して、CRL の署名を検証します。有効な署名を持つ CRL のみを返します。
CRL_FIND_ISSUED_BY_DELTA_FLAG
デルタ CRL を検索して返します。
CRL_FIND_ISSUED_BY_BASE_FLAG
ベース CRL を検索して返します。
CRL_FIND_ISSUED_FOR_SET_STRONG_PROPERTIES_FLAG
検証に成功した後、署名の強度がチェックされます。このフラグは dwFindType パラメーターが CRL_FIND_ISSUED_FOR に設定されている場合にのみ適用されます。CRL_FIND_ISSUED_BY_SIGNATURE_FLAG も設定する必要があります。成功した場合、CRL コンテキストに次の強い署名プロパティが設定されます。 Windows 8 および Windows Server 2012: このフラグはこのバージョンからサポートされます。
dwFindTypeDWORDin

実行する検索の種類を指定します。dwFindType の値によって、pvFindPara パラメーターのデータ型、内容、および用途が決まります。現在定義されている検索の種類と、それぞれの pvFindPara の要件は次のとおりです。

意味
CRL_FIND_ANY
pvFindPara パラメーターは使用されません。NULL に設定する必要があります。
検索条件はありません。ストア内の次の CRL が返されます。
CRL_FIND_ISSUED_BY
CERT_CONTEXT へのポインター。
CERT_CONTEXT 内の発行者に一致する、ストア内の次の CRL を検索します。
CRL_FIND_EXISTING
CRL_CONTEXT へのポインター。
次の方法で CRL_CONTEXT に一致する次の CRL を検索します。
  • 両方がベース CRL であるか、両方がデルタ CRL である。
  • 両方の発行者名 BLOB が同一である。
  • 存在する場合、Authority/KeyIdentifier および IssuingDistributionPoint のエンコード済み拡張 BLOB が一致する。
CRL_FIND_ISSUED_FOR
CRL_FIND_ISSUED_FOR_PARA へのポインター。
CRL_FIND_ISSUED_FOR_PARA 構造体内のサブジェクト証明書の発行者に一致する、ストア内の次の CRL を検索します。

CRL が見つからない場合は、CRL_FIND_ISSUED_FOR_PARA 構造体内の発行者に一致する、ストア内の次の CRL を検索します。

注意 クロス証明書を使用する場合、発行者の証明書内のサブジェクト名が、サブジェクト証明書および対応する CRL 内の発行者名と一致しないことがあります。
pvFindParavoid*inoptionalこのパラメーターは dwFindType の値によって決まります。詳細については、このトピックの前出の表を参照してください。
pPrevCrlContextCRL_CONTEXT*inoptionalこの関数によって最後に返された CRL_CONTEXT へのポインター。検索条件を満たすストア内の最初の CRL を取得するには NULL にする必要があります。検索条件を満たす後続の CRL は、pPrevCrlContext を、この関数の前回の呼び出しで返された PCCRL_CONTEXT ポインターに設定することで取得できます。検索処理では、検索条件に一致しない CRL や、 CertDeleteCRLFromStore によってストアから以前に削除された CRL はスキップされます。この関数は、このパラメーターの値が NULL でない場合、その値が参照する CRL_CONTEXT を解放します。

戻り値の型: CRL_CONTEXT*

公式ドキュメント

証明書ストア内で、dwFindType パラメーターおよび関連する pvFindPara パラメーターによって指定された検索条件に一致する、最初または次の証明書失効リスト (CRL) コンテキストを検索します。

戻り値

関数が成功した場合、読み取り専用の CRL コンテキストへのポインターが返されます。返された CRL コンテキストの使用が終わったら、 CertFreeCRLContext 関数を呼び出して解放するか、後続の CertFindCRLInStore 関数の呼び出しで pPrevCrlContext パラメーターとして渡すことで暗黙的に解放します。

関数が失敗し、検索条件に一致する CRL が見つからなかった場合、戻り値は NULL です。拡張エラー情報を取得するには、 GetLastError を呼び出します。考えられるエラーコードの一部を次に示します。

戻りコード 説明
E_INVALIDARG
hCertStore パラメーターのハンドルが、pPrevCrlContext パラメーターが指す CRL コンテキスト内のハンドルと一致しないか、dwFindType パラメーターに無効な検索の種類が指定されました。
CRYPT_E_NOT_FOUND
ストアに CRL が存在しないか、検索条件に一致する CRL が見つからなかったか、ストアのリストの末尾に達しました。

解説(Remarks)

返されたポインターは、後続の関数呼び出しで pPrevCrlContext パラメーターとして渡されると解放されます。それ以外の場合は、 CertFreeCRLContext を呼び出して明示的に解放する必要があります。NULL でない pPrevCrlContext は、関数内でエラーが発生した場合でも、CertFindCRLInStore によって CertFreeCRLContext の呼び出しを使用して常に解放されます。

CertDuplicateCRLContext を呼び出すことで、返されたコンテキストの複製を作成できます。返された CRL コンテキストは、 CertAddCRLContextToStore を使用して別の証明書ストアに追加できます。また、 CertAddCRLLinkToStore を使用して、その CRL コンテキストへのリンクを非コレクションストアに追加することもできます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

CRL_CONTEXT* CertFindCRLInStore(
    HCERTSTORE hCertStore,
    CERT_QUERY_ENCODING_TYPE dwCertEncodingType,
    DWORD dwFindFlags,
    DWORD dwFindType,
    const void* pvFindPara,   // optional
    CRL_CONTEXT* pPrevCrlContext   // optional
);
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CertFindCRLInStore(
    IntPtr hCertStore,   // HCERTSTORE
    uint dwCertEncodingType,   // CERT_QUERY_ENCODING_TYPE
    uint dwFindFlags,   // DWORD
    uint dwFindType,   // DWORD
    IntPtr pvFindPara,   // void* optional
    IntPtr pPrevCrlContext   // CRL_CONTEXT* optional
);
<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CertFindCRLInStore(
    hCertStore As IntPtr,   ' HCERTSTORE
    dwCertEncodingType As UInteger,   ' CERT_QUERY_ENCODING_TYPE
    dwFindFlags As UInteger,   ' DWORD
    dwFindType As UInteger,   ' DWORD
    pvFindPara As IntPtr,   ' void* optional
    pPrevCrlContext As IntPtr   ' CRL_CONTEXT* optional
) As IntPtr
End Function
' hCertStore : HCERTSTORE
' dwCertEncodingType : CERT_QUERY_ENCODING_TYPE
' dwFindFlags : DWORD
' dwFindType : DWORD
' pvFindPara : void* optional
' pPrevCrlContext : CRL_CONTEXT* optional
Declare PtrSafe Function CertFindCRLInStore Lib "crypt32" ( _
    ByVal hCertStore As LongPtr, _
    ByVal dwCertEncodingType As Long, _
    ByVal dwFindFlags As Long, _
    ByVal dwFindType As Long, _
    ByVal pvFindPara As LongPtr, _
    ByVal pPrevCrlContext As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertFindCRLInStore = ctypes.windll.crypt32.CertFindCRLInStore
CertFindCRLInStore.restype = ctypes.c_void_p
CertFindCRLInStore.argtypes = [
    wintypes.HANDLE,  # hCertStore : HCERTSTORE
    wintypes.DWORD,  # dwCertEncodingType : CERT_QUERY_ENCODING_TYPE
    wintypes.DWORD,  # dwFindFlags : DWORD
    wintypes.DWORD,  # dwFindType : DWORD
    ctypes.POINTER(None),  # pvFindPara : void* optional
    ctypes.c_void_p,  # pPrevCrlContext : CRL_CONTEXT* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPT32.dll')
CertFindCRLInStore = Fiddle::Function.new(
  lib['CertFindCRLInStore'],
  [
    Fiddle::TYPE_VOIDP,  # hCertStore : HCERTSTORE
    -Fiddle::TYPE_INT,  # dwCertEncodingType : CERT_QUERY_ENCODING_TYPE
    -Fiddle::TYPE_INT,  # dwFindFlags : DWORD
    -Fiddle::TYPE_INT,  # dwFindType : DWORD
    Fiddle::TYPE_VOIDP,  # pvFindPara : void* optional
    Fiddle::TYPE_VOIDP,  # pPrevCrlContext : CRL_CONTEXT* optional
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "crypt32")]
extern "system" {
    fn CertFindCRLInStore(
        hCertStore: *mut core::ffi::c_void,  // HCERTSTORE
        dwCertEncodingType: u32,  // CERT_QUERY_ENCODING_TYPE
        dwFindFlags: u32,  // DWORD
        dwFindType: u32,  // DWORD
        pvFindPara: *const (),  // void* optional
        pPrevCrlContext: *mut CRL_CONTEXT  // CRL_CONTEXT* optional
    ) -> *mut CRL_CONTEXT;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern IntPtr CertFindCRLInStore(IntPtr hCertStore, uint dwCertEncodingType, uint dwFindFlags, uint dwFindType, IntPtr pvFindPara, IntPtr pPrevCrlContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CertFindCRLInStore' -Namespace Win32 -PassThru
# $api::CertFindCRLInStore(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext)
#uselib "CRYPT32.dll"
#func global CertFindCRLInStore "CertFindCRLInStore" sptr, sptr, sptr, sptr, sptr, sptr
; CertFindCRLInStore hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, varptr(pPrevCrlContext)   ; 戻り値は stat
; hCertStore : HCERTSTORE -> "sptr"
; dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> "sptr"
; dwFindFlags : DWORD -> "sptr"
; dwFindType : DWORD -> "sptr"
; pvFindPara : void* optional -> "sptr"
; pPrevCrlContext : CRL_CONTEXT* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CRYPT32.dll"
#cfunc global CertFindCRLInStore "CertFindCRLInStore" sptr, int, int, int, sptr, var
; res = CertFindCRLInStore(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext)
; hCertStore : HCERTSTORE -> "sptr"
; dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> "int"
; dwFindFlags : DWORD -> "int"
; dwFindType : DWORD -> "int"
; pvFindPara : void* optional -> "sptr"
; pPrevCrlContext : CRL_CONTEXT* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; CRL_CONTEXT* CertFindCRLInStore(HCERTSTORE hCertStore, CERT_QUERY_ENCODING_TYPE dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, void* pvFindPara, CRL_CONTEXT* pPrevCrlContext)
#uselib "CRYPT32.dll"
#cfunc global CertFindCRLInStore "CertFindCRLInStore" intptr, int, int, int, intptr, var
; res = CertFindCRLInStore(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext)
; hCertStore : HCERTSTORE -> "intptr"
; dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> "int"
; dwFindFlags : DWORD -> "int"
; dwFindType : DWORD -> "int"
; pvFindPara : void* optional -> "intptr"
; pPrevCrlContext : CRL_CONTEXT* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCertFindCRLInStore = crypt32.NewProc("CertFindCRLInStore")
)

// hCertStore (HCERTSTORE), dwCertEncodingType (CERT_QUERY_ENCODING_TYPE), dwFindFlags (DWORD), dwFindType (DWORD), pvFindPara (void* optional), pPrevCrlContext (CRL_CONTEXT* optional)
r1, _, err := procCertFindCRLInStore.Call(
	uintptr(hCertStore),
	uintptr(dwCertEncodingType),
	uintptr(dwFindFlags),
	uintptr(dwFindType),
	uintptr(pvFindPara),
	uintptr(pPrevCrlContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CRL_CONTEXT*
function CertFindCRLInStore(
  hCertStore: THandle;   // HCERTSTORE
  dwCertEncodingType: DWORD;   // CERT_QUERY_ENCODING_TYPE
  dwFindFlags: DWORD;   // DWORD
  dwFindType: DWORD;   // DWORD
  pvFindPara: Pointer;   // void* optional
  pPrevCrlContext: Pointer   // CRL_CONTEXT* optional
): Pointer; stdcall;
  external 'CRYPT32.dll' name 'CertFindCRLInStore';
result := DllCall("CRYPT32\CertFindCRLInStore"
    , "Ptr", hCertStore   ; HCERTSTORE
    , "UInt", dwCertEncodingType   ; CERT_QUERY_ENCODING_TYPE
    , "UInt", dwFindFlags   ; DWORD
    , "UInt", dwFindType   ; DWORD
    , "Ptr", pvFindPara   ; void* optional
    , "Ptr", pPrevCrlContext   ; CRL_CONTEXT* optional
    , "Ptr")   ; return: CRL_CONTEXT*
●CertFindCRLInStore(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext) = DLL("CRYPT32.dll", "void* CertFindCRLInStore(void*, dword, dword, dword, void*, void*)")
# 呼び出し: CertFindCRLInStore(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext)
# hCertStore : HCERTSTORE -> "void*"
# dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> "dword"
# dwFindFlags : DWORD -> "dword"
# dwFindType : DWORD -> "dword"
# pvFindPara : void* optional -> "void*"
# pPrevCrlContext : CRL_CONTEXT* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef CertFindCRLInStoreNative = Pointer<Void> Function(Pointer<Void>, Uint32, Uint32, Uint32, Pointer<Void>, Pointer<Void>);
typedef CertFindCRLInStoreDart = Pointer<Void> Function(Pointer<Void>, int, int, int, Pointer<Void>, Pointer<Void>);
final CertFindCRLInStore = DynamicLibrary.open('CRYPT32.dll')
    .lookupFunction<CertFindCRLInStoreNative, CertFindCRLInStoreDart>('CertFindCRLInStore');
// hCertStore : HCERTSTORE -> Pointer<Void>
// dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> Uint32
// dwFindFlags : DWORD -> Uint32
// dwFindType : DWORD -> Uint32
// pvFindPara : void* optional -> Pointer<Void>
// pPrevCrlContext : CRL_CONTEXT* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CertFindCRLInStore(
  hCertStore: THandle;   // HCERTSTORE
  dwCertEncodingType: DWORD;   // CERT_QUERY_ENCODING_TYPE
  dwFindFlags: DWORD;   // DWORD
  dwFindType: DWORD;   // DWORD
  pvFindPara: Pointer;   // void* optional
  pPrevCrlContext: Pointer   // CRL_CONTEXT* optional
): Pointer; stdcall;
  external 'CRYPT32.dll' name 'CertFindCRLInStore';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CertFindCRLInStore"
  c_CertFindCRLInStore :: Ptr () -> Word32 -> Word32 -> Word32 -> Ptr () -> Ptr () -> IO (Ptr ())
-- hCertStore : HCERTSTORE -> Ptr ()
-- dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> Word32
-- dwFindFlags : DWORD -> Word32
-- dwFindType : DWORD -> Word32
-- pvFindPara : void* optional -> Ptr ()
-- pPrevCrlContext : CRL_CONTEXT* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let certfindcrlinstore =
  foreign "CertFindCRLInStore"
    ((ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning (ptr void))
(* hCertStore : HCERTSTORE -> (ptr void) *)
(* dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> uint32_t *)
(* dwFindFlags : DWORD -> uint32_t *)
(* dwFindType : DWORD -> uint32_t *)
(* pvFindPara : void* optional -> (ptr void) *)
(* pPrevCrlContext : CRL_CONTEXT* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library crypt32 (t "CRYPT32.dll"))
(cffi:use-foreign-library crypt32)

(cffi:defcfun ("CertFindCRLInStore" cert-find-crlin-store :convention :stdcall) :pointer
  (h-cert-store :pointer)   ; HCERTSTORE
  (dw-cert-encoding-type :uint32)   ; CERT_QUERY_ENCODING_TYPE
  (dw-find-flags :uint32)   ; DWORD
  (dw-find-type :uint32)   ; DWORD
  (pv-find-para :pointer)   ; void* optional
  (p-prev-crl-context :pointer))   ; CRL_CONTEXT* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CertFindCRLInStore = Win32::API::More->new('CRYPT32',
    'LPVOID CertFindCRLInStore(HANDLE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, LPVOID pvFindPara, LPVOID pPrevCrlContext)');
# my $ret = $CertFindCRLInStore->Call($hCertStore, $dwCertEncodingType, $dwFindFlags, $dwFindType, $pvFindPara, $pPrevCrlContext);
# hCertStore : HCERTSTORE -> HANDLE
# dwCertEncodingType : CERT_QUERY_ENCODING_TYPE -> DWORD
# dwFindFlags : DWORD -> DWORD
# dwFindType : DWORD -> DWORD
# pvFindPara : void* optional -> LPVOID
# pPrevCrlContext : CRL_CONTEXT* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型