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

CertFindSubjectInSortedCTL

関数
ソート済みCTL内から指定した識別子のサブジェクトを検索する。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CertFindSubjectInSortedCTL(
    CRYPT_INTEGER_BLOB* pSubjectIdentifier,
    CTL_CONTEXT* pCtlContext,
    DWORD dwFlags,
    void* pvReserved,   // optional
    CRYPT_INTEGER_BLOB* pEncodedAttributes   // optional
);

パラメーター

名前方向
pSubjectIdentifierCRYPT_INTEGER_BLOB*in
pCtlContextCTL_CONTEXT*in
dwFlagsDWORDin
pvReservedvoid*optional
pEncodedAttributesCRYPT_INTEGER_BLOB*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL CertFindSubjectInSortedCTL(
    CRYPT_INTEGER_BLOB* pSubjectIdentifier,
    CTL_CONTEXT* pCtlContext,
    DWORD dwFlags,
    void* pvReserved,   // optional
    CRYPT_INTEGER_BLOB* pEncodedAttributes   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern bool CertFindSubjectInSortedCTL(
    IntPtr pSubjectIdentifier,   // CRYPT_INTEGER_BLOB*
    IntPtr pCtlContext,   // CTL_CONTEXT*
    uint dwFlags,   // DWORD
    IntPtr pvReserved,   // void* optional
    IntPtr pEncodedAttributes   // CRYPT_INTEGER_BLOB* optional, out
);
<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CertFindSubjectInSortedCTL(
    pSubjectIdentifier As IntPtr,   ' CRYPT_INTEGER_BLOB*
    pCtlContext As IntPtr,   ' CTL_CONTEXT*
    dwFlags As UInteger,   ' DWORD
    pvReserved As IntPtr,   ' void* optional
    pEncodedAttributes As IntPtr   ' CRYPT_INTEGER_BLOB* optional, out
) As Boolean
End Function
' pSubjectIdentifier : CRYPT_INTEGER_BLOB*
' pCtlContext : CTL_CONTEXT*
' dwFlags : DWORD
' pvReserved : void* optional
' pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out
Declare PtrSafe Function CertFindSubjectInSortedCTL Lib "crypt32" ( _
    ByVal pSubjectIdentifier As LongPtr, _
    ByVal pCtlContext As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal pvReserved As LongPtr, _
    ByVal pEncodedAttributes As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertFindSubjectInSortedCTL = ctypes.windll.crypt32.CertFindSubjectInSortedCTL
CertFindSubjectInSortedCTL.restype = wintypes.BOOL
CertFindSubjectInSortedCTL.argtypes = [
    ctypes.c_void_p,  # pSubjectIdentifier : CRYPT_INTEGER_BLOB*
    ctypes.c_void_p,  # pCtlContext : CTL_CONTEXT*
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.POINTER(None),  # pvReserved : void* optional
    ctypes.c_void_p,  # pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPT32.dll')
CertFindSubjectInSortedCTL = Fiddle::Function.new(
  lib['CertFindSubjectInSortedCTL'],
  [
    Fiddle::TYPE_VOIDP,  # pSubjectIdentifier : CRYPT_INTEGER_BLOB*
    Fiddle::TYPE_VOIDP,  # pCtlContext : CTL_CONTEXT*
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # pvReserved : void* optional
    Fiddle::TYPE_VOIDP,  # pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "crypt32")]
extern "system" {
    fn CertFindSubjectInSortedCTL(
        pSubjectIdentifier: *mut CRYPT_INTEGER_BLOB,  // CRYPT_INTEGER_BLOB*
        pCtlContext: *mut CTL_CONTEXT,  // CTL_CONTEXT*
        dwFlags: u32,  // DWORD
        pvReserved: *mut (),  // void* optional
        pEncodedAttributes: *mut CRYPT_INTEGER_BLOB  // CRYPT_INTEGER_BLOB* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll")]
public static extern bool CertFindSubjectInSortedCTL(IntPtr pSubjectIdentifier, IntPtr pCtlContext, uint dwFlags, IntPtr pvReserved, IntPtr pEncodedAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CertFindSubjectInSortedCTL' -Namespace Win32 -PassThru
# $api::CertFindSubjectInSortedCTL(pSubjectIdentifier, pCtlContext, dwFlags, pvReserved, pEncodedAttributes)
#uselib "CRYPT32.dll"
#func global CertFindSubjectInSortedCTL "CertFindSubjectInSortedCTL" sptr, sptr, sptr, sptr, sptr
; CertFindSubjectInSortedCTL varptr(pSubjectIdentifier), varptr(pCtlContext), dwFlags, pvReserved, varptr(pEncodedAttributes)   ; 戻り値は stat
; pSubjectIdentifier : CRYPT_INTEGER_BLOB* -> "sptr"
; pCtlContext : CTL_CONTEXT* -> "sptr"
; dwFlags : DWORD -> "sptr"
; pvReserved : void* optional -> "sptr"
; pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CRYPT32.dll"
#cfunc global CertFindSubjectInSortedCTL "CertFindSubjectInSortedCTL" var, var, int, sptr, var
; res = CertFindSubjectInSortedCTL(pSubjectIdentifier, pCtlContext, dwFlags, pvReserved, pEncodedAttributes)
; pSubjectIdentifier : CRYPT_INTEGER_BLOB* -> "var"
; pCtlContext : CTL_CONTEXT* -> "var"
; dwFlags : DWORD -> "int"
; pvReserved : void* optional -> "sptr"
; pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CertFindSubjectInSortedCTL(CRYPT_INTEGER_BLOB* pSubjectIdentifier, CTL_CONTEXT* pCtlContext, DWORD dwFlags, void* pvReserved, CRYPT_INTEGER_BLOB* pEncodedAttributes)
#uselib "CRYPT32.dll"
#cfunc global CertFindSubjectInSortedCTL "CertFindSubjectInSortedCTL" var, var, int, intptr, var
; res = CertFindSubjectInSortedCTL(pSubjectIdentifier, pCtlContext, dwFlags, pvReserved, pEncodedAttributes)
; pSubjectIdentifier : CRYPT_INTEGER_BLOB* -> "var"
; pCtlContext : CTL_CONTEXT* -> "var"
; dwFlags : DWORD -> "int"
; pvReserved : void* optional -> "intptr"
; pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCertFindSubjectInSortedCTL = crypt32.NewProc("CertFindSubjectInSortedCTL")
)

// pSubjectIdentifier (CRYPT_INTEGER_BLOB*), pCtlContext (CTL_CONTEXT*), dwFlags (DWORD), pvReserved (void* optional), pEncodedAttributes (CRYPT_INTEGER_BLOB* optional, out)
r1, _, err := procCertFindSubjectInSortedCTL.Call(
	uintptr(pSubjectIdentifier),
	uintptr(pCtlContext),
	uintptr(dwFlags),
	uintptr(pvReserved),
	uintptr(pEncodedAttributes),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CertFindSubjectInSortedCTL(
  pSubjectIdentifier: Pointer;   // CRYPT_INTEGER_BLOB*
  pCtlContext: Pointer;   // CTL_CONTEXT*
  dwFlags: DWORD;   // DWORD
  pvReserved: Pointer;   // void* optional
  pEncodedAttributes: Pointer   // CRYPT_INTEGER_BLOB* optional, out
): BOOL; stdcall;
  external 'CRYPT32.dll' name 'CertFindSubjectInSortedCTL';
result := DllCall("CRYPT32\CertFindSubjectInSortedCTL"
    , "Ptr", pSubjectIdentifier   ; CRYPT_INTEGER_BLOB*
    , "Ptr", pCtlContext   ; CTL_CONTEXT*
    , "UInt", dwFlags   ; DWORD
    , "Ptr", pvReserved   ; void* optional
    , "Ptr", pEncodedAttributes   ; CRYPT_INTEGER_BLOB* optional, out
    , "Int")   ; return: BOOL
●CertFindSubjectInSortedCTL(pSubjectIdentifier, pCtlContext, dwFlags, pvReserved, pEncodedAttributes) = DLL("CRYPT32.dll", "bool CertFindSubjectInSortedCTL(void*, void*, dword, void*, void*)")
# 呼び出し: CertFindSubjectInSortedCTL(pSubjectIdentifier, pCtlContext, dwFlags, pvReserved, pEncodedAttributes)
# pSubjectIdentifier : CRYPT_INTEGER_BLOB* -> "void*"
# pCtlContext : CTL_CONTEXT* -> "void*"
# dwFlags : DWORD -> "dword"
# pvReserved : void* optional -> "void*"
# pEncodedAttributes : CRYPT_INTEGER_BLOB* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。