Win32 API 日本語リファレンス
ホームSecurity.Cryptography › CryptInstallOIDFunctionAddress

CryptInstallOIDFunctionAddress

関数
OID関数のアドレスを登録テーブルにインストールする。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CryptInstallOIDFunctionAddress(
    HMODULE hModule,   // optional
    DWORD dwEncodingType,
    LPCSTR pszFuncName,
    DWORD cFuncEntry,
    const CRYPT_OID_FUNC_ENTRY* rgFuncEntry,
    DWORD dwFlags
);

パラメーター

名前方向
hModuleHMODULEinoptional
dwEncodingTypeDWORDin
pszFuncNameLPCSTRin
cFuncEntryDWORDin
rgFuncEntryCRYPT_OID_FUNC_ENTRY*in
dwFlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// 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 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // BOOL
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';
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)。