ホーム › System.Environment › CreateEnclave
CreateEnclave
関数プロセス内に指定種別のセキュアエンクレーブを作成する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
void* CreateEnclave(
HANDLE hProcess,
void* lpAddress, // optional
UINT_PTR dwSize,
UINT_PTR dwInitialCommitment,
DWORD flEnclaveType,
const void* lpEnclaveInformation,
DWORD dwInfoLength,
DWORD* lpEnclaveError // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hProcess | HANDLE | in |
| lpAddress | void* | inoptional |
| dwSize | UINT_PTR | in |
| dwInitialCommitment | UINT_PTR | in |
| flEnclaveType | DWORD | in |
| lpEnclaveInformation | void* | in |
| dwInfoLength | DWORD | in |
| lpEnclaveError | DWORD* | outoptional |
戻り値の型: void*
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
void* CreateEnclave(
HANDLE hProcess,
void* lpAddress, // optional
UINT_PTR dwSize,
UINT_PTR dwInitialCommitment,
DWORD flEnclaveType,
const void* lpEnclaveInformation,
DWORD dwInfoLength,
DWORD* lpEnclaveError // optional
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateEnclave(
IntPtr hProcess, // HANDLE
IntPtr lpAddress, // void* optional
UIntPtr dwSize, // UINT_PTR
UIntPtr dwInitialCommitment, // UINT_PTR
uint flEnclaveType, // DWORD
IntPtr lpEnclaveInformation, // void*
uint dwInfoLength, // DWORD
IntPtr lpEnclaveError // DWORD* optional, out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateEnclave(
hProcess As IntPtr, ' HANDLE
lpAddress As IntPtr, ' void* optional
dwSize As UIntPtr, ' UINT_PTR
dwInitialCommitment As UIntPtr, ' UINT_PTR
flEnclaveType As UInteger, ' DWORD
lpEnclaveInformation As IntPtr, ' void*
dwInfoLength As UInteger, ' DWORD
lpEnclaveError As IntPtr ' DWORD* optional, out
) As IntPtr
End Function' hProcess : HANDLE
' lpAddress : void* optional
' dwSize : UINT_PTR
' dwInitialCommitment : UINT_PTR
' flEnclaveType : DWORD
' lpEnclaveInformation : void*
' dwInfoLength : DWORD
' lpEnclaveError : DWORD* optional, out
Declare PtrSafe Function CreateEnclave Lib "kernel32" ( _
ByVal hProcess As LongPtr, _
ByVal lpAddress As LongPtr, _
ByVal dwSize As LongPtr, _
ByVal dwInitialCommitment As LongPtr, _
ByVal flEnclaveType As Long, _
ByVal lpEnclaveInformation As LongPtr, _
ByVal dwInfoLength As Long, _
ByVal lpEnclaveError As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateEnclave = ctypes.windll.kernel32.CreateEnclave
CreateEnclave.restype = ctypes.c_void_p
CreateEnclave.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE
ctypes.POINTER(None), # lpAddress : void* optional
ctypes.c_size_t, # dwSize : UINT_PTR
ctypes.c_size_t, # dwInitialCommitment : UINT_PTR
wintypes.DWORD, # flEnclaveType : DWORD
ctypes.POINTER(None), # lpEnclaveInformation : void*
wintypes.DWORD, # dwInfoLength : DWORD
ctypes.POINTER(wintypes.DWORD), # lpEnclaveError : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
CreateEnclave = Fiddle::Function.new(
lib['CreateEnclave'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE
Fiddle::TYPE_VOIDP, # lpAddress : void* optional
Fiddle::TYPE_UINTPTR_T, # dwSize : UINT_PTR
Fiddle::TYPE_UINTPTR_T, # dwInitialCommitment : UINT_PTR
-Fiddle::TYPE_INT, # flEnclaveType : DWORD
Fiddle::TYPE_VOIDP, # lpEnclaveInformation : void*
-Fiddle::TYPE_INT, # dwInfoLength : DWORD
Fiddle::TYPE_VOIDP, # lpEnclaveError : DWORD* optional, out
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn CreateEnclave(
hProcess: *mut core::ffi::c_void, // HANDLE
lpAddress: *mut (), // void* optional
dwSize: usize, // UINT_PTR
dwInitialCommitment: usize, // UINT_PTR
flEnclaveType: u32, // DWORD
lpEnclaveInformation: *const (), // void*
dwInfoLength: u32, // DWORD
lpEnclaveError: *mut u32 // DWORD* optional, out
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern IntPtr CreateEnclave(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, UIntPtr dwInitialCommitment, uint flEnclaveType, IntPtr lpEnclaveInformation, uint dwInfoLength, IntPtr lpEnclaveError);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateEnclave' -Namespace Win32 -PassThru
# $api::CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, lpEnclaveError)#uselib "KERNEL32.dll"
#func global CreateEnclave "CreateEnclave" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CreateEnclave hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, varptr(lpEnclaveError) ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; lpAddress : void* optional -> "sptr"
; dwSize : UINT_PTR -> "sptr"
; dwInitialCommitment : UINT_PTR -> "sptr"
; flEnclaveType : DWORD -> "sptr"
; lpEnclaveInformation : void* -> "sptr"
; dwInfoLength : DWORD -> "sptr"
; lpEnclaveError : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global CreateEnclave "CreateEnclave" sptr, sptr, sptr, sptr, int, sptr, int, var ; res = CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, lpEnclaveError) ; hProcess : HANDLE -> "sptr" ; lpAddress : void* optional -> "sptr" ; dwSize : UINT_PTR -> "sptr" ; dwInitialCommitment : UINT_PTR -> "sptr" ; flEnclaveType : DWORD -> "int" ; lpEnclaveInformation : void* -> "sptr" ; dwInfoLength : DWORD -> "int" ; lpEnclaveError : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global CreateEnclave "CreateEnclave" sptr, sptr, sptr, sptr, int, sptr, int, sptr ; res = CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, varptr(lpEnclaveError)) ; hProcess : HANDLE -> "sptr" ; lpAddress : void* optional -> "sptr" ; dwSize : UINT_PTR -> "sptr" ; dwInitialCommitment : UINT_PTR -> "sptr" ; flEnclaveType : DWORD -> "int" ; lpEnclaveInformation : void* -> "sptr" ; dwInfoLength : DWORD -> "int" ; lpEnclaveError : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void* CreateEnclave(HANDLE hProcess, void* lpAddress, UINT_PTR dwSize, UINT_PTR dwInitialCommitment, DWORD flEnclaveType, void* lpEnclaveInformation, DWORD dwInfoLength, DWORD* lpEnclaveError) #uselib "KERNEL32.dll" #cfunc global CreateEnclave "CreateEnclave" intptr, intptr, intptr, intptr, int, intptr, int, var ; res = CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, lpEnclaveError) ; hProcess : HANDLE -> "intptr" ; lpAddress : void* optional -> "intptr" ; dwSize : UINT_PTR -> "intptr" ; dwInitialCommitment : UINT_PTR -> "intptr" ; flEnclaveType : DWORD -> "int" ; lpEnclaveInformation : void* -> "intptr" ; dwInfoLength : DWORD -> "int" ; lpEnclaveError : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void* CreateEnclave(HANDLE hProcess, void* lpAddress, UINT_PTR dwSize, UINT_PTR dwInitialCommitment, DWORD flEnclaveType, void* lpEnclaveInformation, DWORD dwInfoLength, DWORD* lpEnclaveError) #uselib "KERNEL32.dll" #cfunc global CreateEnclave "CreateEnclave" intptr, intptr, intptr, intptr, int, intptr, int, intptr ; res = CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, varptr(lpEnclaveError)) ; hProcess : HANDLE -> "intptr" ; lpAddress : void* optional -> "intptr" ; dwSize : UINT_PTR -> "intptr" ; dwInitialCommitment : UINT_PTR -> "intptr" ; flEnclaveType : DWORD -> "int" ; lpEnclaveInformation : void* -> "intptr" ; dwInfoLength : DWORD -> "int" ; lpEnclaveError : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procCreateEnclave = kernel32.NewProc("CreateEnclave")
)
// hProcess (HANDLE), lpAddress (void* optional), dwSize (UINT_PTR), dwInitialCommitment (UINT_PTR), flEnclaveType (DWORD), lpEnclaveInformation (void*), dwInfoLength (DWORD), lpEnclaveError (DWORD* optional, out)
r1, _, err := procCreateEnclave.Call(
uintptr(hProcess),
uintptr(lpAddress),
uintptr(dwSize),
uintptr(dwInitialCommitment),
uintptr(flEnclaveType),
uintptr(lpEnclaveInformation),
uintptr(dwInfoLength),
uintptr(lpEnclaveError),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function CreateEnclave(
hProcess: THandle; // HANDLE
lpAddress: Pointer; // void* optional
dwSize: NativeUInt; // UINT_PTR
dwInitialCommitment: NativeUInt; // UINT_PTR
flEnclaveType: DWORD; // DWORD
lpEnclaveInformation: Pointer; // void*
dwInfoLength: DWORD; // DWORD
lpEnclaveError: Pointer // DWORD* optional, out
): Pointer; stdcall;
external 'KERNEL32.dll' name 'CreateEnclave';result := DllCall("KERNEL32\CreateEnclave"
, "Ptr", hProcess ; HANDLE
, "Ptr", lpAddress ; void* optional
, "UPtr", dwSize ; UINT_PTR
, "UPtr", dwInitialCommitment ; UINT_PTR
, "UInt", flEnclaveType ; DWORD
, "Ptr", lpEnclaveInformation ; void*
, "UInt", dwInfoLength ; DWORD
, "Ptr", lpEnclaveError ; DWORD* optional, out
, "Ptr") ; return: void*●CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, lpEnclaveError) = DLL("KERNEL32.dll", "void* CreateEnclave(void*, void*, int, int, dword, void*, dword, void*)")
# 呼び出し: CreateEnclave(hProcess, lpAddress, dwSize, dwInitialCommitment, flEnclaveType, lpEnclaveInformation, dwInfoLength, lpEnclaveError)
# hProcess : HANDLE -> "void*"
# lpAddress : void* optional -> "void*"
# dwSize : UINT_PTR -> "int"
# dwInitialCommitment : UINT_PTR -> "int"
# flEnclaveType : DWORD -> "dword"
# lpEnclaveInformation : void* -> "void*"
# dwInfoLength : DWORD -> "dword"
# lpEnclaveError : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。