ホーム › System.Environment › CallEnclave
CallEnclave
関数エンクレーブ内のルーチンを呼び出して実行する。
シグネチャ
// vertdll.dll
#include <windows.h>
BOOL CallEnclave(
INT_PTR lpRoutine,
void* lpParameter,
BOOL fWaitForThread,
void** lpReturnValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpRoutine | INT_PTR | in | 呼び出すエンクレーブ内のエクスポート済みルーチンのアドレス。 |
| lpParameter | void* | in | ルーチンへ渡すパラメータポインタ。 |
| fWaitForThread | BOOL | in | 利用可能なエンクレーブスレッドを待機するかどうかを示すブール値。 |
| lpReturnValue | void** | out | ルーチンの戻り値を受け取るポインタ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// vertdll.dll
#include <windows.h>
BOOL CallEnclave(
INT_PTR lpRoutine,
void* lpParameter,
BOOL fWaitForThread,
void** lpReturnValue
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("vertdll.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CallEnclave(
IntPtr lpRoutine, // INT_PTR
IntPtr lpParameter, // void*
bool fWaitForThread, // BOOL
IntPtr lpReturnValue // void** out
);<DllImport("vertdll.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CallEnclave(
lpRoutine As IntPtr, ' INT_PTR
lpParameter As IntPtr, ' void*
fWaitForThread As Boolean, ' BOOL
lpReturnValue As IntPtr ' void** out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' lpRoutine : INT_PTR
' lpParameter : void*
' fWaitForThread : BOOL
' lpReturnValue : void** out
Declare PtrSafe Function CallEnclave Lib "vertdll" ( _
ByVal lpRoutine As LongPtr, _
ByVal lpParameter As LongPtr, _
ByVal fWaitForThread As Long, _
ByVal lpReturnValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CallEnclave = ctypes.windll.vertdll.CallEnclave
CallEnclave.restype = wintypes.BOOL
CallEnclave.argtypes = [
ctypes.c_ssize_t, # lpRoutine : INT_PTR
ctypes.POINTER(None), # lpParameter : void*
wintypes.BOOL, # fWaitForThread : BOOL
ctypes.c_void_p, # lpReturnValue : void** out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('vertdll.dll')
CallEnclave = Fiddle::Function.new(
lib['CallEnclave'],
[
Fiddle::TYPE_INTPTR_T, # lpRoutine : INT_PTR
Fiddle::TYPE_VOIDP, # lpParameter : void*
Fiddle::TYPE_INT, # fWaitForThread : BOOL
Fiddle::TYPE_VOIDP, # lpReturnValue : void** out
],
Fiddle::TYPE_INT)#[link(name = "vertdll")]
extern "system" {
fn CallEnclave(
lpRoutine: isize, // INT_PTR
lpParameter: *mut (), // void*
fWaitForThread: i32, // BOOL
lpReturnValue: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("vertdll.dll", SetLastError = true)]
public static extern bool CallEnclave(IntPtr lpRoutine, IntPtr lpParameter, bool fWaitForThread, IntPtr lpReturnValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'vertdll_CallEnclave' -Namespace Win32 -PassThru
# $api::CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)#uselib "vertdll.dll"
#func global CallEnclave "CallEnclave" sptr, sptr, sptr, sptr
; CallEnclave lpRoutine, lpParameter, fWaitForThread, lpReturnValue ; 戻り値は stat
; lpRoutine : INT_PTR -> "sptr"
; lpParameter : void* -> "sptr"
; fWaitForThread : BOOL -> "sptr"
; lpReturnValue : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "vertdll.dll"
#cfunc global CallEnclave "CallEnclave" sptr, sptr, int, sptr
; res = CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
; lpRoutine : INT_PTR -> "sptr"
; lpParameter : void* -> "sptr"
; fWaitForThread : BOOL -> "int"
; lpReturnValue : void** out -> "sptr"; BOOL CallEnclave(INT_PTR lpRoutine, void* lpParameter, BOOL fWaitForThread, void** lpReturnValue)
#uselib "vertdll.dll"
#cfunc global CallEnclave "CallEnclave" intptr, intptr, int, intptr
; res = CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
; lpRoutine : INT_PTR -> "intptr"
; lpParameter : void* -> "intptr"
; fWaitForThread : BOOL -> "int"
; lpReturnValue : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
vertdll = windows.NewLazySystemDLL("vertdll.dll")
procCallEnclave = vertdll.NewProc("CallEnclave")
)
// lpRoutine (INT_PTR), lpParameter (void*), fWaitForThread (BOOL), lpReturnValue (void** out)
r1, _, err := procCallEnclave.Call(
uintptr(lpRoutine),
uintptr(lpParameter),
uintptr(fWaitForThread),
uintptr(lpReturnValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CallEnclave(
lpRoutine: NativeInt; // INT_PTR
lpParameter: Pointer; // void*
fWaitForThread: BOOL; // BOOL
lpReturnValue: Pointer // void** out
): BOOL; stdcall;
external 'vertdll.dll' name 'CallEnclave';result := DllCall("vertdll\CallEnclave"
, "Ptr", lpRoutine ; INT_PTR
, "Ptr", lpParameter ; void*
, "Int", fWaitForThread ; BOOL
, "Ptr", lpReturnValue ; void** out
, "Int") ; return: BOOL●CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue) = DLL("vertdll.dll", "bool CallEnclave(int, void*, bool, void*)")
# 呼び出し: CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
# lpRoutine : INT_PTR -> "int"
# lpParameter : void* -> "void*"
# fWaitForThread : BOOL -> "bool"
# lpReturnValue : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "vertdll" fn CallEnclave(
lpRoutine: isize, // INT_PTR
lpParameter: ?*anyopaque, // void*
fWaitForThread: i32, // BOOL
lpReturnValue: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc CallEnclave(
lpRoutine: int, # INT_PTR
lpParameter: pointer, # void*
fWaitForThread: int32, # BOOL
lpReturnValue: pointer # void** out
): int32 {.importc: "CallEnclave", stdcall, dynlib: "vertdll.dll".}pragma(lib, "vertdll");
extern(Windows)
int CallEnclave(
ptrdiff_t lpRoutine, // INT_PTR
void* lpParameter, // void*
int fWaitForThread, // BOOL
void** lpReturnValue // void** out
);ccall((:CallEnclave, "vertdll.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Int32, Ptr{Cvoid}),
lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
# lpRoutine : INT_PTR -> Int
# lpParameter : void* -> Ptr{Cvoid}
# fWaitForThread : BOOL -> Int32
# lpReturnValue : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CallEnclave(
intptr_t lpRoutine,
void* lpParameter,
int32_t fWaitForThread,
void** lpReturnValue);
]]
local vertdll = ffi.load("vertdll")
-- vertdll.CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
-- lpRoutine : INT_PTR
-- lpParameter : void*
-- fWaitForThread : BOOL
-- lpReturnValue : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('vertdll.dll');
const CallEnclave = lib.func('__stdcall', 'CallEnclave', 'int32_t', ['intptr_t', 'void *', 'int32_t', 'void *']);
// CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
// lpRoutine : INT_PTR -> 'intptr_t'
// lpParameter : void* -> 'void *'
// fWaitForThread : BOOL -> 'int32_t'
// lpReturnValue : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("vertdll.dll", {
CallEnclave: { parameters: ["isize", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue)
// lpRoutine : INT_PTR -> "isize"
// lpParameter : void* -> "pointer"
// fWaitForThread : BOOL -> "i32"
// lpReturnValue : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CallEnclave(
intptr_t lpRoutine,
void* lpParameter,
int32_t fWaitForThread,
void** lpReturnValue);
C, "vertdll.dll");
// $ffi->CallEnclave(lpRoutine, lpParameter, fWaitForThread, lpReturnValue);
// lpRoutine : INT_PTR
// lpParameter : void*
// fWaitForThread : BOOL
// lpReturnValue : void** out
// 構造体/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);
boolean CallEnclave(
long lpRoutine, // INT_PTR
Pointer lpParameter, // void*
boolean fWaitForThread, // BOOL
Pointer lpReturnValue // void** out
);
}@[Link("vertdll")]
lib Libvertdll
fun CallEnclave = CallEnclave(
lpRoutine : LibC::SSizeT, # INT_PTR
lpParameter : Void*, # void*
fWaitForThread : Int32, # BOOL
lpReturnValue : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CallEnclaveNative = Int32 Function(IntPtr, Pointer<Void>, Int32, Pointer<Void>);
typedef CallEnclaveDart = int Function(int, Pointer<Void>, int, Pointer<Void>);
final CallEnclave = DynamicLibrary.open('vertdll.dll')
.lookupFunction<CallEnclaveNative, CallEnclaveDart>('CallEnclave');
// lpRoutine : INT_PTR -> IntPtr
// lpParameter : void* -> Pointer<Void>
// fWaitForThread : BOOL -> Int32
// lpReturnValue : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CallEnclave(
lpRoutine: NativeInt; // INT_PTR
lpParameter: Pointer; // void*
fWaitForThread: BOOL; // BOOL
lpReturnValue: Pointer // void** out
): BOOL; stdcall;
external 'vertdll.dll' name 'CallEnclave';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CallEnclave"
c_CallEnclave :: CIntPtr -> Ptr () -> CInt -> Ptr () -> IO CInt
-- lpRoutine : INT_PTR -> CIntPtr
-- lpParameter : void* -> Ptr ()
-- fWaitForThread : BOOL -> CInt
-- lpReturnValue : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let callenclave =
foreign "CallEnclave"
(intptr_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> returning int32_t)
(* lpRoutine : INT_PTR -> intptr_t *)
(* lpParameter : void* -> (ptr void) *)
(* fWaitForThread : BOOL -> int32_t *)
(* lpReturnValue : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library vertdll (t "vertdll.dll"))
(cffi:use-foreign-library vertdll)
(cffi:defcfun ("CallEnclave" call-enclave :convention :stdcall) :int32
(lp-routine :int64) ; INT_PTR
(lp-parameter :pointer) ; void*
(f-wait-for-thread :int32) ; BOOL
(lp-return-value :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CallEnclave = Win32::API::More->new('vertdll',
'BOOL CallEnclave(LPARAM lpRoutine, LPVOID lpParameter, BOOL fWaitForThread, LPVOID lpReturnValue)');
# my $ret = $CallEnclave->Call($lpRoutine, $lpParameter, $fWaitForThread, $lpReturnValue);
# lpRoutine : INT_PTR -> LPARAM
# lpParameter : void* -> LPVOID
# fWaitForThread : BOOL -> BOOL
# lpReturnValue : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。