ホーム › Security.Cryptography › CryptInstallOIDFunctionAddress
CryptInstallOIDFunctionAddress
関数OID関数のアドレスを登録テーブルにインストールする。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptInstallOIDFunctionAddress(
HMODULE hModule, // optional
DWORD dwEncodingType,
LPCSTR pszFuncName,
DWORD cFuncEntry,
const CRYPT_OID_FUNC_ENTRY* rgFuncEntry,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hModule | HMODULE | inoptional | このパラメーターは、DllMain に渡された hModule パラメーターで更新されます。これにより、関数アドレスを含む DLL が CryptGetOIDFunctionAddress または CryptFreeOIDFunctionAddress によってアンロードされるのを防ぎます。これは、その DLL が CryptRegisterOIDFunction を通じて OID 関数も登録している場合に該当します。 |
| dwEncodingType | DWORD | in | 一致させるエンコーディングの種類を指定します。現在は X509_ASN_ENCODING と PKCS_7_ASN_ENCODING のみが使用されていますが、将来的に追加のエンコーディングの種類が加わる可能性があります。現在の両方のエンコーディングの種類に一致させるには、次のように指定します。 |
| pszFuncName | LPCSTR | in | インストールする関数セットの名前。 |
| cFuncEntry | DWORD | in | rgFuncEntry[] 内の配列要素の数。 |
| rgFuncEntry | CRYPT_OID_FUNC_ENTRY* | in | CRYPT_OID_FUNC_ENTRY 構造体の配列で、各要素には OID と、それに対応するルーチンの開始アドレスが含まれます。 既定の関数をインストールするには、その配列要素の CRYPT_OID_FUNC_ENTRY 構造体の pszOID メンバーに CRYPT_DEFAULT_OID を設定します。 |
| dwFlags | DWORD | in | 既定では、新しい関数セットは関数セットの一覧の末尾にインストールされます。CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG フラグを設定すると、関数セットは一覧の先頭にインストールされます。 |
戻り値の型: BOOL
公式ドキュメント
CryptInstallOIDFunctionAddress 関数は、呼び出し可能なオブジェクト識別子 (OID) 関数アドレスのセットをインストールします。
戻り値
関数が成功した場合は、0 以外の値 (TRUE) を返します。
関数が失敗した場合は、0 (FALSE) を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptInstallOIDFunctionAddress(
HMODULE hModule, // optional
DWORD dwEncodingType,
LPCSTR pszFuncName,
DWORD cFuncEntry,
const CRYPT_OID_FUNC_ENTRY* rgFuncEntry,
DWORD dwFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern bool CryptInstallOIDFunctionAddress(
IntPtr hModule, // HMODULE optional
uint dwEncodingType, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string pszFuncName, // LPCSTR
uint cFuncEntry, // DWORD
IntPtr rgFuncEntry, // CRYPT_OID_FUNC_ENTRY*
uint dwFlags // DWORD
);<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CryptInstallOIDFunctionAddress(
hModule As IntPtr, ' HMODULE optional
dwEncodingType As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszFuncName As String, ' LPCSTR
cFuncEntry As UInteger, ' DWORD
rgFuncEntry As IntPtr, ' CRYPT_OID_FUNC_ENTRY*
dwFlags As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hModule : HMODULE optional
' dwEncodingType : DWORD
' pszFuncName : LPCSTR
' cFuncEntry : DWORD
' rgFuncEntry : CRYPT_OID_FUNC_ENTRY*
' dwFlags : DWORD
Declare PtrSafe Function CryptInstallOIDFunctionAddress Lib "crypt32" ( _
ByVal hModule As LongPtr, _
ByVal dwEncodingType As Long, _
ByVal pszFuncName As String, _
ByVal cFuncEntry As Long, _
ByVal rgFuncEntry As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptInstallOIDFunctionAddress = ctypes.windll.crypt32.CryptInstallOIDFunctionAddress
CryptInstallOIDFunctionAddress.restype = wintypes.BOOL
CryptInstallOIDFunctionAddress.argtypes = [
wintypes.HANDLE, # hModule : HMODULE optional
wintypes.DWORD, # dwEncodingType : DWORD
wintypes.LPCSTR, # pszFuncName : LPCSTR
wintypes.DWORD, # cFuncEntry : DWORD
ctypes.c_void_p, # rgFuncEntry : CRYPT_OID_FUNC_ENTRY*
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptInstallOIDFunctionAddress = Fiddle::Function.new(
lib['CryptInstallOIDFunctionAddress'],
[
Fiddle::TYPE_VOIDP, # hModule : HMODULE optional
-Fiddle::TYPE_INT, # dwEncodingType : DWORD
Fiddle::TYPE_VOIDP, # pszFuncName : LPCSTR
-Fiddle::TYPE_INT, # cFuncEntry : DWORD
Fiddle::TYPE_VOIDP, # rgFuncEntry : CRYPT_OID_FUNC_ENTRY*
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptInstallOIDFunctionAddress(
hModule: *mut core::ffi::c_void, // HMODULE optional
dwEncodingType: u32, // DWORD
pszFuncName: *const u8, // LPCSTR
cFuncEntry: u32, // DWORD
rgFuncEntry: *const CRYPT_OID_FUNC_ENTRY, // CRYPT_OID_FUNC_ENTRY*
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll")]
public static extern bool CryptInstallOIDFunctionAddress(IntPtr hModule, uint dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName, uint cFuncEntry, IntPtr rgFuncEntry, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptInstallOIDFunctionAddress' -Namespace Win32 -PassThru
# $api::CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags)#uselib "CRYPT32.dll"
#func global CryptInstallOIDFunctionAddress "CryptInstallOIDFunctionAddress" sptr, sptr, sptr, sptr, sptr, sptr
; CryptInstallOIDFunctionAddress hModule, dwEncodingType, pszFuncName, cFuncEntry, varptr(rgFuncEntry), dwFlags ; 戻り値は stat
; hModule : HMODULE optional -> "sptr"
; dwEncodingType : DWORD -> "sptr"
; pszFuncName : LPCSTR -> "sptr"
; cFuncEntry : DWORD -> "sptr"
; rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CRYPT32.dll" #cfunc global CryptInstallOIDFunctionAddress "CryptInstallOIDFunctionAddress" sptr, int, str, int, var, int ; res = CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags) ; hModule : HMODULE optional -> "sptr" ; dwEncodingType : DWORD -> "int" ; pszFuncName : LPCSTR -> "str" ; cFuncEntry : DWORD -> "int" ; rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CRYPT32.dll" #cfunc global CryptInstallOIDFunctionAddress "CryptInstallOIDFunctionAddress" sptr, int, str, int, sptr, int ; res = CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, varptr(rgFuncEntry), dwFlags) ; hModule : HMODULE optional -> "sptr" ; dwEncodingType : DWORD -> "int" ; pszFuncName : LPCSTR -> "str" ; cFuncEntry : DWORD -> "int" ; rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CryptInstallOIDFunctionAddress(HMODULE hModule, DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry, CRYPT_OID_FUNC_ENTRY* rgFuncEntry, DWORD dwFlags) #uselib "CRYPT32.dll" #cfunc global CryptInstallOIDFunctionAddress "CryptInstallOIDFunctionAddress" intptr, int, str, int, var, int ; res = CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags) ; hModule : HMODULE optional -> "intptr" ; dwEncodingType : DWORD -> "int" ; pszFuncName : LPCSTR -> "str" ; cFuncEntry : DWORD -> "int" ; rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CryptInstallOIDFunctionAddress(HMODULE hModule, DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry, CRYPT_OID_FUNC_ENTRY* rgFuncEntry, DWORD dwFlags) #uselib "CRYPT32.dll" #cfunc global CryptInstallOIDFunctionAddress "CryptInstallOIDFunctionAddress" intptr, int, str, int, intptr, int ; res = CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, varptr(rgFuncEntry), dwFlags) ; hModule : HMODULE optional -> "intptr" ; dwEncodingType : DWORD -> "int" ; pszFuncName : LPCSTR -> "str" ; cFuncEntry : DWORD -> "int" ; rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptInstallOIDFunctionAddress = crypt32.NewProc("CryptInstallOIDFunctionAddress")
)
// hModule (HMODULE optional), dwEncodingType (DWORD), pszFuncName (LPCSTR), cFuncEntry (DWORD), rgFuncEntry (CRYPT_OID_FUNC_ENTRY*), dwFlags (DWORD)
r1, _, err := procCryptInstallOIDFunctionAddress.Call(
uintptr(hModule),
uintptr(dwEncodingType),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszFuncName))),
uintptr(cFuncEntry),
uintptr(rgFuncEntry),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptInstallOIDFunctionAddress(
hModule: THandle; // HMODULE optional
dwEncodingType: DWORD; // DWORD
pszFuncName: PAnsiChar; // LPCSTR
cFuncEntry: DWORD; // DWORD
rgFuncEntry: Pointer; // CRYPT_OID_FUNC_ENTRY*
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptInstallOIDFunctionAddress';result := DllCall("CRYPT32\CryptInstallOIDFunctionAddress"
, "Ptr", hModule ; HMODULE optional
, "UInt", dwEncodingType ; DWORD
, "AStr", pszFuncName ; LPCSTR
, "UInt", cFuncEntry ; DWORD
, "Ptr", rgFuncEntry ; CRYPT_OID_FUNC_ENTRY*
, "UInt", dwFlags ; DWORD
, "Int") ; return: BOOL●CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags) = DLL("CRYPT32.dll", "bool CryptInstallOIDFunctionAddress(void*, dword, char*, dword, void*, dword)")
# 呼び出し: CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags)
# hModule : HMODULE optional -> "void*"
# dwEncodingType : DWORD -> "dword"
# pszFuncName : LPCSTR -> "char*"
# cFuncEntry : DWORD -> "dword"
# rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "crypt32" fn CryptInstallOIDFunctionAddress(
hModule: ?*anyopaque, // HMODULE optional
dwEncodingType: u32, // DWORD
pszFuncName: [*c]const u8, // LPCSTR
cFuncEntry: u32, // DWORD
rgFuncEntry: [*c]CRYPT_OID_FUNC_ENTRY, // CRYPT_OID_FUNC_ENTRY*
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc CryptInstallOIDFunctionAddress(
hModule: pointer, # HMODULE optional
dwEncodingType: uint32, # DWORD
pszFuncName: cstring, # LPCSTR
cFuncEntry: uint32, # DWORD
rgFuncEntry: ptr CRYPT_OID_FUNC_ENTRY, # CRYPT_OID_FUNC_ENTRY*
dwFlags: uint32 # DWORD
): int32 {.importc: "CryptInstallOIDFunctionAddress", stdcall, dynlib: "CRYPT32.dll".}pragma(lib, "crypt32");
extern(Windows)
int CryptInstallOIDFunctionAddress(
void* hModule, // HMODULE optional
uint dwEncodingType, // DWORD
const(char)* pszFuncName, // LPCSTR
uint cFuncEntry, // DWORD
CRYPT_OID_FUNC_ENTRY* rgFuncEntry, // CRYPT_OID_FUNC_ENTRY*
uint dwFlags // DWORD
);ccall((:CryptInstallOIDFunctionAddress, "CRYPT32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Cstring, UInt32, Ptr{CRYPT_OID_FUNC_ENTRY}, UInt32),
hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags)
# hModule : HMODULE optional -> Ptr{Cvoid}
# dwEncodingType : DWORD -> UInt32
# pszFuncName : LPCSTR -> Cstring
# cFuncEntry : DWORD -> UInt32
# rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> Ptr{CRYPT_OID_FUNC_ENTRY}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CryptInstallOIDFunctionAddress(
void* hModule,
uint32_t dwEncodingType,
const char* pszFuncName,
uint32_t cFuncEntry,
void* rgFuncEntry,
uint32_t dwFlags);
]]
local crypt32 = ffi.load("crypt32")
-- crypt32.CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags)
-- hModule : HMODULE optional
-- dwEncodingType : DWORD
-- pszFuncName : LPCSTR
-- cFuncEntry : DWORD
-- rgFuncEntry : CRYPT_OID_FUNC_ENTRY*
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CRYPT32.dll');
const CryptInstallOIDFunctionAddress = lib.func('__stdcall', 'CryptInstallOIDFunctionAddress', 'int32_t', ['void *', 'uint32_t', 'str', 'uint32_t', 'void *', 'uint32_t']);
// CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags)
// hModule : HMODULE optional -> 'void *'
// dwEncodingType : DWORD -> 'uint32_t'
// pszFuncName : LPCSTR -> 'str'
// cFuncEntry : DWORD -> 'uint32_t'
// rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> 'void *'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CRYPT32.dll", {
CryptInstallOIDFunctionAddress: { parameters: ["pointer", "u32", "buffer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags)
// hModule : HMODULE optional -> "pointer"
// dwEncodingType : DWORD -> "u32"
// pszFuncName : LPCSTR -> "buffer"
// cFuncEntry : DWORD -> "u32"
// rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> "pointer"
// dwFlags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CryptInstallOIDFunctionAddress(
void* hModule,
uint32_t dwEncodingType,
const char* pszFuncName,
uint32_t cFuncEntry,
void* rgFuncEntry,
uint32_t dwFlags);
C, "CRYPT32.dll");
// $ffi->CryptInstallOIDFunctionAddress(hModule, dwEncodingType, pszFuncName, cFuncEntry, rgFuncEntry, dwFlags);
// hModule : HMODULE optional
// dwEncodingType : DWORD
// pszFuncName : LPCSTR
// cFuncEntry : DWORD
// rgFuncEntry : CRYPT_OID_FUNC_ENTRY*
// dwFlags : DWORD
// 構造体/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 Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = Native.load("crypt32", Crypt32.class);
boolean CryptInstallOIDFunctionAddress(
Pointer hModule, // HMODULE optional
int dwEncodingType, // DWORD
String pszFuncName, // LPCSTR
int cFuncEntry, // DWORD
Pointer rgFuncEntry, // CRYPT_OID_FUNC_ENTRY*
int dwFlags // DWORD
);
}@[Link("crypt32")]
lib LibCRYPT32
fun CryptInstallOIDFunctionAddress = CryptInstallOIDFunctionAddress(
hModule : Void*, # HMODULE optional
dwEncodingType : UInt32, # DWORD
pszFuncName : UInt8*, # LPCSTR
cFuncEntry : UInt32, # DWORD
rgFuncEntry : CRYPT_OID_FUNC_ENTRY*, # CRYPT_OID_FUNC_ENTRY*
dwFlags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CryptInstallOIDFunctionAddressNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf8>, Uint32, Pointer<Void>, Uint32);
typedef CryptInstallOIDFunctionAddressDart = int Function(Pointer<Void>, int, Pointer<Utf8>, int, Pointer<Void>, int);
final CryptInstallOIDFunctionAddress = DynamicLibrary.open('CRYPT32.dll')
.lookupFunction<CryptInstallOIDFunctionAddressNative, CryptInstallOIDFunctionAddressDart>('CryptInstallOIDFunctionAddress');
// hModule : HMODULE optional -> Pointer<Void>
// dwEncodingType : DWORD -> Uint32
// pszFuncName : LPCSTR -> Pointer<Utf8>
// cFuncEntry : DWORD -> Uint32
// rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> Pointer<Void>
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CryptInstallOIDFunctionAddress(
hModule: THandle; // HMODULE optional
dwEncodingType: DWORD; // DWORD
pszFuncName: PAnsiChar; // LPCSTR
cFuncEntry: DWORD; // DWORD
rgFuncEntry: Pointer; // CRYPT_OID_FUNC_ENTRY*
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptInstallOIDFunctionAddress';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CryptInstallOIDFunctionAddress"
c_CryptInstallOIDFunctionAddress :: Ptr () -> Word32 -> CString -> Word32 -> Ptr () -> Word32 -> IO CInt
-- hModule : HMODULE optional -> Ptr ()
-- dwEncodingType : DWORD -> Word32
-- pszFuncName : LPCSTR -> CString
-- cFuncEntry : DWORD -> Word32
-- rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> Ptr ()
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cryptinstalloidfunctionaddress =
foreign "CryptInstallOIDFunctionAddress"
((ptr void) @-> uint32_t @-> string @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* hModule : HMODULE optional -> (ptr void) *)
(* dwEncodingType : DWORD -> uint32_t *)
(* pszFuncName : LPCSTR -> string *)
(* cFuncEntry : DWORD -> uint32_t *)
(* rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> (ptr void) *)
(* dwFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library crypt32 (t "CRYPT32.dll"))
(cffi:use-foreign-library crypt32)
(cffi:defcfun ("CryptInstallOIDFunctionAddress" crypt-install-oidfunction-address :convention :stdcall) :int32
(h-module :pointer) ; HMODULE optional
(dw-encoding-type :uint32) ; DWORD
(psz-func-name :string) ; LPCSTR
(c-func-entry :uint32) ; DWORD
(rg-func-entry :pointer) ; CRYPT_OID_FUNC_ENTRY*
(dw-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CryptInstallOIDFunctionAddress = Win32::API::More->new('CRYPT32',
'BOOL CryptInstallOIDFunctionAddress(HANDLE hModule, DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry, LPVOID rgFuncEntry, DWORD dwFlags)');
# my $ret = $CryptInstallOIDFunctionAddress->Call($hModule, $dwEncodingType, $pszFuncName, $cFuncEntry, $rgFuncEntry, $dwFlags);
# hModule : HMODULE optional -> HANDLE
# dwEncodingType : DWORD -> DWORD
# pszFuncName : LPCSTR -> LPCSTR
# cFuncEntry : DWORD -> DWORD
# rgFuncEntry : CRYPT_OID_FUNC_ENTRY* -> LPVOID
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。