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

WHvAllocateVpciResource

関数
仮想PCIリソースを割り当ててハンドルを取得する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

// 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
);

パラメーター

名前方向
ProviderIdGUID*inoptional
FlagsWHV_ALLOCATE_VPCI_RESOURCE_FLAGSin
ResourceDescriptorvoid*inoptional
ResourceDescriptorSizeInBytesDWORDin
VpciResourceHANDLE*out

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
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';
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)。