ホーム › System.Hypervisor › WHvRequestInterrupt
WHvRequestInterrupt
関数パーティションに割り込みを要求する。
シグネチャ
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvRequestInterrupt(
WHV_PARTITION_HANDLE Partition,
const WHV_INTERRUPT_CONTROL* Interrupt,
DWORD InterruptControlSize
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Partition | WHV_PARTITION_HANDLE | in | 割り込みを要求する対象パーティションハンドル。 |
| Interrupt | WHV_INTERRUPT_CONTROL* | in | 送出する割り込みの内容を格納した制御構造体へのポインタ。 |
| InterruptControlSize | DWORD | in | Interrupt構造体のサイズをバイト単位で指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvRequestInterrupt(
WHV_PARTITION_HANDLE Partition,
const WHV_INTERRUPT_CONTROL* Interrupt,
DWORD InterruptControlSize
);[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvRequestInterrupt(
IntPtr Partition, // WHV_PARTITION_HANDLE
IntPtr Interrupt, // WHV_INTERRUPT_CONTROL*
uint InterruptControlSize // DWORD
);<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvRequestInterrupt(
Partition As IntPtr, ' WHV_PARTITION_HANDLE
Interrupt As IntPtr, ' WHV_INTERRUPT_CONTROL*
InterruptControlSize As UInteger ' DWORD
) As Integer
End Function' Partition : WHV_PARTITION_HANDLE
' Interrupt : WHV_INTERRUPT_CONTROL*
' InterruptControlSize : DWORD
Declare PtrSafe Function WHvRequestInterrupt Lib "winhvplatform" ( _
ByVal Partition As LongPtr, _
ByVal Interrupt As LongPtr, _
ByVal InterruptControlSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WHvRequestInterrupt = ctypes.windll.winhvplatform.WHvRequestInterrupt
WHvRequestInterrupt.restype = ctypes.c_int
WHvRequestInterrupt.argtypes = [
ctypes.c_ssize_t, # Partition : WHV_PARTITION_HANDLE
ctypes.c_void_p, # Interrupt : WHV_INTERRUPT_CONTROL*
wintypes.DWORD, # InterruptControlSize : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvRequestInterrupt = Fiddle::Function.new(
lib['WHvRequestInterrupt'],
[
Fiddle::TYPE_INTPTR_T, # Partition : WHV_PARTITION_HANDLE
Fiddle::TYPE_VOIDP, # Interrupt : WHV_INTERRUPT_CONTROL*
-Fiddle::TYPE_INT, # InterruptControlSize : DWORD
],
Fiddle::TYPE_INT)#[link(name = "winhvplatform")]
extern "system" {
fn WHvRequestInterrupt(
Partition: isize, // WHV_PARTITION_HANDLE
Interrupt: *const WHV_INTERRUPT_CONTROL, // WHV_INTERRUPT_CONTROL*
InterruptControlSize: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvRequestInterrupt(IntPtr Partition, IntPtr Interrupt, uint InterruptControlSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvRequestInterrupt' -Namespace Win32 -PassThru
# $api::WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize)#uselib "WinHvPlatform.dll"
#func global WHvRequestInterrupt "WHvRequestInterrupt" sptr, sptr, sptr
; WHvRequestInterrupt Partition, varptr(Interrupt), InterruptControlSize ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; Interrupt : WHV_INTERRUPT_CONTROL* -> "sptr"
; InterruptControlSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WinHvPlatform.dll" #cfunc global WHvRequestInterrupt "WHvRequestInterrupt" sptr, var, int ; res = WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; Interrupt : WHV_INTERRUPT_CONTROL* -> "var" ; InterruptControlSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WinHvPlatform.dll" #cfunc global WHvRequestInterrupt "WHvRequestInterrupt" sptr, sptr, int ; res = WHvRequestInterrupt(Partition, varptr(Interrupt), InterruptControlSize) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; Interrupt : WHV_INTERRUPT_CONTROL* -> "sptr" ; InterruptControlSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WHvRequestInterrupt(WHV_PARTITION_HANDLE Partition, WHV_INTERRUPT_CONTROL* Interrupt, DWORD InterruptControlSize) #uselib "WinHvPlatform.dll" #cfunc global WHvRequestInterrupt "WHvRequestInterrupt" intptr, var, int ; res = WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; Interrupt : WHV_INTERRUPT_CONTROL* -> "var" ; InterruptControlSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WHvRequestInterrupt(WHV_PARTITION_HANDLE Partition, WHV_INTERRUPT_CONTROL* Interrupt, DWORD InterruptControlSize) #uselib "WinHvPlatform.dll" #cfunc global WHvRequestInterrupt "WHvRequestInterrupt" intptr, intptr, int ; res = WHvRequestInterrupt(Partition, varptr(Interrupt), InterruptControlSize) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; Interrupt : WHV_INTERRUPT_CONTROL* -> "intptr" ; InterruptControlSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
procWHvRequestInterrupt = winhvplatform.NewProc("WHvRequestInterrupt")
)
// Partition (WHV_PARTITION_HANDLE), Interrupt (WHV_INTERRUPT_CONTROL*), InterruptControlSize (DWORD)
r1, _, err := procWHvRequestInterrupt.Call(
uintptr(Partition),
uintptr(Interrupt),
uintptr(InterruptControlSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WHvRequestInterrupt(
Partition: NativeInt; // WHV_PARTITION_HANDLE
Interrupt: Pointer; // WHV_INTERRUPT_CONTROL*
InterruptControlSize: DWORD // DWORD
): Integer; stdcall;
external 'WinHvPlatform.dll' name 'WHvRequestInterrupt';result := DllCall("WinHvPlatform\WHvRequestInterrupt"
, "Ptr", Partition ; WHV_PARTITION_HANDLE
, "Ptr", Interrupt ; WHV_INTERRUPT_CONTROL*
, "UInt", InterruptControlSize ; DWORD
, "Int") ; return: HRESULT●WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize) = DLL("WinHvPlatform.dll", "int WHvRequestInterrupt(int, void*, dword)")
# 呼び出し: WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize)
# Partition : WHV_PARTITION_HANDLE -> "int"
# Interrupt : WHV_INTERRUPT_CONTROL* -> "void*"
# InterruptControlSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winhvplatform" fn WHvRequestInterrupt(
Partition: isize, // WHV_PARTITION_HANDLE
Interrupt: [*c]WHV_INTERRUPT_CONTROL, // WHV_INTERRUPT_CONTROL*
InterruptControlSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc WHvRequestInterrupt(
Partition: int, # WHV_PARTITION_HANDLE
Interrupt: ptr WHV_INTERRUPT_CONTROL, # WHV_INTERRUPT_CONTROL*
InterruptControlSize: uint32 # DWORD
): int32 {.importc: "WHvRequestInterrupt", stdcall, dynlib: "WinHvPlatform.dll".}pragma(lib, "winhvplatform");
extern(Windows)
int WHvRequestInterrupt(
ptrdiff_t Partition, // WHV_PARTITION_HANDLE
WHV_INTERRUPT_CONTROL* Interrupt, // WHV_INTERRUPT_CONTROL*
uint InterruptControlSize // DWORD
);ccall((:WHvRequestInterrupt, "WinHvPlatform.dll"), stdcall, Int32,
(Int, Ptr{WHV_INTERRUPT_CONTROL}, UInt32),
Partition, Interrupt, InterruptControlSize)
# Partition : WHV_PARTITION_HANDLE -> Int
# Interrupt : WHV_INTERRUPT_CONTROL* -> Ptr{WHV_INTERRUPT_CONTROL}
# InterruptControlSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WHvRequestInterrupt(
intptr_t Partition,
void* Interrupt,
uint32_t InterruptControlSize);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize)
-- Partition : WHV_PARTITION_HANDLE
-- Interrupt : WHV_INTERRUPT_CONTROL*
-- InterruptControlSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvRequestInterrupt = lib.func('__stdcall', 'WHvRequestInterrupt', 'int32_t', ['intptr_t', 'void *', 'uint32_t']);
// WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// Interrupt : WHV_INTERRUPT_CONTROL* -> 'void *'
// InterruptControlSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WinHvPlatform.dll", {
WHvRequestInterrupt: { parameters: ["isize", "pointer", "u32"], result: "i32" },
});
// lib.symbols.WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// Interrupt : WHV_INTERRUPT_CONTROL* -> "pointer"
// InterruptControlSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WHvRequestInterrupt(
intptr_t Partition,
void* Interrupt,
uint32_t InterruptControlSize);
C, "WinHvPlatform.dll");
// $ffi->WHvRequestInterrupt(Partition, Interrupt, InterruptControlSize);
// Partition : WHV_PARTITION_HANDLE
// Interrupt : WHV_INTERRUPT_CONTROL*
// InterruptControlSize : DWORD
// 構造体/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 Winhvplatform extends StdCallLibrary {
Winhvplatform INSTANCE = Native.load("winhvplatform", Winhvplatform.class);
int WHvRequestInterrupt(
long Partition, // WHV_PARTITION_HANDLE
Pointer Interrupt, // WHV_INTERRUPT_CONTROL*
int InterruptControlSize // DWORD
);
}@[Link("winhvplatform")]
lib LibWinHvPlatform
fun WHvRequestInterrupt = WHvRequestInterrupt(
Partition : LibC::SSizeT, # WHV_PARTITION_HANDLE
Interrupt : WHV_INTERRUPT_CONTROL*, # WHV_INTERRUPT_CONTROL*
InterruptControlSize : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WHvRequestInterruptNative = Int32 Function(IntPtr, Pointer<Void>, Uint32);
typedef WHvRequestInterruptDart = int Function(int, Pointer<Void>, int);
final WHvRequestInterrupt = DynamicLibrary.open('WinHvPlatform.dll')
.lookupFunction<WHvRequestInterruptNative, WHvRequestInterruptDart>('WHvRequestInterrupt');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// Interrupt : WHV_INTERRUPT_CONTROL* -> Pointer<Void>
// InterruptControlSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WHvRequestInterrupt(
Partition: NativeInt; // WHV_PARTITION_HANDLE
Interrupt: Pointer; // WHV_INTERRUPT_CONTROL*
InterruptControlSize: DWORD // DWORD
): Integer; stdcall;
external 'WinHvPlatform.dll' name 'WHvRequestInterrupt';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WHvRequestInterrupt"
c_WHvRequestInterrupt :: CIntPtr -> Ptr () -> Word32 -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- Interrupt : WHV_INTERRUPT_CONTROL* -> Ptr ()
-- InterruptControlSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let whvrequestinterrupt =
foreign "WHvRequestInterrupt"
(intptr_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* Interrupt : WHV_INTERRUPT_CONTROL* -> (ptr void) *)
(* InterruptControlSize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)
(cffi:defcfun ("WHvRequestInterrupt" whv-request-interrupt :convention :stdcall) :int32
(partition :int64) ; WHV_PARTITION_HANDLE
(interrupt :pointer) ; WHV_INTERRUPT_CONTROL*
(interrupt-control-size :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WHvRequestInterrupt = Win32::API::More->new('WinHvPlatform',
'int WHvRequestInterrupt(LPARAM Partition, LPVOID Interrupt, DWORD InterruptControlSize)');
# my $ret = $WHvRequestInterrupt->Call($Partition, $Interrupt, $InterruptControlSize);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# Interrupt : WHV_INTERRUPT_CONTROL* -> LPVOID
# InterruptControlSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。