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