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

DRMVerify

関数
署名(証明)済みデータを検証する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMVerify(
    LPWSTR wszData,   // optional
    DWORD* pcAttestedData,
    LPWSTR wszAttestedData,   // optional
    DRMATTESTTYPE* peType,
    DWORD* pcPrincipal,
    LPWSTR wszPrincipal,   // optional
    DWORD* pcManifest,
    LPWSTR wszManifest   // optional
);

パラメーター

名前方向説明
wszDataLPWSTRinoptional検証対象の署名済みデータを示すUnicode文字列。
pcAttestedDataDWORD*inout入力時にバッファ長、出力時に必要長を示すポインタ。
wszAttestedDataLPWSTRoutoptional検証された証明データを受け取る出力バッファ。NULLでサイズ問い合わせ可。
peTypeDRMATTESTTYPE*inout検証された証明の種別を受け取るDRMATTESTTYPEポインタ。
pcPrincipalDWORD*inout入力時にバッファ長、出力時に必要長を示すポインタ。
wszPrincipalLPWSTRoutoptional署名者プリンシパルを受け取る出力バッファ。NULLでサイズ問い合わせ可。
pcManifestDWORD*inout入力時にバッファ長、出力時に必要長を示すポインタ。
wszManifestLPWSTRoutoptionalマニフェストを受け取る出力バッファ。NULLでサイズ問い合わせ可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DRMVerify(
    LPWSTR wszData,   // optional
    DWORD* pcAttestedData,
    LPWSTR wszAttestedData,   // optional
    DRMATTESTTYPE* peType,
    DWORD* pcPrincipal,
    LPWSTR wszPrincipal,   // optional
    DWORD* pcManifest,
    LPWSTR wszManifest   // optional
);
[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMVerify(
    [MarshalAs(UnmanagedType.LPWStr)] string wszData,   // LPWSTR optional
    ref uint pcAttestedData,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszAttestedData,   // LPWSTR optional, out
    ref int peType,   // DRMATTESTTYPE* in/out
    ref uint pcPrincipal,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszPrincipal,   // LPWSTR optional, out
    ref uint pcManifest,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszManifest   // LPWSTR optional, out
);
<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMVerify(
    <MarshalAs(UnmanagedType.LPWStr)> wszData As String,   ' LPWSTR optional
    ByRef pcAttestedData As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> wszAttestedData As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef peType As Integer,   ' DRMATTESTTYPE* in/out
    ByRef pcPrincipal As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> wszPrincipal As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef pcManifest As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> wszManifest As System.Text.StringBuilder   ' LPWSTR optional, out
) As Integer
End Function
' wszData : LPWSTR optional
' pcAttestedData : DWORD* in/out
' wszAttestedData : LPWSTR optional, out
' peType : DRMATTESTTYPE* in/out
' pcPrincipal : DWORD* in/out
' wszPrincipal : LPWSTR optional, out
' pcManifest : DWORD* in/out
' wszManifest : LPWSTR optional, out
Declare PtrSafe Function DRMVerify Lib "msdrm" ( _
    ByVal wszData As LongPtr, _
    ByRef pcAttestedData As Long, _
    ByVal wszAttestedData As LongPtr, _
    ByRef peType As Long, _
    ByRef pcPrincipal As Long, _
    ByVal wszPrincipal As LongPtr, _
    ByRef pcManifest As Long, _
    ByVal wszManifest As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DRMVerify = ctypes.windll.msdrm.DRMVerify
DRMVerify.restype = ctypes.c_int
DRMVerify.argtypes = [
    wintypes.LPCWSTR,  # wszData : LPWSTR optional
    ctypes.POINTER(wintypes.DWORD),  # pcAttestedData : DWORD* in/out
    wintypes.LPWSTR,  # wszAttestedData : LPWSTR optional, out
    ctypes.c_void_p,  # peType : DRMATTESTTYPE* in/out
    ctypes.POINTER(wintypes.DWORD),  # pcPrincipal : DWORD* in/out
    wintypes.LPWSTR,  # wszPrincipal : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcManifest : DWORD* in/out
    wintypes.LPWSTR,  # wszManifest : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMVerify = msdrm.NewProc("DRMVerify")
)

// wszData (LPWSTR optional), pcAttestedData (DWORD* in/out), wszAttestedData (LPWSTR optional, out), peType (DRMATTESTTYPE* in/out), pcPrincipal (DWORD* in/out), wszPrincipal (LPWSTR optional, out), pcManifest (DWORD* in/out), wszManifest (LPWSTR optional, out)
r1, _, err := procDRMVerify.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszData))),
	uintptr(pcAttestedData),
	uintptr(wszAttestedData),
	uintptr(peType),
	uintptr(pcPrincipal),
	uintptr(wszPrincipal),
	uintptr(pcManifest),
	uintptr(wszManifest),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DRMVerify(
  wszData: PWideChar;   // LPWSTR optional
  pcAttestedData: Pointer;   // DWORD* in/out
  wszAttestedData: PWideChar;   // LPWSTR optional, out
  peType: Pointer;   // DRMATTESTTYPE* in/out
  pcPrincipal: Pointer;   // DWORD* in/out
  wszPrincipal: PWideChar;   // LPWSTR optional, out
  pcManifest: Pointer;   // DWORD* in/out
  wszManifest: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'msdrm.dll' name 'DRMVerify';
result := DllCall("msdrm\DRMVerify"
    , "WStr", wszData   ; LPWSTR optional
    , "Ptr", pcAttestedData   ; DWORD* in/out
    , "Ptr", wszAttestedData   ; LPWSTR optional, out
    , "Ptr", peType   ; DRMATTESTTYPE* in/out
    , "Ptr", pcPrincipal   ; DWORD* in/out
    , "Ptr", wszPrincipal   ; LPWSTR optional, out
    , "Ptr", pcManifest   ; DWORD* in/out
    , "Ptr", wszManifest   ; LPWSTR optional, out
    , "Int")   ; return: HRESULT
●DRMVerify(wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest) = DLL("msdrm.dll", "int DRMVerify(char*, void*, char*, void*, void*, char*, void*, char*)")
# 呼び出し: DRMVerify(wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest)
# wszData : LPWSTR optional -> "char*"
# pcAttestedData : DWORD* in/out -> "void*"
# wszAttestedData : LPWSTR optional, out -> "char*"
# peType : DRMATTESTTYPE* in/out -> "void*"
# pcPrincipal : DWORD* in/out -> "void*"
# wszPrincipal : LPWSTR optional, out -> "char*"
# pcManifest : DWORD* in/out -> "void*"
# wszManifest : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "msdrm" fn DRMVerify(
    wszData: [*c]const u16, // LPWSTR optional
    pcAttestedData: [*c]u32, // DWORD* in/out
    wszAttestedData: [*c]u16, // LPWSTR optional, out
    peType: [*c]i32, // DRMATTESTTYPE* in/out
    pcPrincipal: [*c]u32, // DWORD* in/out
    wszPrincipal: [*c]u16, // LPWSTR optional, out
    pcManifest: [*c]u32, // DWORD* in/out
    wszManifest: [*c]u16 // LPWSTR optional, out
) callconv(std.os.windows.WINAPI) i32;
proc DRMVerify(
    wszData: WideCString,  # LPWSTR optional
    pcAttestedData: ptr uint32,  # DWORD* in/out
    wszAttestedData: ptr uint16,  # LPWSTR optional, out
    peType: ptr int32,  # DRMATTESTTYPE* in/out
    pcPrincipal: ptr uint32,  # DWORD* in/out
    wszPrincipal: ptr uint16,  # LPWSTR optional, out
    pcManifest: ptr uint32,  # DWORD* in/out
    wszManifest: ptr uint16  # LPWSTR optional, out
): int32 {.importc: "DRMVerify", stdcall, dynlib: "msdrm.dll".}
pragma(lib, "msdrm");
extern(Windows)
int DRMVerify(
    const(wchar)* wszData,   // LPWSTR optional
    uint* pcAttestedData,   // DWORD* in/out
    wchar* wszAttestedData,   // LPWSTR optional, out
    int* peType,   // DRMATTESTTYPE* in/out
    uint* pcPrincipal,   // DWORD* in/out
    wchar* wszPrincipal,   // LPWSTR optional, out
    uint* pcManifest,   // DWORD* in/out
    wchar* wszManifest   // LPWSTR optional, out
);
ccall((:DRMVerify, "msdrm.dll"), stdcall, Int32,
      (Cwstring, Ptr{UInt32}, Ptr{UInt16}, Ptr{Int32}, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt32}, Ptr{UInt16}),
      wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest)
