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