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