Win32 API 日本語リファレンス
ホームData.RightsManagement › DRMConstructCertificateChain

DRMConstructCertificateChain

関数
複数の証明書から証明書チェーンを構築する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMConstructCertificateChain(
    DWORD cCertificates,
    LPWSTR* rgwszCertificates,
    DWORD* pcChain,
    LPWSTR wszChain   // optional
);

パラメーター

名前方向説明
cCertificatesDWORDin結合する証明書の個数。
rgwszCertificatesLPWSTR*in結合対象の証明書文字列配列へのポインタ。
pcChainDWORD*inout入力時にバッファ長、出力時に必要長を示すポインタ。
wszChainLPWSTRoutoptional構築した証明書チェーンを受け取る出力バッファ。NULLでサイズ問い合わせ可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DRMConstructCertificateChain(
    DWORD cCertificates,
    LPWSTR* rgwszCertificates,
    DWORD* pcChain,
    LPWSTR wszChain   // optional
);
[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMConstructCertificateChain(
    uint cCertificates,   // DWORD
    IntPtr rgwszCertificates,   // LPWSTR*
    ref uint pcChain,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszChain   // LPWSTR optional, out
);
<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMConstructCertificateChain(
    cCertificates As UInteger,   ' DWORD
    rgwszCertificates As IntPtr,   ' LPWSTR*
    ByRef pcChain As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> wszChain As System.Text.StringBuilder   ' LPWSTR optional, out
) As Integer
End Function
' cCertificates : DWORD
' rgwszCertificates : LPWSTR*
' pcChain : DWORD* in/out
' wszChain : LPWSTR optional, out
Declare PtrSafe Function DRMConstructCertificateChain Lib "msdrm" ( _
    ByVal cCertificates As Long, _
    ByVal rgwszCertificates As LongPtr, _
    ByRef pcChain As Long, _
    ByVal wszChain As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DRMConstructCertificateChain = ctypes.windll.msdrm.DRMConstructCertificateChain
DRMConstructCertificateChain.restype = ctypes.c_int
DRMConstructCertificateChain.argtypes = [
    wintypes.DWORD,  # cCertificates : DWORD
    ctypes.c_void_p,  # rgwszCertificates : LPWSTR*
    ctypes.POINTER(wintypes.DWORD),  # pcChain : DWORD* in/out
    wintypes.LPWSTR,  # wszChain : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msdrm.dll')
DRMConstructCertificateChain = Fiddle::Function.new(
  lib['DRMConstructCertificateChain'],
  [
    -Fiddle::TYPE_INT,  # cCertificates : DWORD
    Fiddle::TYPE_VOIDP,  # rgwszCertificates : LPWSTR*
    Fiddle::TYPE_VOIDP,  # pcChain : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # wszChain : LPWSTR optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "msdrm")]
extern "system" {
    fn DRMConstructCertificateChain(
        cCertificates: u32,  // DWORD
        rgwszCertificates: *mut *mut u16,  // LPWSTR*
        pcChain: *mut u32,  // DWORD* in/out
        wszChain: *mut u16  // LPWSTR optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMConstructCertificateChain(uint cCertificates, IntPtr rgwszCertificates, ref uint pcChain, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszChain);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMConstructCertificateChain' -Namespace Win32 -PassThru
# $api::DRMConstructCertificateChain(cCertificates, rgwszCertificates, pcChain, wszChain)
#uselib "msdrm.dll"
#func global DRMConstructCertificateChain "DRMConstructCertificateChain" sptr, sptr, sptr, sptr
; DRMConstructCertificateChain cCertificates, varptr(rgwszCertificates), varptr(pcChain), varptr(wszChain)   ; 戻り値は stat
; cCertificates : DWORD -> "sptr"
; rgwszCertificates : LPWSTR* -> "sptr"
; pcChain : DWORD* in/out -> "sptr"
; wszChain : LPWSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msdrm.dll"
#cfunc global DRMConstructCertificateChain "DRMConstructCertificateChain" int, var, var, var
; res = DRMConstructCertificateChain(cCertificates, rgwszCertificates, pcChain, wszChain)
; cCertificates : DWORD -> "int"
; rgwszCertificates : LPWSTR* -> "var"
; pcChain : DWORD* in/out -> "var"
; wszChain : LPWSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT DRMConstructCertificateChain(DWORD cCertificates, LPWSTR* rgwszCertificates, DWORD* pcChain, LPWSTR wszChain)
#uselib "msdrm.dll"
#cfunc global DRMConstructCertificateChain "DRMConstructCertificateChain" int, var, var, var
; res = DRMConstructCertificateChain(cCertificates, rgwszCertificates, pcChain, wszChain)
; cCertificates : DWORD -> "int"
; rgwszCertificates : LPWSTR* -> "var"
; pcChain : DWORD* in/out -> "var"
; wszChain : LPWSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMConstructCertificateChain = msdrm.NewProc("DRMConstructCertificateChain")
)

// cCertificates (DWORD), rgwszCertificates (LPWSTR*), pcChain (DWORD* in/out), wszChain (LPWSTR optional, out)
r1, _, err := procDRMConstructCertificateChain.Call(
	uintptr(cCertificates),
	uintptr(rgwszCertificates),
	uintptr(pcChain),
	uintptr(wszChain),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DRMConstructCertificateChain(
  cCertificates: DWORD;   // DWORD
  rgwszCertificates: PPWideChar;   // LPWSTR*
  pcChain: Pointer;   // DWORD* in/out
  wszChain: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'msdrm.dll' name 'DRMConstructCertificateChain';
result := DllCall("msdrm\DRMConstructCertificateChain"
    , "UInt", cCertificates   ; DWORD
    , "Ptr", rgwszCertificates   ; LPWSTR*
    , "Ptr", pcChain   ; DWORD* in/out
    , "Ptr", wszChain   ; LPWSTR optional, out
    , "Int")   ; return: HRESULT
●DRMConstructCertificateChain(cCertificates, rgwszCertificates, pcChain, wszChain) = DLL("msdrm.dll", "int DRMConstructCertificateChain(dword, void*, void*, char*)")
# 呼び出し: DRMConstructCertificateChain(cCertificates, rgwszCertificates, pcChain, wszChain)
# cCertificates : DWORD -> "dword"
# rgwszCertificates : LPWSTR* -> "void*"
# pcChain : DWORD* in/out -> "void*"
# wszChain : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef DRMConstructCertificateChainNative = Int32 Function(Uint32, Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Utf16>);
typedef DRMConstructCertificateChainDart = int Function(int, Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Utf16>);
final DRMConstructCertificateChain = DynamicLibrary.open('msdrm.dll')
    .lookupFunction<DRMConstructCertificateChainNative, DRMConstructCertificateChainDart>('DRMConstructCertificateChain');
// cCertificates : DWORD -> Uint32
// rgwszCertificates : LPWSTR* -> Pointer<Pointer<Utf16>>
// pcChain : DWORD* in/out -> Pointer<Uint32>
// wszChain : LPWSTR optional, out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DRMConstructCertificateChain(
  cCertificates: DWORD;   // DWORD
  rgwszCertificates: PPWideChar;   // LPWSTR*
  pcChain: Pointer;   // DWORD* in/out
  wszChain: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'msdrm.dll' name 'DRMConstructCertificateChain';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DRMConstructCertificateChain"
  c_DRMConstructCertificateChain :: Word32 -> Ptr CWString -> Ptr Word32 -> CWString -> IO Int32
-- cCertificates : DWORD -> Word32
-- rgwszCertificates : LPWSTR* -> Ptr CWString
-- pcChain : DWORD* in/out -> Ptr Word32
-- wszChain : LPWSTR optional, out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let drmconstructcertificatechain =
  foreign "DRMConstructCertificateChain"
    (uint32_t @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning int32_t)
(* cCertificates : DWORD -> uint32_t *)
(* rgwszCertificates : LPWSTR* -> (ptr (ptr uint16_t)) *)
(* pcChain : DWORD* in/out -> (ptr uint32_t) *)
(* wszChain : LPWSTR optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msdrm (t "msdrm.dll"))
(cffi:use-foreign-library msdrm)

(cffi:defcfun ("DRMConstructCertificateChain" drmconstruct-certificate-chain :convention :stdcall) :int32
  (c-certificates :uint32)   ; DWORD
  (rgwsz-certificates :pointer)   ; LPWSTR*
  (pc-chain :pointer)   ; DWORD* in/out
  (wsz-chain :pointer))   ; LPWSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DRMConstructCertificateChain = Win32::API::More->new('msdrm',
    'int DRMConstructCertificateChain(DWORD cCertificates, LPVOID rgwszCertificates, LPVOID pcChain, LPWSTR wszChain)');
# my $ret = $DRMConstructCertificateChain->Call($cCertificates, $rgwszCertificates, $pcChain, $wszChain);
# cCertificates : DWORD -> DWORD
# rgwszCertificates : LPWSTR* -> LPVOID
# pcChain : DWORD* in/out -> LPVOID
# wszChain : LPWSTR optional, out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。