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

WHvRegisterPartitionDoorbellEvent

関数
パーティションにドアベルイベントを登録する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvRegisterPartitionDoorbellEvent(
    WHV_PARTITION_HANDLE Partition,
    const WHV_DOORBELL_MATCH_DATA* MatchData,
    HANDLE EventHandle
);

パラメーター

名前方向説明
PartitionWHV_PARTITION_HANDLEin対象パーティションのハンドルを指定する。
MatchDataWHV_DOORBELL_MATCH_DATA*inドアベルが発火する条件(GPA・値・マスク等)を記述した構造体へのポインタ。
EventHandleHANDLEin条件成立時にシグナル状態となるイベントオブジェクトのハンドルを指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvRegisterPartitionDoorbellEvent(
    WHV_PARTITION_HANDLE Partition,
    const WHV_DOORBELL_MATCH_DATA* MatchData,
    HANDLE EventHandle
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvRegisterPartitionDoorbellEvent(
    IntPtr Partition,   // WHV_PARTITION_HANDLE
    IntPtr MatchData,   // WHV_DOORBELL_MATCH_DATA*
    IntPtr EventHandle   // HANDLE
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvRegisterPartitionDoorbellEvent(
    Partition As IntPtr,   ' WHV_PARTITION_HANDLE
    MatchData As IntPtr,   ' WHV_DOORBELL_MATCH_DATA*
    EventHandle As IntPtr   ' HANDLE
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
' MatchData : WHV_DOORBELL_MATCH_DATA*
' EventHandle : HANDLE
Declare PtrSafe Function WHvRegisterPartitionDoorbellEvent Lib "winhvplatform" ( _
    ByVal Partition As LongPtr, _
    ByVal MatchData As LongPtr, _
    ByVal EventHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvRegisterPartitionDoorbellEvent = ctypes.windll.winhvplatform.WHvRegisterPartitionDoorbellEvent
WHvRegisterPartitionDoorbellEvent.restype = ctypes.c_int
WHvRegisterPartitionDoorbellEvent.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    ctypes.c_void_p,  # MatchData : WHV_DOORBELL_MATCH_DATA*
    wintypes.HANDLE,  # EventHandle : HANDLE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvRegisterPartitionDoorbellEvent = Fiddle::Function.new(
  lib['WHvRegisterPartitionDoorbellEvent'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    Fiddle::TYPE_VOIDP,  # MatchData : WHV_DOORBELL_MATCH_DATA*
    Fiddle::TYPE_VOIDP,  # EventHandle : HANDLE
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvRegisterPartitionDoorbellEvent(
        Partition: isize,  // WHV_PARTITION_HANDLE
        MatchData: *const WHV_DOORBELL_MATCH_DATA,  // WHV_DOORBELL_MATCH_DATA*
        EventHandle: *mut core::ffi::c_void  // HANDLE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvRegisterPartitionDoorbellEvent(IntPtr Partition, IntPtr MatchData, IntPtr EventHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvRegisterPartitionDoorbellEvent' -Namespace Win32 -PassThru
# $api::WHvRegisterPartitionDoorbellEvent(Partition, MatchData, EventHandle)
#uselib "WinHvPlatform.dll"
#func global WHvRegisterPartitionDoorbellEvent "WHvRegisterPartitionDoorbellEvent" sptr, sptr, sptr
; WHvRegisterPartitionDoorbellEvent Partition, varptr(MatchData), EventHandle   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; MatchData : WHV_DOORBELL_MATCH_DATA* -> "sptr"
; EventHandle : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinHvPlatform.dll"
#cfunc global WHvRegisterPartitionDoorbellEvent "WHvRegisterPartitionDoorbellEvent" sptr, var, sptr
; res = WHvRegisterPartitionDoorbellEvent(Partition, MatchData, EventHandle)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; MatchData : WHV_DOORBELL_MATCH_DATA* -> "var"
; EventHandle : HANDLE -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WHvRegisterPartitionDoorbellEvent(WHV_PARTITION_HANDLE Partition, WHV_DOORBELL_MATCH_DATA* MatchData, HANDLE EventHandle)
#uselib "WinHvPlatform.dll"
#cfunc global WHvRegisterPartitionDoorbellEvent "WHvRegisterPartitionDoorbellEvent" intptr, var, intptr
; res = WHvRegisterPartitionDoorbellEvent(Partition, MatchData, EventHandle)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; MatchData : WHV_DOORBELL_MATCH_DATA* -> "var"
; EventHandle : HANDLE -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvRegisterPartitionDoorbellEvent = winhvplatform.NewProc("WHvRegisterPartitionDoorbellEvent")
)

// Partition (WHV_PARTITION_HANDLE), MatchData (WHV_DOORBELL_MATCH_DATA*), EventHandle (HANDLE)
r1, _, err := procWHvRegisterPartitionDoorbellEvent.Call(
	uintptr(Partition),
	uintptr(MatchData),
	uintptr(EventHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WHvRegisterPartitionDoorbellEvent(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  MatchData: Pointer;   // WHV_DOORBELL_MATCH_DATA*
  EventHandle: THandle   // HANDLE
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvRegisterPartitionDoorbellEvent';
result := DllCall("WinHvPlatform\WHvRegisterPartitionDoorbellEvent"
    , "Ptr", Partition   ; WHV_PARTITION_HANDLE
    , "Ptr", MatchData   ; WHV_DOORBELL_MATCH_DATA*
    , "Ptr", EventHandle   ; HANDLE
    , "Int")   ; return: HRESULT
●WHvRegisterPartitionDoorbellEvent(Partition, MatchData, EventHandle) = DLL("WinHvPlatform.dll", "int WHvRegisterPartitionDoorbellEvent(int, void*, void*)")
# 呼び出し: WHvRegisterPartitionDoorbellEvent(Partition, MatchData, EventHandle)
# Partition : WHV_PARTITION_HANDLE -> "int"
# MatchData : WHV_DOORBELL_MATCH_DATA* -> "void*"
# EventHandle : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef WHvRegisterPartitionDoorbellEventNative = Int32 Function(IntPtr, Pointer<Void>, Pointer<Void>);
typedef WHvRegisterPartitionDoorbellEventDart = int Function(int, Pointer<Void>, Pointer<Void>);
final WHvRegisterPartitionDoorbellEvent = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvRegisterPartitionDoorbellEventNative, WHvRegisterPartitionDoorbellEventDart>('WHvRegisterPartitionDoorbellEvent');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// MatchData : WHV_DOORBELL_MATCH_DATA* -> Pointer<Void>
// EventHandle : HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WHvRegisterPartitionDoorbellEvent(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  MatchData: Pointer;   // WHV_DOORBELL_MATCH_DATA*
  EventHandle: THandle   // HANDLE
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvRegisterPartitionDoorbellEvent';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvRegisterPartitionDoorbellEvent"
  c_WHvRegisterPartitionDoorbellEvent :: CIntPtr -> Ptr () -> Ptr () -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- MatchData : WHV_DOORBELL_MATCH_DATA* -> Ptr ()
-- EventHandle : HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvregisterpartitiondoorbellevent =
  foreign "WHvRegisterPartitionDoorbellEvent"
    (intptr_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* MatchData : WHV_DOORBELL_MATCH_DATA* -> (ptr void) *)
(* EventHandle : HANDLE -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)

(cffi:defcfun ("WHvRegisterPartitionDoorbellEvent" whv-register-partition-doorbell-event :convention :stdcall) :int32
  (partition :int64)   ; WHV_PARTITION_HANDLE
  (match-data :pointer)   ; WHV_DOORBELL_MATCH_DATA*
  (event-handle :pointer))   ; HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvRegisterPartitionDoorbellEvent = Win32::API::More->new('WinHvPlatform',
    'int WHvRegisterPartitionDoorbellEvent(LPARAM Partition, LPVOID MatchData, HANDLE EventHandle)');
# my $ret = $WHvRegisterPartitionDoorbellEvent->Call($Partition, $MatchData, $EventHandle);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# MatchData : WHV_DOORBELL_MATCH_DATA* -> LPVOID
# EventHandle : HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型