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

WHvGetVpciDeviceNotification

関数
仮想PCIデバイスの通知を取得する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvGetVpciDeviceNotification(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG LogicalDeviceId,
    WHV_VPCI_DEVICE_NOTIFICATION* Notification,
    DWORD NotificationSizeInBytes
);

パラメーター

名前方向説明
PartitionWHV_PARTITION_HANDLEin対象パーティションのハンドルを指定する。
LogicalDeviceIdULONGLONGin対象とする仮想PCIデバイスの論理デバイスIDを指定する。
NotificationWHV_VPCI_DEVICE_NOTIFICATION*out発生したデバイス通知の内容を受け取る構造体へのポインタ。
NotificationSizeInBytesDWORDinNotification構造体のバイト単位のサイズを指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

WHvGetVpciDeviceNotification = ctypes.windll.winhvplatform.WHvGetVpciDeviceNotification
WHvGetVpciDeviceNotification.restype = ctypes.c_int
WHvGetVpciDeviceNotification.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    ctypes.c_ulonglong,  # LogicalDeviceId : ULONGLONG
    ctypes.c_void_p,  # Notification : WHV_VPCI_DEVICE_NOTIFICATION* out
    wintypes.DWORD,  # NotificationSizeInBytes : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvGetVpciDeviceNotification = winhvplatform.NewProc("WHvGetVpciDeviceNotification")
)

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

extern "winhvplatform" fn WHvGetVpciDeviceNotification(
    Partition: isize, // WHV_PARTITION_HANDLE
    LogicalDeviceId: u64, // ULONGLONG
    Notification: [*c]WHV_VPCI_DEVICE_NOTIFICATION, // WHV_VPCI_DEVICE_NOTIFICATION* out
    NotificationSizeInBytes: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc WHvGetVpciDeviceNotification(
    Partition: int,  # WHV_PARTITION_HANDLE
    LogicalDeviceId: uint64,  # ULONGLONG
    Notification: ptr WHV_VPCI_DEVICE_NOTIFICATION,  # WHV_VPCI_DEVICE_NOTIFICATION* out
    NotificationSizeInBytes: uint32  # DWORD
): int32 {.importc: "WHvGetVpciDeviceNotification", stdcall, dynlib: "WinHvPlatform.dll".}
pragma(lib, "winhvplatform");
extern(Windows)
int WHvGetVpciDeviceNotification(
    ptrdiff_t Partition,   // WHV_PARTITION_HANDLE
    ulong LogicalDeviceId,   // ULONGLONG
    WHV_VPCI_DEVICE_NOTIFICATION* Notification,   // WHV_VPCI_DEVICE_NOTIFICATION* out
    uint NotificationSizeInBytes   // DWORD
);
ccall((:WHvGetVpciDeviceNotification, "WinHvPlatform.dll"), stdcall, Int32,
      (Int, UInt64, Ptr{WHV_VPCI_DEVICE_NOTIFICATION}, UInt32),
      Partition, LogicalDeviceId, Notification, NotificationSizeInBytes)
# Partition : WHV_PARTITION_HANDLE -> Int
# LogicalDeviceId : ULONGLONG -> UInt64
# Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> Ptr{WHV_VPCI_DEVICE_NOTIFICATION}
# NotificationSizeInBytes : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvGetVpciDeviceNotification(
    intptr_t Partition,
    uint64_t LogicalDeviceId,
    void* Notification,
    uint32_t NotificationSizeInBytes);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvGetVpciDeviceNotification(Partition, LogicalDeviceId, Notification, NotificationSizeInBytes)
-- Partition : WHV_PARTITION_HANDLE
-- LogicalDeviceId : ULONGLONG
-- Notification : WHV_VPCI_DEVICE_NOTIFICATION* out
-- NotificationSizeInBytes : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvGetVpciDeviceNotification = lib.func('__stdcall', 'WHvGetVpciDeviceNotification', 'int32_t', ['intptr_t', 'uint64_t', 'void *', 'uint32_t']);
// WHvGetVpciDeviceNotification(Partition, LogicalDeviceId, Notification, NotificationSizeInBytes)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// LogicalDeviceId : ULONGLONG -> 'uint64_t'
// Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> 'void *'
// NotificationSizeInBytes : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvPlatform.dll", {
  WHvGetVpciDeviceNotification: { parameters: ["isize", "u64", "pointer", "u32"], result: "i32" },
});
// lib.symbols.WHvGetVpciDeviceNotification(Partition, LogicalDeviceId, Notification, NotificationSizeInBytes)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// LogicalDeviceId : ULONGLONG -> "u64"
// Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> "pointer"
// NotificationSizeInBytes : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvGetVpciDeviceNotification(
    intptr_t Partition,
    uint64_t LogicalDeviceId,
    void* Notification,
    uint32_t NotificationSizeInBytes);
