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

PstMapCertificate

関数
証明書をトークン情報にマッピングして取得する。
DLLcertpoleng.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

NTSTATUS PstMapCertificate(
    const CERT_CONTEXT* pCert,
    LSA_TOKEN_INFORMATION_TYPE* pTokenInformationType,
    void** ppTokenInformation
);

パラメーター

名前方向
pCertCERT_CONTEXT*in
pTokenInformationTypeLSA_TOKEN_INFORMATION_TYPE*out
ppTokenInformationvoid**out

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS PstMapCertificate(
    const CERT_CONTEXT* pCert,
    LSA_TOKEN_INFORMATION_TYPE* pTokenInformationType,
    void** ppTokenInformation
);
[DllImport("certpoleng.dll", ExactSpelling = true)]
static extern int PstMapCertificate(
    IntPtr pCert,   // CERT_CONTEXT*
    out int pTokenInformationType,   // LSA_TOKEN_INFORMATION_TYPE* out
    IntPtr ppTokenInformation   // void** out
);
<DllImport("certpoleng.dll", ExactSpelling:=True)>
Public Shared Function PstMapCertificate(
    pCert As IntPtr,   ' CERT_CONTEXT*
    <Out> ByRef pTokenInformationType As Integer,   ' LSA_TOKEN_INFORMATION_TYPE* out
    ppTokenInformation As IntPtr   ' void** out
) As Integer
End Function
' pCert : CERT_CONTEXT*
' pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out
' ppTokenInformation : void** out
Declare PtrSafe Function PstMapCertificate Lib "certpoleng" ( _
    ByVal pCert As LongPtr, _
    ByRef pTokenInformationType As Long, _
    ByVal ppTokenInformation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PstMapCertificate = ctypes.windll.certpoleng.PstMapCertificate
PstMapCertificate.restype = ctypes.c_int
PstMapCertificate.argtypes = [
    ctypes.c_void_p,  # pCert : CERT_CONTEXT*
    ctypes.c_void_p,  # pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out
    ctypes.c_void_p,  # ppTokenInformation : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('certpoleng.dll')
PstMapCertificate = Fiddle::Function.new(
  lib['PstMapCertificate'],
  [
    Fiddle::TYPE_VOIDP,  # pCert : CERT_CONTEXT*
    Fiddle::TYPE_VOIDP,  # pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out
    Fiddle::TYPE_VOIDP,  # ppTokenInformation : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "certpoleng")]
extern "system" {
    fn PstMapCertificate(
        pCert: *const CERT_CONTEXT,  // CERT_CONTEXT*
        pTokenInformationType: *mut i32,  // LSA_TOKEN_INFORMATION_TYPE* out
        ppTokenInformation: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("certpoleng.dll")]
public static extern int PstMapCertificate(IntPtr pCert, out int pTokenInformationType, IntPtr ppTokenInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'certpoleng_PstMapCertificate' -Namespace Win32 -PassThru
# $api::PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation)
#uselib "certpoleng.dll"
#func global PstMapCertificate "PstMapCertificate" sptr, sptr, sptr
; PstMapCertificate varptr(pCert), pTokenInformationType, ppTokenInformation   ; 戻り値は stat
; pCert : CERT_CONTEXT* -> "sptr"
; pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> "sptr"
; ppTokenInformation : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "certpoleng.dll"
#cfunc global PstMapCertificate "PstMapCertificate" var, int, sptr
; res = PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation)
; pCert : CERT_CONTEXT* -> "var"
; pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> "int"
; ppTokenInformation : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; NTSTATUS PstMapCertificate(CERT_CONTEXT* pCert, LSA_TOKEN_INFORMATION_TYPE* pTokenInformationType, void** ppTokenInformation)
#uselib "certpoleng.dll"
#cfunc global PstMapCertificate "PstMapCertificate" var, int, intptr
; res = PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation)
; pCert : CERT_CONTEXT* -> "var"
; pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> "int"
; ppTokenInformation : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	certpoleng = windows.NewLazySystemDLL("certpoleng.dll")
	procPstMapCertificate = certpoleng.NewProc("PstMapCertificate")
)

// pCert (CERT_CONTEXT*), pTokenInformationType (LSA_TOKEN_INFORMATION_TYPE* out), ppTokenInformation (void** out)
r1, _, err := procPstMapCertificate.Call(
	uintptr(pCert),
	uintptr(pTokenInformationType),
	uintptr(ppTokenInformation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function PstMapCertificate(
  pCert: Pointer;   // CERT_CONTEXT*
  pTokenInformationType: Pointer;   // LSA_TOKEN_INFORMATION_TYPE* out
  ppTokenInformation: Pointer   // void** out
): Integer; stdcall;
  external 'certpoleng.dll' name 'PstMapCertificate';
result := DllCall("certpoleng\PstMapCertificate"
    , "Ptr", pCert   ; CERT_CONTEXT*
    , "Ptr", pTokenInformationType   ; LSA_TOKEN_INFORMATION_TYPE* out
    , "Ptr", ppTokenInformation   ; void** out
    , "Int")   ; return: NTSTATUS
●PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation) = DLL("certpoleng.dll", "int PstMapCertificate(void*, void*, void*)")
# 呼び出し: PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation)
# pCert : CERT_CONTEXT* -> "void*"
# pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> "void*"
# ppTokenInformation : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。