ホーム › Security.Cryptography › CryptMemAlloc
CryptMemAlloc
関数暗号API用のメモリを割り当てる。
シグネチャ
// CRYPT32.dll
#include <windows.h>
void* CryptMemAlloc(
DWORD cbSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| cbSize | DWORD | in |
戻り値の型: void*
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
void* CryptMemAlloc(
DWORD cbSize
);[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern IntPtr CryptMemAlloc(
uint cbSize // DWORD
);<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CryptMemAlloc(
cbSize As UInteger ' DWORD
) As IntPtr
End Function' cbSize : DWORD
Declare PtrSafe Function CryptMemAlloc Lib "crypt32" ( _
ByVal cbSize As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptMemAlloc = ctypes.windll.crypt32.CryptMemAlloc
CryptMemAlloc.restype = ctypes.c_void_p
CryptMemAlloc.argtypes = [
wintypes.DWORD, # cbSize : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptMemAlloc = Fiddle::Function.new(
lib['CryptMemAlloc'],
[
-Fiddle::TYPE_INT, # cbSize : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "crypt32")]
extern "system" {
fn CryptMemAlloc(
cbSize: u32 // DWORD
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CRYPT32.dll")]
public static extern IntPtr CryptMemAlloc(uint cbSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptMemAlloc' -Namespace Win32 -PassThru
# $api::CryptMemAlloc(cbSize)#uselib "CRYPT32.dll"
#func global CryptMemAlloc "CryptMemAlloc" sptr
; CryptMemAlloc cbSize ; 戻り値は stat
; cbSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CRYPT32.dll"
#cfunc global CryptMemAlloc "CryptMemAlloc" int
; res = CryptMemAlloc(cbSize)
; cbSize : DWORD -> "int"; void* CryptMemAlloc(DWORD cbSize)
#uselib "CRYPT32.dll"
#cfunc global CryptMemAlloc "CryptMemAlloc" int
; res = CryptMemAlloc(cbSize)
; cbSize : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptMemAlloc = crypt32.NewProc("CryptMemAlloc")
)
// cbSize (DWORD)
r1, _, err := procCryptMemAlloc.Call(
uintptr(cbSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function CryptMemAlloc(
cbSize: DWORD // DWORD
): Pointer; stdcall;
external 'CRYPT32.dll' name 'CryptMemAlloc';result := DllCall("CRYPT32\CryptMemAlloc"
, "UInt", cbSize ; DWORD
, "Ptr") ; return: void*●CryptMemAlloc(cbSize) = DLL("CRYPT32.dll", "void* CryptMemAlloc(dword)")
# 呼び出し: CryptMemAlloc(cbSize)
# cbSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。