Win32 API 日本語リファレンス
ホームSystem.Environment › EnclaveCopyOutOfEnclave

EnclaveCopyOutOfEnclave

関数
エンクレーブ内から非保護領域へデータをコピーする。
DLLvertdll.dll呼出規約winapi

シグネチャ

// vertdll.dll
#include <windows.h>

HRESULT EnclaveCopyOutOfEnclave(
    void* UnsecureAddress,
    const void* EnclaveAddress,
    UINT_PTR NumberOfBytes
);

パラメーター

名前方向
UnsecureAddressvoid*out
EnclaveAddressvoid*in
NumberOfBytesUINT_PTRin

戻り値の型: HRESULT

各言語での呼び出し定義

// vertdll.dll
#include <windows.h>

HRESULT EnclaveCopyOutOfEnclave(
    void* UnsecureAddress,
    const void* EnclaveAddress,
    UINT_PTR NumberOfBytes
);
[DllImport("vertdll.dll", ExactSpelling = true)]
static extern int EnclaveCopyOutOfEnclave(
    IntPtr UnsecureAddress,   // void* out
    IntPtr EnclaveAddress,   // void*
    UIntPtr NumberOfBytes   // UINT_PTR
);
<DllImport("vertdll.dll", ExactSpelling:=True)>
Public Shared Function EnclaveCopyOutOfEnclave(
    UnsecureAddress As IntPtr,   ' void* out
    EnclaveAddress As IntPtr,   ' void*
    NumberOfBytes As UIntPtr   ' UINT_PTR
) As Integer
End Function
' UnsecureAddress : void* out
' EnclaveAddress : void*
' NumberOfBytes : UINT_PTR
Declare PtrSafe Function EnclaveCopyOutOfEnclave Lib "vertdll" ( _
    ByVal UnsecureAddress As LongPtr, _
    ByVal EnclaveAddress As LongPtr, _
    ByVal NumberOfBytes As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EnclaveCopyOutOfEnclave = ctypes.windll.vertdll.EnclaveCopyOutOfEnclave
EnclaveCopyOutOfEnclave.restype = ctypes.c_int
EnclaveCopyOutOfEnclave.argtypes = [
    ctypes.POINTER(None),  # UnsecureAddress : void* out
    ctypes.POINTER(None),  # EnclaveAddress : void*
    ctypes.c_size_t,  # NumberOfBytes : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('vertdll.dll')
EnclaveCopyOutOfEnclave = Fiddle::Function.new(
  lib['EnclaveCopyOutOfEnclave'],
  [
    Fiddle::TYPE_VOIDP,  # UnsecureAddress : void* out
    Fiddle::TYPE_VOIDP,  # EnclaveAddress : void*
    Fiddle::TYPE_UINTPTR_T,  # NumberOfBytes : UINT_PTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "vertdll")]
extern "system" {
    fn EnclaveCopyOutOfEnclave(
        UnsecureAddress: *mut (),  // void* out
        EnclaveAddress: *const (),  // void*
        NumberOfBytes: usize  // UINT_PTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("vertdll.dll")]
public static extern int EnclaveCopyOutOfEnclave(IntPtr UnsecureAddress, IntPtr EnclaveAddress, UIntPtr NumberOfBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'vertdll_EnclaveCopyOutOfEnclave' -Namespace Win32 -PassThru
# $api::EnclaveCopyOutOfEnclave(UnsecureAddress, EnclaveAddress, NumberOfBytes)
#uselib "vertdll.dll"
#func global EnclaveCopyOutOfEnclave "EnclaveCopyOutOfEnclave" sptr, sptr, sptr
; EnclaveCopyOutOfEnclave UnsecureAddress, EnclaveAddress, NumberOfBytes   ; 戻り値は stat
; UnsecureAddress : void* out -> "sptr"
; EnclaveAddress : void* -> "sptr"
; NumberOfBytes : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "vertdll.dll"
#cfunc global EnclaveCopyOutOfEnclave "EnclaveCopyOutOfEnclave" sptr, sptr, sptr
; res = EnclaveCopyOutOfEnclave(UnsecureAddress, EnclaveAddress, NumberOfBytes)
; UnsecureAddress : void* out -> "sptr"
; EnclaveAddress : void* -> "sptr"
; NumberOfBytes : UINT_PTR -> "sptr"
; HRESULT EnclaveCopyOutOfEnclave(void* UnsecureAddress, void* EnclaveAddress, UINT_PTR NumberOfBytes)
#uselib "vertdll.dll"
#cfunc global EnclaveCopyOutOfEnclave "EnclaveCopyOutOfEnclave" intptr, intptr, intptr
; res = EnclaveCopyOutOfEnclave(UnsecureAddress, EnclaveAddress, NumberOfBytes)
; UnsecureAddress : void* out -> "intptr"
; EnclaveAddress : void* -> "intptr"
; NumberOfBytes : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	vertdll = windows.NewLazySystemDLL("vertdll.dll")
	procEnclaveCopyOutOfEnclave = vertdll.NewProc("EnclaveCopyOutOfEnclave")
)

// UnsecureAddress (void* out), EnclaveAddress (void*), NumberOfBytes (UINT_PTR)
r1, _, err := procEnclaveCopyOutOfEnclave.Call(
	uintptr(UnsecureAddress),
	uintptr(EnclaveAddress),
	uintptr(NumberOfBytes),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function EnclaveCopyOutOfEnclave(
  UnsecureAddress: Pointer;   // void* out
  EnclaveAddress: Pointer;   // void*
  NumberOfBytes: NativeUInt   // UINT_PTR
): Integer; stdcall;
  external 'vertdll.dll' name 'EnclaveCopyOutOfEnclave';
result := DllCall("vertdll\EnclaveCopyOutOfEnclave"
    , "Ptr", UnsecureAddress   ; void* out
    , "Ptr", EnclaveAddress   ; void*
    , "UPtr", NumberOfBytes   ; UINT_PTR
    , "Int")   ; return: HRESULT
●EnclaveCopyOutOfEnclave(UnsecureAddress, EnclaveAddress, NumberOfBytes) = DLL("vertdll.dll", "int EnclaveCopyOutOfEnclave(void*, void*, int)")
# 呼び出し: EnclaveCopyOutOfEnclave(UnsecureAddress, EnclaveAddress, NumberOfBytes)
# UnsecureAddress : void* out -> "void*"
# EnclaveAddress : void* -> "void*"
# NumberOfBytes : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。