ホーム › System.Hypervisor › WHvMapVpciDeviceMmioRanges
WHvMapVpciDeviceMmioRanges
関数仮想PCIデバイスのMMIO範囲をマップする。
シグネチャ
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvMapVpciDeviceMmioRanges(
WHV_PARTITION_HANDLE Partition,
ULONGLONG LogicalDeviceId,
DWORD* MappingCount,
WHV_VPCI_MMIO_MAPPING** Mappings
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Partition | WHV_PARTITION_HANDLE | in |
| LogicalDeviceId | ULONGLONG | in |
| MappingCount | DWORD* | out |
| Mappings | WHV_VPCI_MMIO_MAPPING** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvMapVpciDeviceMmioRanges(
WHV_PARTITION_HANDLE Partition,
ULONGLONG LogicalDeviceId,
DWORD* MappingCount,
WHV_VPCI_MMIO_MAPPING** Mappings
);[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvMapVpciDeviceMmioRanges(
IntPtr Partition, // WHV_PARTITION_HANDLE
ulong LogicalDeviceId, // ULONGLONG
out uint MappingCount, // DWORD* out
IntPtr Mappings // WHV_VPCI_MMIO_MAPPING** out
);<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvMapVpciDeviceMmioRanges(
Partition As IntPtr, ' WHV_PARTITION_HANDLE
LogicalDeviceId As ULong, ' ULONGLONG
<Out> ByRef MappingCount As UInteger, ' DWORD* out
Mappings As IntPtr ' WHV_VPCI_MMIO_MAPPING** out
) As Integer
End Function' Partition : WHV_PARTITION_HANDLE
' LogicalDeviceId : ULONGLONG
' MappingCount : DWORD* out
' Mappings : WHV_VPCI_MMIO_MAPPING** out
Declare PtrSafe Function WHvMapVpciDeviceMmioRanges Lib "winhvplatform" ( _
ByVal Partition As LongPtr, _
ByVal LogicalDeviceId As LongLong, _
ByRef MappingCount As Long, _
ByVal Mappings As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WHvMapVpciDeviceMmioRanges = ctypes.windll.winhvplatform.WHvMapVpciDeviceMmioRanges
WHvMapVpciDeviceMmioRanges.restype = ctypes.c_int
WHvMapVpciDeviceMmioRanges.argtypes = [
ctypes.c_ssize_t, # Partition : WHV_PARTITION_HANDLE
ctypes.c_ulonglong, # LogicalDeviceId : ULONGLONG
ctypes.POINTER(wintypes.DWORD), # MappingCount : DWORD* out
ctypes.c_void_p, # Mappings : WHV_VPCI_MMIO_MAPPING** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvMapVpciDeviceMmioRanges = Fiddle::Function.new(
lib['WHvMapVpciDeviceMmioRanges'],
[
Fiddle::TYPE_INTPTR_T, # Partition : WHV_PARTITION_HANDLE
-Fiddle::TYPE_LONG_LONG, # LogicalDeviceId : ULONGLONG
Fiddle::TYPE_VOIDP, # MappingCount : DWORD* out
Fiddle::TYPE_VOIDP, # Mappings : WHV_VPCI_MMIO_MAPPING** out
],
Fiddle::TYPE_INT)#[link(name = "winhvplatform")]
extern "system" {
fn WHvMapVpciDeviceMmioRanges(
Partition: isize, // WHV_PARTITION_HANDLE
LogicalDeviceId: u64, // ULONGLONG
MappingCount: *mut u32, // DWORD* out
Mappings: *mut *mut WHV_VPCI_MMIO_MAPPING // WHV_VPCI_MMIO_MAPPING** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvMapVpciDeviceMmioRanges(IntPtr Partition, ulong LogicalDeviceId, out uint MappingCount, IntPtr Mappings);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvMapVpciDeviceMmioRanges' -Namespace Win32 -PassThru
# $api::WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, MappingCount, Mappings)#uselib "WinHvPlatform.dll"
#func global WHvMapVpciDeviceMmioRanges "WHvMapVpciDeviceMmioRanges" sptr, sptr, sptr, sptr
; WHvMapVpciDeviceMmioRanges Partition, LogicalDeviceId, varptr(MappingCount), varptr(Mappings) ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "sptr"
; MappingCount : DWORD* out -> "sptr"
; Mappings : WHV_VPCI_MMIO_MAPPING** out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WinHvPlatform.dll" #cfunc global WHvMapVpciDeviceMmioRanges "WHvMapVpciDeviceMmioRanges" sptr, int64, var, var ; res = WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, MappingCount, Mappings) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; LogicalDeviceId : ULONGLONG -> "int64" ; MappingCount : DWORD* out -> "var" ; Mappings : WHV_VPCI_MMIO_MAPPING** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "WinHvPlatform.dll" #cfunc global WHvMapVpciDeviceMmioRanges "WHvMapVpciDeviceMmioRanges" sptr, int64, sptr, sptr ; res = WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, varptr(MappingCount), varptr(Mappings)) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; LogicalDeviceId : ULONGLONG -> "int64" ; MappingCount : DWORD* out -> "sptr" ; Mappings : WHV_VPCI_MMIO_MAPPING** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; HRESULT WHvMapVpciDeviceMmioRanges(WHV_PARTITION_HANDLE Partition, ULONGLONG LogicalDeviceId, DWORD* MappingCount, WHV_VPCI_MMIO_MAPPING** Mappings) #uselib "WinHvPlatform.dll" #cfunc global WHvMapVpciDeviceMmioRanges "WHvMapVpciDeviceMmioRanges" intptr, int64, var, var ; res = WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, MappingCount, Mappings) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; LogicalDeviceId : ULONGLONG -> "int64" ; MappingCount : DWORD* out -> "var" ; Mappings : WHV_VPCI_MMIO_MAPPING** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WHvMapVpciDeviceMmioRanges(WHV_PARTITION_HANDLE Partition, ULONGLONG LogicalDeviceId, DWORD* MappingCount, WHV_VPCI_MMIO_MAPPING** Mappings) #uselib "WinHvPlatform.dll" #cfunc global WHvMapVpciDeviceMmioRanges "WHvMapVpciDeviceMmioRanges" intptr, int64, intptr, intptr ; res = WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, varptr(MappingCount), varptr(Mappings)) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; LogicalDeviceId : ULONGLONG -> "int64" ; MappingCount : DWORD* out -> "intptr" ; Mappings : WHV_VPCI_MMIO_MAPPING** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
procWHvMapVpciDeviceMmioRanges = winhvplatform.NewProc("WHvMapVpciDeviceMmioRanges")
)
// Partition (WHV_PARTITION_HANDLE), LogicalDeviceId (ULONGLONG), MappingCount (DWORD* out), Mappings (WHV_VPCI_MMIO_MAPPING** out)
r1, _, err := procWHvMapVpciDeviceMmioRanges.Call(
uintptr(Partition),
uintptr(LogicalDeviceId),
uintptr(MappingCount),
uintptr(Mappings),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WHvMapVpciDeviceMmioRanges(
Partition: NativeInt; // WHV_PARTITION_HANDLE
LogicalDeviceId: UInt64; // ULONGLONG
MappingCount: Pointer; // DWORD* out
Mappings: Pointer // WHV_VPCI_MMIO_MAPPING** out
): Integer; stdcall;
external 'WinHvPlatform.dll' name 'WHvMapVpciDeviceMmioRanges';result := DllCall("WinHvPlatform\WHvMapVpciDeviceMmioRanges"
, "Ptr", Partition ; WHV_PARTITION_HANDLE
, "Int64", LogicalDeviceId ; ULONGLONG
, "Ptr", MappingCount ; DWORD* out
, "Ptr", Mappings ; WHV_VPCI_MMIO_MAPPING** out
, "Int") ; return: HRESULT●WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, MappingCount, Mappings) = DLL("WinHvPlatform.dll", "int WHvMapVpciDeviceMmioRanges(int, qword, void*, void*)")
# 呼び出し: WHvMapVpciDeviceMmioRanges(Partition, LogicalDeviceId, MappingCount, Mappings)
# Partition : WHV_PARTITION_HANDLE -> "int"
# LogicalDeviceId : ULONGLONG -> "qword"
# MappingCount : DWORD* out -> "void*"
# Mappings : WHV_VPCI_MMIO_MAPPING** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。