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