ホーム › Security.Cryptography.Catalog › CryptCATAdminAcquireContext2
CryptCATAdminAcquireContext2
関数ハッシュアルゴリズムや署名ポリシーを指定してカタログ管理コンテキストを取得する。
シグネチャ
// WINTRUST.dll
#include <windows.h>
BOOL CryptCATAdminAcquireContext2(
INT_PTR* phCatAdmin,
const GUID* pgSubsystem, // optional
LPCWSTR pwszHashAlgorithm, // optional
CERT_STRONG_SIGN_PARA* pStrongHashPolicy, // optional
DWORD dwFlags // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| phCatAdmin | INT_PTR* | out |
| pgSubsystem | GUID* | inoptional |
| pwszHashAlgorithm | LPCWSTR | inoptional |
| pStrongHashPolicy | CERT_STRONG_SIGN_PARA* | inoptional |
| dwFlags | DWORD | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// WINTRUST.dll
#include <windows.h>
BOOL CryptCATAdminAcquireContext2(
INT_PTR* phCatAdmin,
const GUID* pgSubsystem, // optional
LPCWSTR pwszHashAlgorithm, // optional
CERT_STRONG_SIGN_PARA* pStrongHashPolicy, // optional
DWORD dwFlags // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINTRUST.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptCATAdminAcquireContext2(
out IntPtr phCatAdmin, // INT_PTR* out
IntPtr pgSubsystem, // GUID* optional
[MarshalAs(UnmanagedType.LPWStr)] string pwszHashAlgorithm, // LPCWSTR optional
IntPtr pStrongHashPolicy, // CERT_STRONG_SIGN_PARA* optional
uint dwFlags // DWORD optional
);<DllImport("WINTRUST.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptCATAdminAcquireContext2(
<Out> ByRef phCatAdmin As IntPtr, ' INT_PTR* out
pgSubsystem As IntPtr, ' GUID* optional
<MarshalAs(UnmanagedType.LPWStr)> pwszHashAlgorithm As String, ' LPCWSTR optional
pStrongHashPolicy As IntPtr, ' CERT_STRONG_SIGN_PARA* optional
dwFlags As UInteger ' DWORD optional
) As Boolean
End Function' phCatAdmin : INT_PTR* out
' pgSubsystem : GUID* optional
' pwszHashAlgorithm : LPCWSTR optional
' pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional
' dwFlags : DWORD optional
Declare PtrSafe Function CryptCATAdminAcquireContext2 Lib "wintrust" ( _
ByRef phCatAdmin As LongPtr, _
ByVal pgSubsystem As LongPtr, _
ByVal pwszHashAlgorithm As LongPtr, _
ByVal pStrongHashPolicy As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptCATAdminAcquireContext2 = ctypes.windll.wintrust.CryptCATAdminAcquireContext2
CryptCATAdminAcquireContext2.restype = wintypes.BOOL
CryptCATAdminAcquireContext2.argtypes = [
ctypes.POINTER(ctypes.c_ssize_t), # phCatAdmin : INT_PTR* out
ctypes.c_void_p, # pgSubsystem : GUID* optional
wintypes.LPCWSTR, # pwszHashAlgorithm : LPCWSTR optional
ctypes.c_void_p, # pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional
wintypes.DWORD, # dwFlags : DWORD optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINTRUST.dll')
CryptCATAdminAcquireContext2 = Fiddle::Function.new(
lib['CryptCATAdminAcquireContext2'],
[
Fiddle::TYPE_VOIDP, # phCatAdmin : INT_PTR* out
Fiddle::TYPE_VOIDP, # pgSubsystem : GUID* optional
Fiddle::TYPE_VOIDP, # pwszHashAlgorithm : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional
-Fiddle::TYPE_INT, # dwFlags : DWORD optional
],
Fiddle::TYPE_INT)#[link(name = "wintrust")]
extern "system" {
fn CryptCATAdminAcquireContext2(
phCatAdmin: *mut isize, // INT_PTR* out
pgSubsystem: *const GUID, // GUID* optional
pwszHashAlgorithm: *const u16, // LPCWSTR optional
pStrongHashPolicy: *mut CERT_STRONG_SIGN_PARA, // CERT_STRONG_SIGN_PARA* optional
dwFlags: u32 // DWORD optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINTRUST.dll", SetLastError = true)]
public static extern bool CryptCATAdminAcquireContext2(out IntPtr phCatAdmin, IntPtr pgSubsystem, [MarshalAs(UnmanagedType.LPWStr)] string pwszHashAlgorithm, IntPtr pStrongHashPolicy, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINTRUST_CryptCATAdminAcquireContext2' -Namespace Win32 -PassThru
# $api::CryptCATAdminAcquireContext2(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags)#uselib "WINTRUST.dll"
#func global CryptCATAdminAcquireContext2 "CryptCATAdminAcquireContext2" sptr, sptr, sptr, sptr, sptr
; CryptCATAdminAcquireContext2 varptr(phCatAdmin), varptr(pgSubsystem), pwszHashAlgorithm, varptr(pStrongHashPolicy), dwFlags ; 戻り値は stat
; phCatAdmin : INT_PTR* out -> "sptr"
; pgSubsystem : GUID* optional -> "sptr"
; pwszHashAlgorithm : LPCWSTR optional -> "sptr"
; pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional -> "sptr"
; dwFlags : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WINTRUST.dll" #cfunc global CryptCATAdminAcquireContext2 "CryptCATAdminAcquireContext2" var, var, wstr, var, int ; res = CryptCATAdminAcquireContext2(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags) ; phCatAdmin : INT_PTR* out -> "var" ; pgSubsystem : GUID* optional -> "var" ; pwszHashAlgorithm : LPCWSTR optional -> "wstr" ; pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional -> "var" ; dwFlags : DWORD optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WINTRUST.dll" #cfunc global CryptCATAdminAcquireContext2 "CryptCATAdminAcquireContext2" sptr, sptr, wstr, sptr, int ; res = CryptCATAdminAcquireContext2(varptr(phCatAdmin), varptr(pgSubsystem), pwszHashAlgorithm, varptr(pStrongHashPolicy), dwFlags) ; phCatAdmin : INT_PTR* out -> "sptr" ; pgSubsystem : GUID* optional -> "sptr" ; pwszHashAlgorithm : LPCWSTR optional -> "wstr" ; pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional -> "sptr" ; dwFlags : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CryptCATAdminAcquireContext2(INT_PTR* phCatAdmin, GUID* pgSubsystem, LPCWSTR pwszHashAlgorithm, CERT_STRONG_SIGN_PARA* pStrongHashPolicy, DWORD dwFlags) #uselib "WINTRUST.dll" #cfunc global CryptCATAdminAcquireContext2 "CryptCATAdminAcquireContext2" var, var, wstr, var, int ; res = CryptCATAdminAcquireContext2(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags) ; phCatAdmin : INT_PTR* out -> "var" ; pgSubsystem : GUID* optional -> "var" ; pwszHashAlgorithm : LPCWSTR optional -> "wstr" ; pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional -> "var" ; dwFlags : DWORD optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CryptCATAdminAcquireContext2(INT_PTR* phCatAdmin, GUID* pgSubsystem, LPCWSTR pwszHashAlgorithm, CERT_STRONG_SIGN_PARA* pStrongHashPolicy, DWORD dwFlags) #uselib "WINTRUST.dll" #cfunc global CryptCATAdminAcquireContext2 "CryptCATAdminAcquireContext2" intptr, intptr, wstr, intptr, int ; res = CryptCATAdminAcquireContext2(varptr(phCatAdmin), varptr(pgSubsystem), pwszHashAlgorithm, varptr(pStrongHashPolicy), dwFlags) ; phCatAdmin : INT_PTR* out -> "intptr" ; pgSubsystem : GUID* optional -> "intptr" ; pwszHashAlgorithm : LPCWSTR optional -> "wstr" ; pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional -> "intptr" ; dwFlags : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wintrust = windows.NewLazySystemDLL("WINTRUST.dll")
procCryptCATAdminAcquireContext2 = wintrust.NewProc("CryptCATAdminAcquireContext2")
)
// phCatAdmin (INT_PTR* out), pgSubsystem (GUID* optional), pwszHashAlgorithm (LPCWSTR optional), pStrongHashPolicy (CERT_STRONG_SIGN_PARA* optional), dwFlags (DWORD optional)
r1, _, err := procCryptCATAdminAcquireContext2.Call(
uintptr(phCatAdmin),
uintptr(pgSubsystem),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszHashAlgorithm))),
uintptr(pStrongHashPolicy),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptCATAdminAcquireContext2(
phCatAdmin: Pointer; // INT_PTR* out
pgSubsystem: PGUID; // GUID* optional
pwszHashAlgorithm: PWideChar; // LPCWSTR optional
pStrongHashPolicy: Pointer; // CERT_STRONG_SIGN_PARA* optional
dwFlags: DWORD // DWORD optional
): BOOL; stdcall;
external 'WINTRUST.dll' name 'CryptCATAdminAcquireContext2';result := DllCall("WINTRUST\CryptCATAdminAcquireContext2"
, "Ptr", phCatAdmin ; INT_PTR* out
, "Ptr", pgSubsystem ; GUID* optional
, "WStr", pwszHashAlgorithm ; LPCWSTR optional
, "Ptr", pStrongHashPolicy ; CERT_STRONG_SIGN_PARA* optional
, "UInt", dwFlags ; DWORD optional
, "Int") ; return: BOOL●CryptCATAdminAcquireContext2(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags) = DLL("WINTRUST.dll", "bool CryptCATAdminAcquireContext2(void*, void*, char*, void*, dword)")
# 呼び出し: CryptCATAdminAcquireContext2(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags)
# phCatAdmin : INT_PTR* out -> "void*"
# pgSubsystem : GUID* optional -> "void*"
# pwszHashAlgorithm : LPCWSTR optional -> "char*"
# pStrongHashPolicy : CERT_STRONG_SIGN_PARA* optional -> "void*"
# dwFlags : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。