ホーム › Security.Cryptography › CryptMsgGetParam
CryptMsgGetParam
関数暗号メッセージから指定したパラメーターを取得する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptMsgGetParam(
void* hCryptMsg,
DWORD dwParamType,
DWORD dwIndex,
void* pvData, // optional
DWORD* pcbData
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hCryptMsg | void* | in |
| dwParamType | DWORD | in |
| dwIndex | DWORD | in |
| pvData | void* | outoptional |
| pcbData | DWORD* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptMsgGetParam(
void* hCryptMsg,
DWORD dwParamType,
DWORD dwIndex,
void* pvData, // optional
DWORD* pcbData
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptMsgGetParam(
IntPtr hCryptMsg, // void*
uint dwParamType, // DWORD
uint dwIndex, // DWORD
IntPtr pvData, // void* optional, out
ref uint pcbData // DWORD* in/out
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptMsgGetParam(
hCryptMsg As IntPtr, ' void*
dwParamType As UInteger, ' DWORD
dwIndex As UInteger, ' DWORD
pvData As IntPtr, ' void* optional, out
ByRef pcbData As UInteger ' DWORD* in/out
) As Boolean
End Function' hCryptMsg : void*
' dwParamType : DWORD
' dwIndex : DWORD
' pvData : void* optional, out
' pcbData : DWORD* in/out
Declare PtrSafe Function CryptMsgGetParam Lib "crypt32" ( _
ByVal hCryptMsg As LongPtr, _
ByVal dwParamType As Long, _
ByVal dwIndex As Long, _
ByVal pvData As LongPtr, _
ByRef pcbData As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptMsgGetParam = ctypes.windll.crypt32.CryptMsgGetParam
CryptMsgGetParam.restype = wintypes.BOOL
CryptMsgGetParam.argtypes = [
ctypes.POINTER(None), # hCryptMsg : void*
wintypes.DWORD, # dwParamType : DWORD
wintypes.DWORD, # dwIndex : DWORD
ctypes.POINTER(None), # pvData : void* optional, out
ctypes.POINTER(wintypes.DWORD), # pcbData : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptMsgGetParam = Fiddle::Function.new(
lib['CryptMsgGetParam'],
[
Fiddle::TYPE_VOIDP, # hCryptMsg : void*
-Fiddle::TYPE_INT, # dwParamType : DWORD
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_VOIDP, # pvData : void* optional, out
Fiddle::TYPE_VOIDP, # pcbData : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptMsgGetParam(
hCryptMsg: *mut (), // void*
dwParamType: u32, // DWORD
dwIndex: u32, // DWORD
pvData: *mut (), // void* optional, out
pcbData: *mut u32 // DWORD* in/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 CryptMsgGetParam(IntPtr hCryptMsg, uint dwParamType, uint dwIndex, IntPtr pvData, ref uint pcbData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptMsgGetParam' -Namespace Win32 -PassThru
# $api::CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, pcbData)#uselib "CRYPT32.dll"
#func global CryptMsgGetParam "CryptMsgGetParam" sptr, sptr, sptr, sptr, sptr
; CryptMsgGetParam hCryptMsg, dwParamType, dwIndex, pvData, varptr(pcbData) ; 戻り値は stat
; hCryptMsg : void* -> "sptr"
; dwParamType : DWORD -> "sptr"
; dwIndex : DWORD -> "sptr"
; pvData : void* optional, out -> "sptr"
; pcbData : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CRYPT32.dll" #cfunc global CryptMsgGetParam "CryptMsgGetParam" sptr, int, int, sptr, var ; res = CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, pcbData) ; hCryptMsg : void* -> "sptr" ; dwParamType : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pvData : void* optional, out -> "sptr" ; pcbData : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CRYPT32.dll" #cfunc global CryptMsgGetParam "CryptMsgGetParam" sptr, int, int, sptr, sptr ; res = CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, varptr(pcbData)) ; hCryptMsg : void* -> "sptr" ; dwParamType : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pvData : void* optional, out -> "sptr" ; pcbData : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CryptMsgGetParam(void* hCryptMsg, DWORD dwParamType, DWORD dwIndex, void* pvData, DWORD* pcbData) #uselib "CRYPT32.dll" #cfunc global CryptMsgGetParam "CryptMsgGetParam" intptr, int, int, intptr, var ; res = CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, pcbData) ; hCryptMsg : void* -> "intptr" ; dwParamType : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pvData : void* optional, out -> "intptr" ; pcbData : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CryptMsgGetParam(void* hCryptMsg, DWORD dwParamType, DWORD dwIndex, void* pvData, DWORD* pcbData) #uselib "CRYPT32.dll" #cfunc global CryptMsgGetParam "CryptMsgGetParam" intptr, int, int, intptr, intptr ; res = CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, varptr(pcbData)) ; hCryptMsg : void* -> "intptr" ; dwParamType : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pvData : void* optional, out -> "intptr" ; pcbData : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptMsgGetParam = crypt32.NewProc("CryptMsgGetParam")
)
// hCryptMsg (void*), dwParamType (DWORD), dwIndex (DWORD), pvData (void* optional, out), pcbData (DWORD* in/out)
r1, _, err := procCryptMsgGetParam.Call(
uintptr(hCryptMsg),
uintptr(dwParamType),
uintptr(dwIndex),
uintptr(pvData),
uintptr(pcbData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptMsgGetParam(
hCryptMsg: Pointer; // void*
dwParamType: DWORD; // DWORD
dwIndex: DWORD; // DWORD
pvData: Pointer; // void* optional, out
pcbData: Pointer // DWORD* in/out
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptMsgGetParam';result := DllCall("CRYPT32\CryptMsgGetParam"
, "Ptr", hCryptMsg ; void*
, "UInt", dwParamType ; DWORD
, "UInt", dwIndex ; DWORD
, "Ptr", pvData ; void* optional, out
, "Ptr", pcbData ; DWORD* in/out
, "Int") ; return: BOOL●CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, pcbData) = DLL("CRYPT32.dll", "bool CryptMsgGetParam(void*, dword, dword, void*, void*)")
# 呼び出し: CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, pcbData)
# hCryptMsg : void* -> "void*"
# dwParamType : DWORD -> "dword"
# dwIndex : DWORD -> "dword"
# pvData : void* optional, out -> "void*"
# pcbData : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。