ホーム › Security.Cryptography › CryptGetOIDFunctionAddress
CryptGetOIDFunctionAddress
関数指定OIDに対応する関数のアドレスを取得する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptGetOIDFunctionAddress(
void* hFuncSet,
DWORD dwEncodingType,
LPCSTR pszOID,
DWORD dwFlags,
void** ppvFuncAddr,
void** phFuncAddr
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hFuncSet | void* | in |
| dwEncodingType | DWORD | in |
| pszOID | LPCSTR | in |
| dwFlags | DWORD | in |
| ppvFuncAddr | void** | out |
| phFuncAddr | void** | out |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptGetOIDFunctionAddress(
void* hFuncSet,
DWORD dwEncodingType,
LPCSTR pszOID,
DWORD dwFlags,
void** ppvFuncAddr,
void** phFuncAddr
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptGetOIDFunctionAddress(
IntPtr hFuncSet, // void*
uint dwEncodingType, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string pszOID, // LPCSTR
uint dwFlags, // DWORD
IntPtr ppvFuncAddr, // void** out
IntPtr phFuncAddr // void** out
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptGetOIDFunctionAddress(
hFuncSet As IntPtr, ' void*
dwEncodingType As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszOID As String, ' LPCSTR
dwFlags As UInteger, ' DWORD
ppvFuncAddr As IntPtr, ' void** out
phFuncAddr As IntPtr ' void** out
) As Boolean
End Function' hFuncSet : void*
' dwEncodingType : DWORD
' pszOID : LPCSTR
' dwFlags : DWORD
' ppvFuncAddr : void** out
' phFuncAddr : void** out
Declare PtrSafe Function CryptGetOIDFunctionAddress Lib "crypt32" ( _
ByVal hFuncSet As LongPtr, _
ByVal dwEncodingType As Long, _
ByVal pszOID As String, _
ByVal dwFlags As Long, _
ByVal ppvFuncAddr As LongPtr, _
ByVal phFuncAddr As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptGetOIDFunctionAddress = ctypes.windll.crypt32.CryptGetOIDFunctionAddress
CryptGetOIDFunctionAddress.restype = wintypes.BOOL
CryptGetOIDFunctionAddress.argtypes = [
ctypes.POINTER(None), # hFuncSet : void*
wintypes.DWORD, # dwEncodingType : DWORD
wintypes.LPCSTR, # pszOID : LPCSTR
wintypes.DWORD, # dwFlags : DWORD
ctypes.c_void_p, # ppvFuncAddr : void** out
ctypes.c_void_p, # phFuncAddr : void** out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptGetOIDFunctionAddress = Fiddle::Function.new(
lib['CryptGetOIDFunctionAddress'],
[
Fiddle::TYPE_VOIDP, # hFuncSet : void*
-Fiddle::TYPE_INT, # dwEncodingType : DWORD
Fiddle::TYPE_VOIDP, # pszOID : LPCSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # ppvFuncAddr : void** out
Fiddle::TYPE_VOIDP, # phFuncAddr : void** out
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptGetOIDFunctionAddress(
hFuncSet: *mut (), // void*
dwEncodingType: u32, // DWORD
pszOID: *const u8, // LPCSTR
dwFlags: u32, // DWORD
ppvFuncAddr: *mut *mut (), // void** out
phFuncAddr: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern bool CryptGetOIDFunctionAddress(IntPtr hFuncSet, uint dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszOID, uint dwFlags, IntPtr ppvFuncAddr, IntPtr phFuncAddr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptGetOIDFunctionAddress' -Namespace Win32 -PassThru
# $api::CryptGetOIDFunctionAddress(hFuncSet, dwEncodingType, pszOID, dwFlags, ppvFuncAddr, phFuncAddr)#uselib "CRYPT32.dll"
#func global CryptGetOIDFunctionAddress "CryptGetOIDFunctionAddress" sptr, sptr, sptr, sptr, sptr, sptr
; CryptGetOIDFunctionAddress hFuncSet, dwEncodingType, pszOID, dwFlags, ppvFuncAddr, phFuncAddr ; 戻り値は stat
; hFuncSet : void* -> "sptr"
; dwEncodingType : DWORD -> "sptr"
; pszOID : LPCSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; ppvFuncAddr : void** out -> "sptr"
; phFuncAddr : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CRYPT32.dll"
#cfunc global CryptGetOIDFunctionAddress "CryptGetOIDFunctionAddress" sptr, int, str, int, sptr, sptr
; res = CryptGetOIDFunctionAddress(hFuncSet, dwEncodingType, pszOID, dwFlags, ppvFuncAddr, phFuncAddr)
; hFuncSet : void* -> "sptr"
; dwEncodingType : DWORD -> "int"
; pszOID : LPCSTR -> "str"
; dwFlags : DWORD -> "int"
; ppvFuncAddr : void** out -> "sptr"
; phFuncAddr : void** out -> "sptr"; BOOL CryptGetOIDFunctionAddress(void* hFuncSet, DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void** ppvFuncAddr, void** phFuncAddr)
#uselib "CRYPT32.dll"
#cfunc global CryptGetOIDFunctionAddress "CryptGetOIDFunctionAddress" intptr, int, str, int, intptr, intptr
; res = CryptGetOIDFunctionAddress(hFuncSet, dwEncodingType, pszOID, dwFlags, ppvFuncAddr, phFuncAddr)
; hFuncSet : void* -> "intptr"
; dwEncodingType : DWORD -> "int"
; pszOID : LPCSTR -> "str"
; dwFlags : DWORD -> "int"
; ppvFuncAddr : void** out -> "intptr"
; phFuncAddr : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptGetOIDFunctionAddress = crypt32.NewProc("CryptGetOIDFunctionAddress")
)
// hFuncSet (void*), dwEncodingType (DWORD), pszOID (LPCSTR), dwFlags (DWORD), ppvFuncAddr (void** out), phFuncAddr (void** out)
r1, _, err := procCryptGetOIDFunctionAddress.Call(
uintptr(hFuncSet),
uintptr(dwEncodingType),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszOID))),
uintptr(dwFlags),
uintptr(ppvFuncAddr),
uintptr(phFuncAddr),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptGetOIDFunctionAddress(
hFuncSet: Pointer; // void*
dwEncodingType: DWORD; // DWORD
pszOID: PAnsiChar; // LPCSTR
dwFlags: DWORD; // DWORD
ppvFuncAddr: Pointer; // void** out
phFuncAddr: Pointer // void** out
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptGetOIDFunctionAddress';result := DllCall("CRYPT32\CryptGetOIDFunctionAddress"
, "Ptr", hFuncSet ; void*
, "UInt", dwEncodingType ; DWORD
, "AStr", pszOID ; LPCSTR
, "UInt", dwFlags ; DWORD
, "Ptr", ppvFuncAddr ; void** out
, "Ptr", phFuncAddr ; void** out
, "Int") ; return: BOOL●CryptGetOIDFunctionAddress(hFuncSet, dwEncodingType, pszOID, dwFlags, ppvFuncAddr, phFuncAddr) = DLL("CRYPT32.dll", "bool CryptGetOIDFunctionAddress(void*, dword, char*, dword, void*, void*)")
# 呼び出し: CryptGetOIDFunctionAddress(hFuncSet, dwEncodingType, pszOID, dwFlags, ppvFuncAddr, phFuncAddr)
# hFuncSet : void* -> "void*"
# dwEncodingType : DWORD -> "dword"
# pszOID : LPCSTR -> "char*"
# dwFlags : DWORD -> "dword"
# ppvFuncAddr : void** out -> "void*"
# phFuncAddr : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。