C, "WinHvPlatform.dll");
// $ffi->WHvGetVpciDeviceNotification(Partition, LogicalDeviceId, Notification, NotificationSizeInBytes);
// Partition : WHV_PARTITION_HANDLE
// LogicalDeviceId : ULONGLONG
// Notification : WHV_VPCI_DEVICE_NOTIFICATION* out
// NotificationSizeInBytes : 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 WHvGetVpciDeviceNotification(
        long Partition,   // WHV_PARTITION_HANDLE
        long LogicalDeviceId,   // ULONGLONG
        Pointer Notification,   // WHV_VPCI_DEVICE_NOTIFICATION* out
        int NotificationSizeInBytes   // DWORD
    );
}
@[Link("winhvplatform")]
lib LibWinHvPlatform
  fun WHvGetVpciDeviceNotification = WHvGetVpciDeviceNotification(
    Partition : LibC::SSizeT,   # WHV_PARTITION_HANDLE
    LogicalDeviceId : UInt64,   # ULONGLONG
    Notification : WHV_VPCI_DEVICE_NOTIFICATION*,   # WHV_VPCI_DEVICE_NOTIFICATION* out
    NotificationSizeInBytes : 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 WHvGetVpciDeviceNotificationNative = Int32 Function(IntPtr, Uint64, Pointer<Void>, Uint32);
typedef WHvGetVpciDeviceNotificationDart = int Function(int, int, Pointer<Void>, int);
final WHvGetVpciDeviceNotification = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvGetVpciDeviceNotificationNative, WHvGetVpciDeviceNotificationDart>('WHvGetVpciDeviceNotification');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// LogicalDeviceId : ULONGLONG -> Uint64
// Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> Pointer<Void>
// NotificationSizeInBytes : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WHvGetVpciDeviceNotification(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  LogicalDeviceId: UInt64;   // ULONGLONG
  Notification: Pointer;   // WHV_VPCI_DEVICE_NOTIFICATION* out
  NotificationSizeInBytes: DWORD   // DWORD
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvGetVpciDeviceNotification';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvGetVpciDeviceNotification"
  c_WHvGetVpciDeviceNotification :: CIntPtr -> Word64 -> Ptr () -> Word32 -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- LogicalDeviceId : ULONGLONG -> Word64
-- Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> Ptr ()
-- NotificationSizeInBytes : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvgetvpcidevicenotification =
  foreign "WHvGetVpciDeviceNotification"
    (intptr_t @-> uint64_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* LogicalDeviceId : ULONGLONG -> uint64_t *)
(* Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> (ptr void) *)
(* NotificationSizeInBytes : 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 ("WHvGetVpciDeviceNotification" whv-get-vpci-device-notification :convention :stdcall) :int32
  (partition :int64)   ; WHV_PARTITION_HANDLE
  (logical-device-id :uint64)   ; ULONGLONG
  (notification :pointer)   ; WHV_VPCI_DEVICE_NOTIFICATION* out
  (notification-size-in-bytes :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvGetVpciDeviceNotification = Win32::API::More->new('WinHvPlatform',
    'int WHvGetVpciDeviceNotification(LPARAM Partition, UINT64 LogicalDeviceId, LPVOID Notification, DWORD NotificationSizeInBytes)');
# my $ret = $WHvGetVpciDeviceNotification->Call($Partition, $LogicalDeviceId, $Notification, $NotificationSizeInBytes);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# LogicalDeviceId : ULONGLONG -> UINT64
# Notification : WHV_VPCI_DEVICE_NOTIFICATION* out -> LPVOID
# NotificationSizeInBytes : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型