# wszData : LPWSTR optional -> Cwstring
# pcAttestedData : DWORD* in/out -> Ptr{UInt32}
# wszAttestedData : LPWSTR optional, out -> Ptr{UInt16}
# peType : DRMATTESTTYPE* in/out -> Ptr{Int32}
# pcPrincipal : DWORD* in/out -> Ptr{UInt32}
# wszPrincipal : LPWSTR optional, out -> Ptr{UInt16}
# pcManifest : DWORD* in/out -> Ptr{UInt32}
# wszManifest : LPWSTR optional, out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t DRMVerify(
    const uint16_t* wszData,
    uint32_t* pcAttestedData,
    uint16_t* wszAttestedData,
    int32_t* peType,
    uint32_t* pcPrincipal,
    uint16_t* wszPrincipal,
    uint32_t* pcManifest,
    uint16_t* wszManifest);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMVerify(wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest)
-- wszData : LPWSTR optional
-- pcAttestedData : DWORD* in/out
-- wszAttestedData : LPWSTR optional, out
-- peType : DRMATTESTTYPE* in/out
-- pcPrincipal : DWORD* in/out
-- wszPrincipal : LPWSTR optional, out
-- pcManifest : DWORD* in/out
-- wszManifest : LPWSTR optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMVerify = lib.func('__stdcall', 'DRMVerify', 'int32_t', ['str16', 'uint32_t *', 'uint16_t *', 'int32_t *', 'uint32_t *', 'uint16_t *', 'uint32_t *', 'uint16_t *']);
// DRMVerify(wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest)
// wszData : LPWSTR optional -> 'str16'
// pcAttestedData : DWORD* in/out -> 'uint32_t *'
// wszAttestedData : LPWSTR optional, out -> 'uint16_t *'
// peType : DRMATTESTTYPE* in/out -> 'int32_t *'
// pcPrincipal : DWORD* in/out -> 'uint32_t *'
// wszPrincipal : LPWSTR optional, out -> 'uint16_t *'
// pcManifest : DWORD* in/out -> 'uint32_t *'
// wszManifest : LPWSTR optional, out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msdrm.dll", {
  DRMVerify: { parameters: ["buffer", "pointer", "buffer", "pointer", "pointer", "buffer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.DRMVerify(wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest)
// wszData : LPWSTR optional -> "buffer"
// pcAttestedData : DWORD* in/out -> "pointer"
// wszAttestedData : LPWSTR optional, out -> "buffer"
// peType : DRMATTESTTYPE* in/out -> "pointer"
// pcPrincipal : DWORD* in/out -> "pointer"
// wszPrincipal : LPWSTR optional, out -> "buffer"
// pcManifest : DWORD* in/out -> "pointer"
// wszManifest : LPWSTR optional, out -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t DRMVerify(
    const uint16_t* wszData,
    uint32_t* pcAttestedData,
    uint16_t* wszAttestedData,
    int32_t* peType,
    uint32_t* pcPrincipal,
    uint16_t* wszPrincipal,
    uint32_t* pcManifest,
    uint16_t* wszManifest);
C, "msdrm.dll");
// $ffi->DRMVerify(wszData, pcAttestedData, wszAttestedData, peType, pcPrincipal, wszPrincipal, pcManifest, wszManifest);
// wszData : LPWSTR optional
// pcAttestedData : DWORD* in/out
// wszAttestedData : LPWSTR optional, out
// peType : DRMATTESTTYPE* in/out
// pcPrincipal : DWORD* in/out
// wszPrincipal : LPWSTR optional, out
// pcManifest : DWORD* in/out
// wszManifest : 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 DRMVerify(
        WString wszData,   // LPWSTR optional
        IntByReference pcAttestedData,   // DWORD* in/out
        char[] wszAttestedData,   // LPWSTR optional, out
        IntByReference peType,   // DRMATTESTTYPE* in/out
        IntByReference pcPrincipal,   // DWORD* in/out
        char[] wszPrincipal,   // LPWSTR optional, out
        IntByReference pcManifest,   // DWORD* in/out
        char[] wszManifest   // LPWSTR optional, out
    );
}
@[Link("msdrm")]
lib Libmsdrm
  fun DRMVerify = DRMVerify(
    wszData : UInt16*,   # LPWSTR optional
    pcAttestedData : UInt32*,   # DWORD* in/out
    wszAttestedData : UInt16*,   # LPWSTR optional, out
    peType : Int32*,   # DRMATTESTTYPE* in/out
    pcPrincipal : UInt32*,   # DWORD* in/out
    wszPrincipal : UInt16*,   # LPWSTR optional, out
    pcManifest : UInt32*,   # DWORD* in/out
    wszManifest : 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 DRMVerifyNative = Int32 Function(Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Int32>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>);
typedef DRMVerifyDart = int Function(Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Int32>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>);
final DRMVerify = DynamicLibrary.open('msdrm.dll')
    .lookupFunction<DRMVerifyNative, DRMVerifyDart>('DRMVerify');
// wszData : LPWSTR optional -> Pointer<Utf16>
// pcAttestedData : DWORD* in/out -> Pointer<Uint32>
// wszAttestedData : LPWSTR optional, out -> Pointer<Utf16>
// peType : DRMATTESTTYPE* in/out -> Pointer<Int32>
// pcPrincipal : DWORD* in/out -> Pointer<Uint32>
// wszPrincipal : LPWSTR optional, out -> Pointer<Utf16>
// pcManifest : DWORD* in/out -> Pointer<Uint32>
// wszManifest : LPWSTR optional, out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DRMVerify(
  wszData: PWideChar;   // LPWSTR optional
  pcAttestedData: Pointer;   // DWORD* in/out
  wszAttestedData: PWideChar;   // LPWSTR optional, out
  peType: Pointer;   // DRMATTESTTYPE* in/out
  pcPrincipal: Pointer;   // DWORD* in/out
  wszPrincipal: PWideChar;   // LPWSTR optional, out
  pcManifest: Pointer;   // DWORD* in/out
  wszManifest: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'msdrm.dll' name 'DRMVerify';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DRMVerify"
  c_DRMVerify :: CWString -> Ptr Word32 -> CWString -> Ptr Int32 -> Ptr Word32 -> CWString -> Ptr Word32 -> CWString -> IO Int32
-- wszData : LPWSTR optional -> CWString
-- pcAttestedData : DWORD* in/out -> Ptr Word32
-- wszAttestedData : LPWSTR optional, out -> CWString
-- peType : DRMATTESTTYPE* in/out -> Ptr Int32
-- pcPrincipal : DWORD* in/out -> Ptr Word32
-- wszPrincipal : LPWSTR optional, out -> CWString
-- pcManifest : DWORD* in/out -> Ptr Word32
-- wszManifest : LPWSTR optional, out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let drmverify =
  foreign "DRMVerify"
    ((ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr int32_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning int32_t)
(* wszData : LPWSTR optional -> (ptr uint16_t) *)
(* pcAttestedData : DWORD* in/out -> (ptr uint32_t) *)
(* wszAttestedData : LPWSTR optional, out -> (ptr uint16_t) *)
(* peType : DRMATTESTTYPE* in/out -> (ptr int32_t) *)
(* pcPrincipal : DWORD* in/out -> (ptr uint32_t) *)
(* wszPrincipal : LPWSTR optional, out -> (ptr uint16_t) *)
(* pcManifest : DWORD* in/out -> (ptr uint32_t) *)
(* wszManifest : 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 ("DRMVerify" drmverify :convention :stdcall) :int32
  (wsz-data (:string :encoding :utf-16le))   ; LPWSTR optional
  (pc-attested-data :pointer)   ; DWORD* in/out
  (wsz-attested-data :pointer)   ; LPWSTR optional, out
  (pe-type :pointer)   ; DRMATTESTTYPE* in/out
  (pc-principal :pointer)   ; DWORD* in/out
  (wsz-principal :pointer)   ; LPWSTR optional, out
  (pc-manifest :pointer)   ; DWORD* in/out
  (wsz-manifest :pointer))   ; LPWSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DRMVerify = Win32::API::More->new('msdrm',
    'int DRMVerify(LPCWSTR wszData, LPVOID pcAttestedData, LPWSTR wszAttestedData, LPVOID peType, LPVOID pcPrincipal, LPWSTR wszPrincipal, LPVOID pcManifest, LPWSTR wszManifest)');
# my $ret = $DRMVerify->Call($wszData, $pcAttestedData, $wszAttestedData, $peType, $pcPrincipal, $wszPrincipal, $pcManifest, $wszManifest);
# wszData : LPWSTR optional -> LPCWSTR
# pcAttestedData : DWORD* in/out -> LPVOID
# wszAttestedData : LPWSTR optional, out -> LPWSTR
# peType : DRMATTESTTYPE* in/out -> LPVOID
# pcPrincipal : DWORD* in/out -> LPVOID
# wszPrincipal : LPWSTR optional, out -> LPWSTR
# pcManifest : DWORD* in/out -> LPVOID
# wszManifest : LPWSTR optional, out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型