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

EnclaveCopyIntoEnclave

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

シグネチャ

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

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

パラメーター

名前方向説明
EnclaveAddressvoid*outコピー先となるエンクレーブ内のアドレス。
UnsecureAddressvoid*inコピー元となる非セキュア(通常)メモリのアドレス。
NumberOfBytesUINT_PTRinコピーするバイト数。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT EnclaveCopyIntoEnclave(
    void* EnclaveAddress,
    const void* UnsecureAddress,
    UINT_PTR NumberOfBytes
);
[DllImport("vertdll.dll", ExactSpelling = true)]
static extern int EnclaveCopyIntoEnclave(
    IntPtr EnclaveAddress,   // void* out
    IntPtr UnsecureAddress,   // void*
    UIntPtr NumberOfBytes   // UINT_PTR
);
<DllImport("vertdll.dll", ExactSpelling:=True)>
Public Shared Function EnclaveCopyIntoEnclave(
    EnclaveAddress As IntPtr,   ' void* out
    UnsecureAddress As IntPtr,   ' void*
    NumberOfBytes As UIntPtr   ' UINT_PTR
) As Integer
End Function
' EnclaveAddress : void* out
' UnsecureAddress : void*
' NumberOfBytes : UINT_PTR
Declare PtrSafe Function EnclaveCopyIntoEnclave Lib "vertdll" ( _
    ByVal EnclaveAddress As LongPtr, _
    ByVal UnsecureAddress 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

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

lib = Fiddle.dlopen('vertdll.dll')
EnclaveCopyIntoEnclave = Fiddle::Function.new(
  lib['EnclaveCopyIntoEnclave'],
  [
    Fiddle::TYPE_VOIDP,  # EnclaveAddress : void* out
    Fiddle::TYPE_VOIDP,  # UnsecureAddress : void*
    Fiddle::TYPE_UINTPTR_T,  # NumberOfBytes : UINT_PTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "vertdll")]
extern "system" {
    fn EnclaveCopyIntoEnclave(
        EnclaveAddress: *mut (),  // void* out
        UnsecureAddress: *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 EnclaveCopyIntoEnclave(IntPtr EnclaveAddress, IntPtr UnsecureAddress, UIntPtr NumberOfBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'vertdll_EnclaveCopyIntoEnclave' -Namespace Win32 -PassThru
# $api::EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes)
#uselib "vertdll.dll"
#func global EnclaveCopyIntoEnclave "EnclaveCopyIntoEnclave" sptr, sptr, sptr
; EnclaveCopyIntoEnclave EnclaveAddress, UnsecureAddress, NumberOfBytes   ; 戻り値は stat
; EnclaveAddress : void* out -> "sptr"
; UnsecureAddress : void* -> "sptr"
; NumberOfBytes : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "vertdll.dll"
#cfunc global EnclaveCopyIntoEnclave "EnclaveCopyIntoEnclave" sptr, sptr, sptr
; res = EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes)
; EnclaveAddress : void* out -> "sptr"
; UnsecureAddress : void* -> "sptr"
; NumberOfBytes : UINT_PTR -> "sptr"
; HRESULT EnclaveCopyIntoEnclave(void* EnclaveAddress, void* UnsecureAddress, UINT_PTR NumberOfBytes)
#uselib "vertdll.dll"
#cfunc global EnclaveCopyIntoEnclave "EnclaveCopyIntoEnclave" intptr, intptr, intptr
; res = EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes)
; EnclaveAddress : void* out -> "intptr"
; UnsecureAddress : void* -> "intptr"
; NumberOfBytes : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	vertdll = windows.NewLazySystemDLL("vertdll.dll")
	procEnclaveCopyIntoEnclave = vertdll.NewProc("EnclaveCopyIntoEnclave")
)

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

extern "vertdll" fn EnclaveCopyIntoEnclave(
    EnclaveAddress: ?*anyopaque, // void* out
    UnsecureAddress: ?*anyopaque, // void*
    NumberOfBytes: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) i32;
proc EnclaveCopyIntoEnclave(
    EnclaveAddress: pointer,  # void* out
    UnsecureAddress: pointer,  # void*
    NumberOfBytes: uint  # UINT_PTR
): int32 {.importc: "EnclaveCopyIntoEnclave", stdcall, dynlib: "vertdll.dll".}
pragma(lib, "vertdll");
extern(Windows)
int EnclaveCopyIntoEnclave(
    void* EnclaveAddress,   // void* out
    void* UnsecureAddress,   // void*
    size_t NumberOfBytes   // UINT_PTR
);
ccall((:EnclaveCopyIntoEnclave, "vertdll.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t),
      EnclaveAddress, UnsecureAddress, NumberOfBytes)
# EnclaveAddress : void* out -> Ptr{Cvoid}
# UnsecureAddress : void* -> Ptr{Cvoid}
# NumberOfBytes : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t EnclaveCopyIntoEnclave(
    void* EnclaveAddress,
    void* UnsecureAddress,
    uintptr_t NumberOfBytes);
]]
local vertdll = ffi.load("vertdll")
-- vertdll.EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes)
-- EnclaveAddress : void* out
-- UnsecureAddress : void*
-- NumberOfBytes : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('vertdll.dll');
const EnclaveCopyIntoEnclave = lib.func('__stdcall', 'EnclaveCopyIntoEnclave', 'int32_t', ['void *', 'void *', 'uintptr_t']);
// EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes)
// EnclaveAddress : void* out -> 'void *'
// UnsecureAddress : void* -> 'void *'
// NumberOfBytes : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("vertdll.dll", {
  EnclaveCopyIntoEnclave: { parameters: ["pointer", "pointer", "usize"], result: "i32" },
});
// lib.symbols.EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes)
// EnclaveAddress : void* out -> "pointer"
// UnsecureAddress : void* -> "pointer"
// NumberOfBytes : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t EnclaveCopyIntoEnclave(
    void* EnclaveAddress,
    void* UnsecureAddress,
    size_t NumberOfBytes);
