ホーム › Data.RightsManagement › DRMCreateEnablingBitsEncryptor
DRMCreateEnablingBitsEncryptor
関数バインドライセンスから暗号化用のビット処理器を作成する。
シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMCreateEnablingBitsEncryptor(
DWORD hBoundLicense,
LPWSTR wszRight, // optional
DWORD hAuxLib,
LPWSTR wszAuxPlug, // optional
DWORD* phEncryptor
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hBoundLicense | DWORD | in | 対象のバインドライセンスハンドル。 |
| wszRight | LPWSTR | inoptional | 暗号化に対応する権利名を示すUnicode文字列。 |
| hAuxLib | DWORD | in | 補助ライブラリのハンドル。不要ならNULL相当の0可。 |
| wszAuxPlug | LPWSTR | inoptional | 補助プラグインを示すUnicode文字列。NULL可。 |
| phEncryptor | DWORD* | inout | 生成された暗号化器のハンドルを受け取る出力先。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// msdrm.dll
#include <windows.h>
HRESULT DRMCreateEnablingBitsEncryptor(
DWORD hBoundLicense,
LPWSTR wszRight, // optional
DWORD hAuxLib,
LPWSTR wszAuxPlug, // optional
DWORD* phEncryptor
);[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMCreateEnablingBitsEncryptor(
uint hBoundLicense, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string wszRight, // LPWSTR optional
uint hAuxLib, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string wszAuxPlug, // LPWSTR optional
ref uint phEncryptor // DWORD* in/out
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMCreateEnablingBitsEncryptor(
hBoundLicense As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> wszRight As String, ' LPWSTR optional
hAuxLib As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> wszAuxPlug As String, ' LPWSTR optional
ByRef phEncryptor As UInteger ' DWORD* in/out
) As Integer
End Function' hBoundLicense : DWORD
' wszRight : LPWSTR optional
' hAuxLib : DWORD
' wszAuxPlug : LPWSTR optional
' phEncryptor : DWORD* in/out
Declare PtrSafe Function DRMCreateEnablingBitsEncryptor Lib "msdrm" ( _
ByVal hBoundLicense As Long, _
ByVal wszRight As LongPtr, _
ByVal hAuxLib As Long, _
ByVal wszAuxPlug As LongPtr, _
ByRef phEncryptor As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DRMCreateEnablingBitsEncryptor = ctypes.windll.msdrm.DRMCreateEnablingBitsEncryptor
DRMCreateEnablingBitsEncryptor.restype = ctypes.c_int
DRMCreateEnablingBitsEncryptor.argtypes = [
wintypes.DWORD, # hBoundLicense : DWORD
wintypes.LPCWSTR, # wszRight : LPWSTR optional
wintypes.DWORD, # hAuxLib : DWORD
wintypes.LPCWSTR, # wszAuxPlug : LPWSTR optional
ctypes.POINTER(wintypes.DWORD), # phEncryptor : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdrm.dll')
DRMCreateEnablingBitsEncryptor = Fiddle::Function.new(
lib['DRMCreateEnablingBitsEncryptor'],
[
-Fiddle::TYPE_INT, # hBoundLicense : DWORD
Fiddle::TYPE_VOIDP, # wszRight : LPWSTR optional
-Fiddle::TYPE_INT, # hAuxLib : DWORD
Fiddle::TYPE_VOIDP, # wszAuxPlug : LPWSTR optional
Fiddle::TYPE_VOIDP, # phEncryptor : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "msdrm")]
extern "system" {
fn DRMCreateEnablingBitsEncryptor(
hBoundLicense: u32, // DWORD
wszRight: *mut u16, // LPWSTR optional
hAuxLib: u32, // DWORD
wszAuxPlug: *mut u16, // LPWSTR optional
phEncryptor: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMCreateEnablingBitsEncryptor(uint hBoundLicense, [MarshalAs(UnmanagedType.LPWStr)] string wszRight, uint hAuxLib, [MarshalAs(UnmanagedType.LPWStr)] string wszAuxPlug, ref uint phEncryptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMCreateEnablingBitsEncryptor' -Namespace Win32 -PassThru
# $api::DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor)#uselib "msdrm.dll"
#func global DRMCreateEnablingBitsEncryptor "DRMCreateEnablingBitsEncryptor" sptr, sptr, sptr, sptr, sptr
; DRMCreateEnablingBitsEncryptor hBoundLicense, wszRight, hAuxLib, wszAuxPlug, varptr(phEncryptor) ; 戻り値は stat
; hBoundLicense : DWORD -> "sptr"
; wszRight : LPWSTR optional -> "sptr"
; hAuxLib : DWORD -> "sptr"
; wszAuxPlug : LPWSTR optional -> "sptr"
; phEncryptor : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msdrm.dll" #cfunc global DRMCreateEnablingBitsEncryptor "DRMCreateEnablingBitsEncryptor" int, wstr, int, wstr, var ; res = DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor) ; hBoundLicense : DWORD -> "int" ; wszRight : LPWSTR optional -> "wstr" ; hAuxLib : DWORD -> "int" ; wszAuxPlug : LPWSTR optional -> "wstr" ; phEncryptor : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msdrm.dll" #cfunc global DRMCreateEnablingBitsEncryptor "DRMCreateEnablingBitsEncryptor" int, wstr, int, wstr, sptr ; res = DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, varptr(phEncryptor)) ; hBoundLicense : DWORD -> "int" ; wszRight : LPWSTR optional -> "wstr" ; hAuxLib : DWORD -> "int" ; wszAuxPlug : LPWSTR optional -> "wstr" ; phEncryptor : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DRMCreateEnablingBitsEncryptor(DWORD hBoundLicense, LPWSTR wszRight, DWORD hAuxLib, LPWSTR wszAuxPlug, DWORD* phEncryptor) #uselib "msdrm.dll" #cfunc global DRMCreateEnablingBitsEncryptor "DRMCreateEnablingBitsEncryptor" int, wstr, int, wstr, var ; res = DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor) ; hBoundLicense : DWORD -> "int" ; wszRight : LPWSTR optional -> "wstr" ; hAuxLib : DWORD -> "int" ; wszAuxPlug : LPWSTR optional -> "wstr" ; phEncryptor : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DRMCreateEnablingBitsEncryptor(DWORD hBoundLicense, LPWSTR wszRight, DWORD hAuxLib, LPWSTR wszAuxPlug, DWORD* phEncryptor) #uselib "msdrm.dll" #cfunc global DRMCreateEnablingBitsEncryptor "DRMCreateEnablingBitsEncryptor" int, wstr, int, wstr, intptr ; res = DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, varptr(phEncryptor)) ; hBoundLicense : DWORD -> "int" ; wszRight : LPWSTR optional -> "wstr" ; hAuxLib : DWORD -> "int" ; wszAuxPlug : LPWSTR optional -> "wstr" ; phEncryptor : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdrm = windows.NewLazySystemDLL("msdrm.dll")
procDRMCreateEnablingBitsEncryptor = msdrm.NewProc("DRMCreateEnablingBitsEncryptor")
)
// hBoundLicense (DWORD), wszRight (LPWSTR optional), hAuxLib (DWORD), wszAuxPlug (LPWSTR optional), phEncryptor (DWORD* in/out)
r1, _, err := procDRMCreateEnablingBitsEncryptor.Call(
uintptr(hBoundLicense),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszRight))),
uintptr(hAuxLib),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszAuxPlug))),
uintptr(phEncryptor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DRMCreateEnablingBitsEncryptor(
hBoundLicense: DWORD; // DWORD
wszRight: PWideChar; // LPWSTR optional
hAuxLib: DWORD; // DWORD
wszAuxPlug: PWideChar; // LPWSTR optional
phEncryptor: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMCreateEnablingBitsEncryptor';result := DllCall("msdrm\DRMCreateEnablingBitsEncryptor"
, "UInt", hBoundLicense ; DWORD
, "WStr", wszRight ; LPWSTR optional
, "UInt", hAuxLib ; DWORD
, "WStr", wszAuxPlug ; LPWSTR optional
, "Ptr", phEncryptor ; DWORD* in/out
, "Int") ; return: HRESULT●DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor) = DLL("msdrm.dll", "int DRMCreateEnablingBitsEncryptor(dword, char*, dword, char*, void*)")
# 呼び出し: DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor)
# hBoundLicense : DWORD -> "dword"
# wszRight : LPWSTR optional -> "char*"
# hAuxLib : DWORD -> "dword"
# wszAuxPlug : LPWSTR optional -> "char*"
# phEncryptor : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msdrm" fn DRMCreateEnablingBitsEncryptor(
hBoundLicense: u32, // DWORD
wszRight: [*c]const u16, // LPWSTR optional
hAuxLib: u32, // DWORD
wszAuxPlug: [*c]const u16, // LPWSTR optional
phEncryptor: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc DRMCreateEnablingBitsEncryptor(
hBoundLicense: uint32, # DWORD
wszRight: WideCString, # LPWSTR optional
hAuxLib: uint32, # DWORD
wszAuxPlug: WideCString, # LPWSTR optional
phEncryptor: ptr uint32 # DWORD* in/out
): int32 {.importc: "DRMCreateEnablingBitsEncryptor", stdcall, dynlib: "msdrm.dll".}pragma(lib, "msdrm");
extern(Windows)
int DRMCreateEnablingBitsEncryptor(
uint hBoundLicense, // DWORD
const(wchar)* wszRight, // LPWSTR optional
uint hAuxLib, // DWORD
const(wchar)* wszAuxPlug, // LPWSTR optional
uint* phEncryptor // DWORD* in/out
);ccall((:DRMCreateEnablingBitsEncryptor, "msdrm.dll"), stdcall, Int32,
(UInt32, Cwstring, UInt32, Cwstring, Ptr{UInt32}),
hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor)
# hBoundLicense : DWORD -> UInt32
# wszRight : LPWSTR optional -> Cwstring
# hAuxLib : DWORD -> UInt32
# wszAuxPlug : LPWSTR optional -> Cwstring
# phEncryptor : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DRMCreateEnablingBitsEncryptor(
uint32_t hBoundLicense,
const uint16_t* wszRight,
uint32_t hAuxLib,
const uint16_t* wszAuxPlug,
uint32_t* phEncryptor);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor)
-- hBoundLicense : DWORD
-- wszRight : LPWSTR optional
-- hAuxLib : DWORD
-- wszAuxPlug : LPWSTR optional
-- phEncryptor : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMCreateEnablingBitsEncryptor = lib.func('__stdcall', 'DRMCreateEnablingBitsEncryptor', 'int32_t', ['uint32_t', 'str16', 'uint32_t', 'str16', 'uint32_t *']);
// DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor)
// hBoundLicense : DWORD -> 'uint32_t'
// wszRight : LPWSTR optional -> 'str16'
// hAuxLib : DWORD -> 'uint32_t'
// wszAuxPlug : LPWSTR optional -> 'str16'
// phEncryptor : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdrm.dll", {
DRMCreateEnablingBitsEncryptor: { parameters: ["u32", "buffer", "u32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor)
// hBoundLicense : DWORD -> "u32"
// wszRight : LPWSTR optional -> "buffer"
// hAuxLib : DWORD -> "u32"
// wszAuxPlug : LPWSTR optional -> "buffer"
// phEncryptor : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DRMCreateEnablingBitsEncryptor(
uint32_t hBoundLicense,
const uint16_t* wszRight,
uint32_t hAuxLib,
const uint16_t* wszAuxPlug,
uint32_t* phEncryptor);
C, "msdrm.dll");
// $ffi->DRMCreateEnablingBitsEncryptor(hBoundLicense, wszRight, hAuxLib, wszAuxPlug, phEncryptor);
// hBoundLicense : DWORD
// wszRight : LPWSTR optional
// hAuxLib : DWORD
// wszAuxPlug : LPWSTR optional
// phEncryptor : DWORD* in/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 DRMCreateEnablingBitsEncryptor(
int hBoundLicense, // DWORD
WString wszRight, // LPWSTR optional
int hAuxLib, // DWORD
WString wszAuxPlug, // LPWSTR optional
IntByReference phEncryptor // DWORD* in/out
);
}@[Link("msdrm")]
lib Libmsdrm
fun DRMCreateEnablingBitsEncryptor = DRMCreateEnablingBitsEncryptor(
hBoundLicense : UInt32, # DWORD
wszRight : UInt16*, # LPWSTR optional
hAuxLib : UInt32, # DWORD
wszAuxPlug : UInt16*, # LPWSTR optional
phEncryptor : UInt32* # DWORD* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DRMCreateEnablingBitsEncryptorNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Uint32>);
typedef DRMCreateEnablingBitsEncryptorDart = int Function(int, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Uint32>);
final DRMCreateEnablingBitsEncryptor = DynamicLibrary.open('msdrm.dll')
.lookupFunction<DRMCreateEnablingBitsEncryptorNative, DRMCreateEnablingBitsEncryptorDart>('DRMCreateEnablingBitsEncryptor');
// hBoundLicense : DWORD -> Uint32
// wszRight : LPWSTR optional -> Pointer<Utf16>
// hAuxLib : DWORD -> Uint32
// wszAuxPlug : LPWSTR optional -> Pointer<Utf16>
// phEncryptor : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DRMCreateEnablingBitsEncryptor(
hBoundLicense: DWORD; // DWORD
wszRight: PWideChar; // LPWSTR optional
hAuxLib: DWORD; // DWORD
wszAuxPlug: PWideChar; // LPWSTR optional
phEncryptor: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMCreateEnablingBitsEncryptor';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DRMCreateEnablingBitsEncryptor"
c_DRMCreateEnablingBitsEncryptor :: Word32 -> CWString -> Word32 -> CWString -> Ptr Word32 -> IO Int32
-- hBoundLicense : DWORD -> Word32
-- wszRight : LPWSTR optional -> CWString
-- hAuxLib : DWORD -> Word32
-- wszAuxPlug : LPWSTR optional -> CWString
-- phEncryptor : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drmcreateenablingbitsencryptor =
foreign "DRMCreateEnablingBitsEncryptor"
(uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hBoundLicense : DWORD -> uint32_t *)
(* wszRight : LPWSTR optional -> (ptr uint16_t) *)
(* hAuxLib : DWORD -> uint32_t *)
(* wszAuxPlug : LPWSTR optional -> (ptr uint16_t) *)
(* phEncryptor : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msdrm (t "msdrm.dll"))
(cffi:use-foreign-library msdrm)
(cffi:defcfun ("DRMCreateEnablingBitsEncryptor" drmcreate-enabling-bits-encryptor :convention :stdcall) :int32
(h-bound-license :uint32) ; DWORD
(wsz-right (:string :encoding :utf-16le)) ; LPWSTR optional
(h-aux-lib :uint32) ; DWORD
(wsz-aux-plug (:string :encoding :utf-16le)) ; LPWSTR optional
(ph-encryptor :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DRMCreateEnablingBitsEncryptor = Win32::API::More->new('msdrm',
'int DRMCreateEnablingBitsEncryptor(DWORD hBoundLicense, LPCWSTR wszRight, DWORD hAuxLib, LPCWSTR wszAuxPlug, LPVOID phEncryptor)');
# my $ret = $DRMCreateEnablingBitsEncryptor->Call($hBoundLicense, $wszRight, $hAuxLib, $wszAuxPlug, $phEncryptor);
# hBoundLicense : DWORD -> DWORD
# wszRight : LPWSTR optional -> LPCWSTR
# hAuxLib : DWORD -> DWORD
# wszAuxPlug : LPWSTR optional -> LPCWSTR
# phEncryptor : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。