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

WHvGetInterruptTargetVpSet

関数
割り込み送信先となる仮想プロセッサの集合を取得する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvGetInterruptTargetVpSet(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG Destination,
    WHV_INTERRUPT_DESTINATION_MODE DestinationMode,
    DWORD* TargetVps,
    DWORD VpCount,
    DWORD* TargetVpCount
);

パラメーター

名前方向説明
PartitionWHV_PARTITION_HANDLEin対象パーティションのハンドルを指定する。
DestinationULONGLONGin割り込みの宛先指定(APIC ID等)を表す値を指定する。
DestinationModeWHV_INTERRUPT_DESTINATION_MODEin宛先の解釈モード(物理/論理)を示す列挙値を指定する。
TargetVpsDWORD*out宛先に該当する仮想プロセッサのインデックス配列を受け取る出力ポインタ。
VpCountDWORDinTargetVps配列が格納できる要素数を指定する。
TargetVpCountDWORD*out実際に該当した仮想プロセッサの数を受け取る出力ポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvGetInterruptTargetVpSet(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG Destination,
    WHV_INTERRUPT_DESTINATION_MODE DestinationMode,
    DWORD* TargetVps,
    DWORD VpCount,
    DWORD* TargetVpCount
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvGetInterruptTargetVpSet(
    IntPtr Partition,   // WHV_PARTITION_HANDLE
    ulong Destination,   // ULONGLONG
    int DestinationMode,   // WHV_INTERRUPT_DESTINATION_MODE
    out uint TargetVps,   // DWORD* out
    uint VpCount,   // DWORD
    out uint TargetVpCount   // DWORD* out
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvGetInterruptTargetVpSet(
    Partition As IntPtr,   ' WHV_PARTITION_HANDLE
    Destination As ULong,   ' ULONGLONG
    DestinationMode As Integer,   ' WHV_INTERRUPT_DESTINATION_MODE
    <Out> ByRef TargetVps As UInteger,   ' DWORD* out
    VpCount As UInteger,   ' DWORD
    <Out> ByRef TargetVpCount As UInteger   ' DWORD* out
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
' Destination : ULONGLONG
' DestinationMode : WHV_INTERRUPT_DESTINATION_MODE
' TargetVps : DWORD* out
' VpCount : DWORD
' TargetVpCount : DWORD* out
Declare PtrSafe Function WHvGetInterruptTargetVpSet Lib "winhvplatform" ( _
    ByVal Partition As LongPtr, _
    ByVal Destination As LongLong, _
    ByVal DestinationMode As Long, _
    ByRef TargetVps As Long, _
    ByVal VpCount As Long, _
    ByRef TargetVpCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvGetInterruptTargetVpSet = ctypes.windll.winhvplatform.WHvGetInterruptTargetVpSet
WHvGetInterruptTargetVpSet.restype = ctypes.c_int
WHvGetInterruptTargetVpSet.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    ctypes.c_ulonglong,  # Destination : ULONGLONG
    ctypes.c_int,  # DestinationMode : WHV_INTERRUPT_DESTINATION_MODE
    ctypes.POINTER(wintypes.DWORD),  # TargetVps : DWORD* out
    wintypes.DWORD,  # VpCount : DWORD
    ctypes.POINTER(wintypes.DWORD),  # TargetVpCount : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvGetInterruptTargetVpSet = Fiddle::Function.new(
  lib['WHvGetInterruptTargetVpSet'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    -Fiddle::TYPE_LONG_LONG,  # Destination : ULONGLONG
    Fiddle::TYPE_INT,  # DestinationMode : WHV_INTERRUPT_DESTINATION_MODE
    Fiddle::TYPE_VOIDP,  # TargetVps : DWORD* out
    -Fiddle::TYPE_INT,  # VpCount : DWORD
    Fiddle::TYPE_VOIDP,  # TargetVpCount : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvGetInterruptTargetVpSet(
        Partition: isize,  // WHV_PARTITION_HANDLE
        Destination: u64,  // ULONGLONG
        DestinationMode: i32,  // WHV_INTERRUPT_DESTINATION_MODE
        TargetVps: *mut u32,  // DWORD* out
        VpCount: u32,  // DWORD
        TargetVpCount: *mut u32  // DWORD* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvGetInterruptTargetVpSet(IntPtr Partition, ulong Destination, int DestinationMode, out uint TargetVps, uint VpCount, out uint TargetVpCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvGetInterruptTargetVpSet' -Namespace Win32 -PassThru
# $api::WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
#uselib "WinHvPlatform.dll"
#func global WHvGetInterruptTargetVpSet "WHvGetInterruptTargetVpSet" sptr, sptr, sptr, sptr, sptr, sptr
; WHvGetInterruptTargetVpSet Partition, Destination, DestinationMode, varptr(TargetVps), VpCount, varptr(TargetVpCount)   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; Destination : ULONGLONG -> "sptr"
; DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> "sptr"
; TargetVps : DWORD* out -> "sptr"
; VpCount : DWORD -> "sptr"
; TargetVpCount : DWORD* out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinHvPlatform.dll"
#cfunc global WHvGetInterruptTargetVpSet "WHvGetInterruptTargetVpSet" sptr, int64, int, var, int, var
; res = WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; Destination : ULONGLONG -> "int64"
; DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> "int"
; TargetVps : DWORD* out -> "var"
; VpCount : DWORD -> "int"
; TargetVpCount : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; HRESULT WHvGetInterruptTargetVpSet(WHV_PARTITION_HANDLE Partition, ULONGLONG Destination, WHV_INTERRUPT_DESTINATION_MODE DestinationMode, DWORD* TargetVps, DWORD VpCount, DWORD* TargetVpCount)
#uselib "WinHvPlatform.dll"
#cfunc global WHvGetInterruptTargetVpSet "WHvGetInterruptTargetVpSet" intptr, int64, int, var, int, var
; res = WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; Destination : ULONGLONG -> "int64"
; DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> "int"
; TargetVps : DWORD* out -> "var"
; VpCount : DWORD -> "int"
; TargetVpCount : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvGetInterruptTargetVpSet = winhvplatform.NewProc("WHvGetInterruptTargetVpSet")
)

// Partition (WHV_PARTITION_HANDLE), Destination (ULONGLONG), DestinationMode (WHV_INTERRUPT_DESTINATION_MODE), TargetVps (DWORD* out), VpCount (DWORD), TargetVpCount (DWORD* out)
r1, _, err := procWHvGetInterruptTargetVpSet.Call(
	uintptr(Partition),
	uintptr(Destination),
	uintptr(DestinationMode),
	uintptr(TargetVps),
	uintptr(VpCount),
	uintptr(TargetVpCount),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WHvGetInterruptTargetVpSet(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  Destination: UInt64;   // ULONGLONG
  DestinationMode: Integer;   // WHV_INTERRUPT_DESTINATION_MODE
  TargetVps: Pointer;   // DWORD* out
  VpCount: DWORD;   // DWORD
  TargetVpCount: Pointer   // DWORD* out
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvGetInterruptTargetVpSet';
result := DllCall("WinHvPlatform\WHvGetInterruptTargetVpSet"
    , "Ptr", Partition   ; WHV_PARTITION_HANDLE
    , "Int64", Destination   ; ULONGLONG
    , "Int", DestinationMode   ; WHV_INTERRUPT_DESTINATION_MODE
    , "Ptr", TargetVps   ; DWORD* out
    , "UInt", VpCount   ; DWORD
    , "Ptr", TargetVpCount   ; DWORD* out
    , "Int")   ; return: HRESULT
●WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount) = DLL("WinHvPlatform.dll", "int WHvGetInterruptTargetVpSet(int, qword, int, void*, dword, void*)")
# 呼び出し: WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
# Partition : WHV_PARTITION_HANDLE -> "int"
# Destination : ULONGLONG -> "qword"
# DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> "int"
# TargetVps : DWORD* out -> "void*"
# VpCount : DWORD -> "dword"
# TargetVpCount : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winhvplatform" fn WHvGetInterruptTargetVpSet(
    Partition: isize, // WHV_PARTITION_HANDLE
    Destination: u64, // ULONGLONG
    DestinationMode: i32, // WHV_INTERRUPT_DESTINATION_MODE
    TargetVps: [*c]u32, // DWORD* out
    VpCount: u32, // DWORD
    TargetVpCount: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
proc WHvGetInterruptTargetVpSet(
    Partition: int,  # WHV_PARTITION_HANDLE
    Destination: uint64,  # ULONGLONG
    DestinationMode: int32,  # WHV_INTERRUPT_DESTINATION_MODE
    TargetVps: ptr uint32,  # DWORD* out
    VpCount: uint32,  # DWORD
    TargetVpCount: ptr uint32  # DWORD* out
): int32 {.importc: "WHvGetInterruptTargetVpSet", stdcall, dynlib: "WinHvPlatform.dll".}
pragma(lib, "winhvplatform");
extern(Windows)
int WHvGetInterruptTargetVpSet(
    ptrdiff_t Partition,   // WHV_PARTITION_HANDLE
    ulong Destination,   // ULONGLONG
    int DestinationMode,   // WHV_INTERRUPT_DESTINATION_MODE
    uint* TargetVps,   // DWORD* out
    uint VpCount,   // DWORD
    uint* TargetVpCount   // DWORD* out
);
ccall((:WHvGetInterruptTargetVpSet, "WinHvPlatform.dll"), stdcall, Int32,
      (Int, UInt64, Int32, Ptr{UInt32}, UInt32, Ptr{UInt32}),
      Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
# Partition : WHV_PARTITION_HANDLE -> Int
# Destination : ULONGLONG -> UInt64
# DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> Int32
# TargetVps : DWORD* out -> Ptr{UInt32}
# VpCount : DWORD -> UInt32
# TargetVpCount : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvGetInterruptTargetVpSet(
    intptr_t Partition,
    uint64_t Destination,
    int32_t DestinationMode,
    uint32_t* TargetVps,
    uint32_t VpCount,
    uint32_t* TargetVpCount);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
-- Partition : WHV_PARTITION_HANDLE
-- Destination : ULONGLONG
-- DestinationMode : WHV_INTERRUPT_DESTINATION_MODE
-- TargetVps : DWORD* out
-- VpCount : DWORD
-- TargetVpCount : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvGetInterruptTargetVpSet = lib.func('__stdcall', 'WHvGetInterruptTargetVpSet', 'int32_t', ['intptr_t', 'uint64_t', 'int32_t', 'uint32_t *', 'uint32_t', 'uint32_t *']);
// WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// Destination : ULONGLONG -> 'uint64_t'
// DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> 'int32_t'
// TargetVps : DWORD* out -> 'uint32_t *'
// VpCount : DWORD -> 'uint32_t'
// TargetVpCount : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvPlatform.dll", {
  WHvGetInterruptTargetVpSet: { parameters: ["isize", "u64", "i32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// Destination : ULONGLONG -> "u64"
// DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> "i32"
// TargetVps : DWORD* out -> "pointer"
// VpCount : DWORD -> "u32"
// TargetVpCount : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvGetInterruptTargetVpSet(
    intptr_t Partition,
    uint64_t Destination,
    int32_t DestinationMode,
    uint32_t* TargetVps,
    uint32_t VpCount,
    uint32_t* TargetVpCount);
C, "WinHvPlatform.dll");
// $ffi->WHvGetInterruptTargetVpSet(Partition, Destination, DestinationMode, TargetVps, VpCount, TargetVpCount);
// Partition : WHV_PARTITION_HANDLE
// Destination : ULONGLONG
// DestinationMode : WHV_INTERRUPT_DESTINATION_MODE
// TargetVps : DWORD* out
// VpCount : DWORD
// TargetVpCount : DWORD* 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 Winhvplatform extends StdCallLibrary {
    Winhvplatform INSTANCE = Native.load("winhvplatform", Winhvplatform.class);
    int WHvGetInterruptTargetVpSet(
        long Partition,   // WHV_PARTITION_HANDLE
        long Destination,   // ULONGLONG
        int DestinationMode,   // WHV_INTERRUPT_DESTINATION_MODE
        IntByReference TargetVps,   // DWORD* out
        int VpCount,   // DWORD
        IntByReference TargetVpCount   // DWORD* out
    );
}
@[Link("winhvplatform")]
lib LibWinHvPlatform
  fun WHvGetInterruptTargetVpSet = WHvGetInterruptTargetVpSet(
    Partition : LibC::SSizeT,   # WHV_PARTITION_HANDLE
    Destination : UInt64,   # ULONGLONG
    DestinationMode : Int32,   # WHV_INTERRUPT_DESTINATION_MODE
    TargetVps : UInt32*,   # DWORD* out
    VpCount : UInt32,   # DWORD
    TargetVpCount : UInt32*   # DWORD* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WHvGetInterruptTargetVpSetNative = Int32 Function(IntPtr, Uint64, Int32, Pointer<Uint32>, Uint32, Pointer<Uint32>);
typedef WHvGetInterruptTargetVpSetDart = int Function(int, int, int, Pointer<Uint32>, int, Pointer<Uint32>);
final WHvGetInterruptTargetVpSet = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvGetInterruptTargetVpSetNative, WHvGetInterruptTargetVpSetDart>('WHvGetInterruptTargetVpSet');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// Destination : ULONGLONG -> Uint64
// DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> Int32
// TargetVps : DWORD* out -> Pointer<Uint32>
// VpCount : DWORD -> Uint32
// TargetVpCount : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WHvGetInterruptTargetVpSet(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  Destination: UInt64;   // ULONGLONG
  DestinationMode: Integer;   // WHV_INTERRUPT_DESTINATION_MODE
  TargetVps: Pointer;   // DWORD* out
  VpCount: DWORD;   // DWORD
  TargetVpCount: Pointer   // DWORD* out
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvGetInterruptTargetVpSet';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvGetInterruptTargetVpSet"
  c_WHvGetInterruptTargetVpSet :: CIntPtr -> Word64 -> Int32 -> Ptr Word32 -> Word32 -> Ptr Word32 -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- Destination : ULONGLONG -> Word64
-- DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> Int32
-- TargetVps : DWORD* out -> Ptr Word32
-- VpCount : DWORD -> Word32
-- TargetVpCount : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvgetinterrupttargetvpset =
  foreign "WHvGetInterruptTargetVpSet"
    (intptr_t @-> uint64_t @-> int32_t @-> (ptr uint32_t) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* Destination : ULONGLONG -> uint64_t *)
(* DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> int32_t *)
(* TargetVps : DWORD* out -> (ptr uint32_t) *)
(* VpCount : DWORD -> uint32_t *)
(* TargetVpCount : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)

(cffi:defcfun ("WHvGetInterruptTargetVpSet" whv-get-interrupt-target-vp-set :convention :stdcall) :int32
  (partition :int64)   ; WHV_PARTITION_HANDLE
  (destination :uint64)   ; ULONGLONG
  (destination-mode :int32)   ; WHV_INTERRUPT_DESTINATION_MODE
  (target-vps :pointer)   ; DWORD* out
  (vp-count :uint32)   ; DWORD
  (target-vp-count :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvGetInterruptTargetVpSet = Win32::API::More->new('WinHvPlatform',
    'int WHvGetInterruptTargetVpSet(LPARAM Partition, UINT64 Destination, int DestinationMode, LPVOID TargetVps, DWORD VpCount, LPVOID TargetVpCount)');
# my $ret = $WHvGetInterruptTargetVpSet->Call($Partition, $Destination, $DestinationMode, $TargetVps, $VpCount, $TargetVpCount);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# Destination : ULONGLONG -> UINT64
# DestinationMode : WHV_INTERRUPT_DESTINATION_MODE -> int
# TargetVps : DWORD* out -> LPVOID
# VpCount : DWORD -> DWORD
# TargetVpCount : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型