C, "vertdll.dll");
// $ffi->EnclaveCopyIntoEnclave(EnclaveAddress, UnsecureAddress, NumberOfBytes);
// EnclaveAddress : void* out
// UnsecureAddress : void*
// NumberOfBytes : UINT_PTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Vertdll extends StdCallLibrary {
    Vertdll INSTANCE = Native.load("vertdll", Vertdll.class);
    int EnclaveCopyIntoEnclave(
        Pointer EnclaveAddress,   // void* out
        Pointer UnsecureAddress,   // void*
        long NumberOfBytes   // UINT_PTR
    );
}
@[Link("vertdll")]
lib Libvertdll
  fun EnclaveCopyIntoEnclave = EnclaveCopyIntoEnclave(
    EnclaveAddress : Void*,   # void* out
    UnsecureAddress : Void*,   # void*
    NumberOfBytes : LibC::SizeT   # UINT_PTR
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef EnclaveCopyIntoEnclaveNative = Int32 Function(Pointer<Void>, Pointer<Void>, UintPtr);
typedef EnclaveCopyIntoEnclaveDart = int Function(Pointer<Void>, Pointer<Void>, int);
final EnclaveCopyIntoEnclave = DynamicLibrary.open('vertdll.dll')
    .lookupFunction<EnclaveCopyIntoEnclaveNative, EnclaveCopyIntoEnclaveDart>('EnclaveCopyIntoEnclave');
// EnclaveAddress : void* out -> Pointer<Void>
// UnsecureAddress : void* -> Pointer<Void>
// NumberOfBytes : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function EnclaveCopyIntoEnclave(
  EnclaveAddress: Pointer;   // void* out
  UnsecureAddress: Pointer;   // void*
  NumberOfBytes: NativeUInt   // UINT_PTR
): Integer; stdcall;
  external 'vertdll.dll' name 'EnclaveCopyIntoEnclave';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "EnclaveCopyIntoEnclave"
  c_EnclaveCopyIntoEnclave :: Ptr () -> Ptr () -> CUIntPtr -> IO Int32
-- EnclaveAddress : void* out -> Ptr ()
-- UnsecureAddress : void* -> Ptr ()
-- NumberOfBytes : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let enclavecopyintoenclave =
  foreign "EnclaveCopyIntoEnclave"
    ((ptr void) @-> (ptr void) @-> size_t @-> returning int32_t)
(* EnclaveAddress : void* out -> (ptr void) *)
(* UnsecureAddress : void* -> (ptr void) *)
(* NumberOfBytes : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library vertdll (t "vertdll.dll"))
(cffi:use-foreign-library vertdll)

(cffi:defcfun ("EnclaveCopyIntoEnclave" enclave-copy-into-enclave :convention :stdcall) :int32
  (enclave-address :pointer)   ; void* out
  (unsecure-address :pointer)   ; void*
  (number-of-bytes :uint64))   ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $EnclaveCopyIntoEnclave = Win32::API::More->new('vertdll',
    'int EnclaveCopyIntoEnclave(LPVOID EnclaveAddress, LPVOID UnsecureAddress, WPARAM NumberOfBytes)');
# my $ret = $EnclaveCopyIntoEnclave->Call($EnclaveAddress, $UnsecureAddress, $NumberOfBytes);
# EnclaveAddress : void* out -> LPVOID
# UnsecureAddress : void* -> LPVOID
# NumberOfBytes : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。