ホーム › System.HostComputeSystem › HcsCrashComputeSystem
HcsCrashComputeSystem
関数コンピュートシステムを意図的にクラッシュさせる。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsCrashComputeSystem(
HCS_SYSTEM computeSystem,
HCS_OPERATION operation,
LPCWSTR options // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| computeSystem | HCS_SYSTEM | in | クラッシュ(ダンプ生成等)させる対象の計算システムハンドル。 |
| operation | HCS_OPERATION | in | 処理結果を受け取る非同期HCS操作のハンドル。 |
| options | LPCWSTR | inoptional | クラッシュ動作の追加オプションを記述したJSON文字列。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsCrashComputeSystem(
HCS_SYSTEM computeSystem,
HCS_OPERATION operation,
LPCWSTR options // optional
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsCrashComputeSystem(
IntPtr computeSystem, // HCS_SYSTEM
IntPtr operation, // HCS_OPERATION
[MarshalAs(UnmanagedType.LPWStr)] string options // LPCWSTR optional
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsCrashComputeSystem(
computeSystem As IntPtr, ' HCS_SYSTEM
operation As IntPtr, ' HCS_OPERATION
<MarshalAs(UnmanagedType.LPWStr)> options As String ' LPCWSTR optional
) As Integer
End Function' computeSystem : HCS_SYSTEM
' operation : HCS_OPERATION
' options : LPCWSTR optional
Declare PtrSafe Function HcsCrashComputeSystem Lib "computecore" ( _
ByVal computeSystem As LongPtr, _
ByVal operation As LongPtr, _
ByVal options As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsCrashComputeSystem = ctypes.windll.computecore.HcsCrashComputeSystem
HcsCrashComputeSystem.restype = ctypes.c_int
HcsCrashComputeSystem.argtypes = [
wintypes.HANDLE, # computeSystem : HCS_SYSTEM
wintypes.HANDLE, # operation : HCS_OPERATION
wintypes.LPCWSTR, # options : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsCrashComputeSystem = Fiddle::Function.new(
lib['HcsCrashComputeSystem'],
[
Fiddle::TYPE_VOIDP, # computeSystem : HCS_SYSTEM
Fiddle::TYPE_VOIDP, # operation : HCS_OPERATION
Fiddle::TYPE_VOIDP, # options : LPCWSTR optional
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsCrashComputeSystem(
computeSystem: *mut core::ffi::c_void, // HCS_SYSTEM
operation: *mut core::ffi::c_void, // HCS_OPERATION
options: *const u16 // LPCWSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsCrashComputeSystem(IntPtr computeSystem, IntPtr operation, [MarshalAs(UnmanagedType.LPWStr)] string options);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsCrashComputeSystem' -Namespace Win32 -PassThru
# $api::HcsCrashComputeSystem(computeSystem, operation, options)#uselib "computecore.dll"
#func global HcsCrashComputeSystem "HcsCrashComputeSystem" sptr, sptr, sptr
; HcsCrashComputeSystem computeSystem, operation, options ; 戻り値は stat
; computeSystem : HCS_SYSTEM -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; options : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "computecore.dll"
#cfunc global HcsCrashComputeSystem "HcsCrashComputeSystem" sptr, sptr, wstr
; res = HcsCrashComputeSystem(computeSystem, operation, options)
; computeSystem : HCS_SYSTEM -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; options : LPCWSTR optional -> "wstr"; HRESULT HcsCrashComputeSystem(HCS_SYSTEM computeSystem, HCS_OPERATION operation, LPCWSTR options)
#uselib "computecore.dll"
#cfunc global HcsCrashComputeSystem "HcsCrashComputeSystem" intptr, intptr, wstr
; res = HcsCrashComputeSystem(computeSystem, operation, options)
; computeSystem : HCS_SYSTEM -> "intptr"
; operation : HCS_OPERATION -> "intptr"
; options : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsCrashComputeSystem = computecore.NewProc("HcsCrashComputeSystem")
)
// computeSystem (HCS_SYSTEM), operation (HCS_OPERATION), options (LPCWSTR optional)
r1, _, err := procHcsCrashComputeSystem.Call(
uintptr(computeSystem),
uintptr(operation),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(options))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsCrashComputeSystem(
computeSystem: THandle; // HCS_SYSTEM
operation: THandle; // HCS_OPERATION
options: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'computecore.dll' name 'HcsCrashComputeSystem';result := DllCall("computecore\HcsCrashComputeSystem"
, "Ptr", computeSystem ; HCS_SYSTEM
, "Ptr", operation ; HCS_OPERATION
, "WStr", options ; LPCWSTR optional
, "Int") ; return: HRESULT●HcsCrashComputeSystem(computeSystem, operation, options) = DLL("computecore.dll", "int HcsCrashComputeSystem(void*, void*, char*)")
# 呼び出し: HcsCrashComputeSystem(computeSystem, operation, options)
# computeSystem : HCS_SYSTEM -> "void*"
# operation : HCS_OPERATION -> "void*"
# options : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computecore" fn HcsCrashComputeSystem(
computeSystem: ?*anyopaque, // HCS_SYSTEM
operation: ?*anyopaque, // HCS_OPERATION
options: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;proc HcsCrashComputeSystem(
computeSystem: pointer, # HCS_SYSTEM
operation: pointer, # HCS_OPERATION
options: WideCString # LPCWSTR optional
): int32 {.importc: "HcsCrashComputeSystem", stdcall, dynlib: "computecore.dll".}pragma(lib, "computecore");
extern(Windows)
int HcsCrashComputeSystem(
void* computeSystem, // HCS_SYSTEM
void* operation, // HCS_OPERATION
const(wchar)* options // LPCWSTR optional
);ccall((:HcsCrashComputeSystem, "computecore.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Cwstring),
computeSystem, operation, options)
# computeSystem : HCS_SYSTEM -> Ptr{Cvoid}
# operation : HCS_OPERATION -> Ptr{Cvoid}
# options : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsCrashComputeSystem(
void* computeSystem,
void* operation,
const uint16_t* options);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsCrashComputeSystem(computeSystem, operation, options)
-- computeSystem : HCS_SYSTEM
-- operation : HCS_OPERATION
-- options : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsCrashComputeSystem = lib.func('__stdcall', 'HcsCrashComputeSystem', 'int32_t', ['void *', 'void *', 'str16']);
// HcsCrashComputeSystem(computeSystem, operation, options)
// computeSystem : HCS_SYSTEM -> 'void *'
// operation : HCS_OPERATION -> 'void *'
// options : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computecore.dll", {
HcsCrashComputeSystem: { parameters: ["pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.HcsCrashComputeSystem(computeSystem, operation, options)
// computeSystem : HCS_SYSTEM -> "pointer"
// operation : HCS_OPERATION -> "pointer"
// options : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsCrashComputeSystem(
void* computeSystem,
void* operation,
const uint16_t* options);
C, "computecore.dll");
// $ffi->HcsCrashComputeSystem(computeSystem, operation, options);
// computeSystem : HCS_SYSTEM
// operation : HCS_OPERATION
// options : LPCWSTR optional
// 構造体/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 Computecore extends StdCallLibrary {
Computecore INSTANCE = Native.load("computecore", Computecore.class);
int HcsCrashComputeSystem(
Pointer computeSystem, // HCS_SYSTEM
Pointer operation, // HCS_OPERATION
WString options // LPCWSTR optional
);
}@[Link("computecore")]
lib Libcomputecore
fun HcsCrashComputeSystem = HcsCrashComputeSystem(
computeSystem : Void*, # HCS_SYSTEM
operation : Void*, # HCS_OPERATION
options : UInt16* # LPCWSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HcsCrashComputeSystemNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
typedef HcsCrashComputeSystemDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
final HcsCrashComputeSystem = DynamicLibrary.open('computecore.dll')
.lookupFunction<HcsCrashComputeSystemNative, HcsCrashComputeSystemDart>('HcsCrashComputeSystem');
// computeSystem : HCS_SYSTEM -> Pointer<Void>
// operation : HCS_OPERATION -> Pointer<Void>
// options : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsCrashComputeSystem(
computeSystem: THandle; // HCS_SYSTEM
operation: THandle; // HCS_OPERATION
options: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'computecore.dll' name 'HcsCrashComputeSystem';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsCrashComputeSystem"
c_HcsCrashComputeSystem :: Ptr () -> Ptr () -> CWString -> IO Int32
-- computeSystem : HCS_SYSTEM -> Ptr ()
-- operation : HCS_OPERATION -> Ptr ()
-- options : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcscrashcomputesystem =
foreign "HcsCrashComputeSystem"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* computeSystem : HCS_SYSTEM -> (ptr void) *)
(* operation : HCS_OPERATION -> (ptr void) *)
(* options : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)
(cffi:defcfun ("HcsCrashComputeSystem" hcs-crash-compute-system :convention :stdcall) :int32
(compute-system :pointer) ; HCS_SYSTEM
(operation :pointer) ; HCS_OPERATION
(options (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsCrashComputeSystem = Win32::API::More->new('computecore',
'int HcsCrashComputeSystem(HANDLE computeSystem, HANDLE operation, LPCWSTR options)');
# my $ret = $HcsCrashComputeSystem->Call($computeSystem, $operation, $options);
# computeSystem : HCS_SYSTEM -> HANDLE
# operation : HCS_OPERATION -> HANDLE
# options : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。