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アカウントへマッピングする対象証明書のCERT_CONTEXTへのポインタ。
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), varptr(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, var, sptr
; res = PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation)
; pCert : CERT_CONTEXT* -> "var"
; pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> "var"
; 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, var, intptr
; res = PstMapCertificate(pCert, pTokenInformationType, ppTokenInformation)
; pCert : CERT_CONTEXT* -> "var"
; pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> "var"
; 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)。
const std = @import("std");

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

typedef PstMapCertificateNative = Int32 Function(Pointer<Void>, Pointer<Int32>, Pointer<Void>);
typedef PstMapCertificateDart = int Function(Pointer<Void>, Pointer<Int32>, Pointer<Void>);
final PstMapCertificate = DynamicLibrary.open('certpoleng.dll')
    .lookupFunction<PstMapCertificateNative, PstMapCertificateDart>('PstMapCertificate');
// pCert : CERT_CONTEXT* -> Pointer<Void>
// pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> Pointer<Int32>
// ppTokenInformation : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PstMapCertificate(
  pCert: Pointer;   // CERT_CONTEXT*
  pTokenInformationType: Pointer;   // LSA_TOKEN_INFORMATION_TYPE* out
  ppTokenInformation: Pointer   // void** out
): Integer; stdcall;
  external 'certpoleng.dll' name 'PstMapCertificate';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PstMapCertificate"
  c_PstMapCertificate :: Ptr () -> Ptr Int32 -> Ptr () -> IO Int32
-- pCert : CERT_CONTEXT* -> Ptr ()
-- pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> Ptr Int32
-- ppTokenInformation : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pstmapcertificate =
  foreign "PstMapCertificate"
    ((ptr void) @-> (ptr int32_t) @-> (ptr void) @-> returning int32_t)
(* pCert : CERT_CONTEXT* -> (ptr void) *)
(* pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> (ptr int32_t) *)
(* ppTokenInformation : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library certpoleng (t "certpoleng.dll"))
(cffi:use-foreign-library certpoleng)

(cffi:defcfun ("PstMapCertificate" pst-map-certificate :convention :stdcall) :int32
  (p-cert :pointer)   ; CERT_CONTEXT*
  (p-token-information-type :pointer)   ; LSA_TOKEN_INFORMATION_TYPE* out
  (pp-token-information :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PstMapCertificate = Win32::API::More->new('certpoleng',
    'int PstMapCertificate(LPVOID pCert, LPVOID pTokenInformationType, LPVOID ppTokenInformation)');
# my $ret = $PstMapCertificate->Call($pCert, $pTokenInformationType, $ppTokenInformation);
# pCert : CERT_CONTEXT* -> LPVOID
# pTokenInformationType : LSA_TOKEN_INFORMATION_TYPE* out -> LPVOID
# ppTokenInformation : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型