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

HdvCreateGuestMemoryAperture

関数
ゲストメモリへのアパーチャマッピングを作成する。
DLLvmdevicehost.dll呼出規約winapi

シグネチャ

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

HRESULT HdvCreateGuestMemoryAperture(
    void* requestor,
    ULONGLONG guestPhysicalAddress,
    DWORD byteCount,
    BOOL writeProtected,
    void** mappedAddress
);

パラメーター

名前方向
requestorvoid*in
guestPhysicalAddressULONGLONGin
byteCountDWORDin
writeProtectedBOOLin
mappedAddressvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HdvCreateGuestMemoryAperture(
    void* requestor,
    ULONGLONG guestPhysicalAddress,
    DWORD byteCount,
    BOOL writeProtected,
    void** mappedAddress
);
[DllImport("vmdevicehost.dll", ExactSpelling = true)]
static extern int HdvCreateGuestMemoryAperture(
    IntPtr requestor,   // void*
    ulong guestPhysicalAddress,   // ULONGLONG
    uint byteCount,   // DWORD
    bool writeProtected,   // BOOL
    IntPtr mappedAddress   // void** out
);
<DllImport("vmdevicehost.dll", ExactSpelling:=True)>
Public Shared Function HdvCreateGuestMemoryAperture(
    requestor As IntPtr,   ' void*
    guestPhysicalAddress As ULong,   ' ULONGLONG
    byteCount As UInteger,   ' DWORD
    writeProtected As Boolean,   ' BOOL
    mappedAddress As IntPtr   ' void** out
) As Integer
End Function
' requestor : void*
' guestPhysicalAddress : ULONGLONG
' byteCount : DWORD
' writeProtected : BOOL
' mappedAddress : void** out
Declare PtrSafe Function HdvCreateGuestMemoryAperture Lib "vmdevicehost" ( _
    ByVal requestor As LongPtr, _
    ByVal guestPhysicalAddress As LongLong, _
    ByVal byteCount As Long, _
    ByVal writeProtected As Long, _
    ByVal mappedAddress As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HdvCreateGuestMemoryAperture = ctypes.windll.vmdevicehost.HdvCreateGuestMemoryAperture
HdvCreateGuestMemoryAperture.restype = ctypes.c_int
HdvCreateGuestMemoryAperture.argtypes = [
    ctypes.POINTER(None),  # requestor : void*
    ctypes.c_ulonglong,  # guestPhysicalAddress : ULONGLONG
    wintypes.DWORD,  # byteCount : DWORD
    wintypes.BOOL,  # writeProtected : BOOL
    ctypes.c_void_p,  # mappedAddress : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('vmdevicehost.dll')
HdvCreateGuestMemoryAperture = Fiddle::Function.new(
  lib['HdvCreateGuestMemoryAperture'],
  [
    Fiddle::TYPE_VOIDP,  # requestor : void*
    -Fiddle::TYPE_LONG_LONG,  # guestPhysicalAddress : ULONGLONG
    -Fiddle::TYPE_INT,  # byteCount : DWORD
    Fiddle::TYPE_INT,  # writeProtected : BOOL
    Fiddle::TYPE_VOIDP,  # mappedAddress : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "vmdevicehost")]
extern "system" {
    fn HdvCreateGuestMemoryAperture(
        requestor: *mut (),  // void*
        guestPhysicalAddress: u64,  // ULONGLONG
        byteCount: u32,  // DWORD
        writeProtected: i32,  // BOOL
        mappedAddress: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("vmdevicehost.dll")]
public static extern int HdvCreateGuestMemoryAperture(IntPtr requestor, ulong guestPhysicalAddress, uint byteCount, bool writeProtected, IntPtr mappedAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'vmdevicehost_HdvCreateGuestMemoryAperture' -Namespace Win32 -PassThru
# $api::HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
#uselib "vmdevicehost.dll"
#func global HdvCreateGuestMemoryAperture "HdvCreateGuestMemoryAperture" sptr, sptr, sptr, sptr, sptr
; HdvCreateGuestMemoryAperture requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress   ; 戻り値は stat
; requestor : void* -> "sptr"
; guestPhysicalAddress : ULONGLONG -> "sptr"
; byteCount : DWORD -> "sptr"
; writeProtected : BOOL -> "sptr"
; mappedAddress : void** out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "vmdevicehost.dll"
#cfunc global HdvCreateGuestMemoryAperture "HdvCreateGuestMemoryAperture" sptr, int64, int, int, sptr
; res = HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
; requestor : void* -> "sptr"
; guestPhysicalAddress : ULONGLONG -> "int64"
; byteCount : DWORD -> "int"
; writeProtected : BOOL -> "int"
; mappedAddress : void** out -> "sptr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; HRESULT HdvCreateGuestMemoryAperture(void* requestor, ULONGLONG guestPhysicalAddress, DWORD byteCount, BOOL writeProtected, void** mappedAddress)
#uselib "vmdevicehost.dll"
#cfunc global HdvCreateGuestMemoryAperture "HdvCreateGuestMemoryAperture" intptr, int64, int, int, intptr
; res = HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
; requestor : void* -> "intptr"
; guestPhysicalAddress : ULONGLONG -> "int64"
; byteCount : DWORD -> "int"
; writeProtected : BOOL -> "int"
; mappedAddress : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	vmdevicehost = windows.NewLazySystemDLL("vmdevicehost.dll")
	procHdvCreateGuestMemoryAperture = vmdevicehost.NewProc("HdvCreateGuestMemoryAperture")
)

// requestor (void*), guestPhysicalAddress (ULONGLONG), byteCount (DWORD), writeProtected (BOOL), mappedAddress (void** out)
r1, _, err := procHdvCreateGuestMemoryAperture.Call(
	uintptr(requestor),
	uintptr(guestPhysicalAddress),
	uintptr(byteCount),
	uintptr(writeProtected),
	uintptr(mappedAddress),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HdvCreateGuestMemoryAperture(
  requestor: Pointer;   // void*
  guestPhysicalAddress: UInt64;   // ULONGLONG
  byteCount: DWORD;   // DWORD
  writeProtected: BOOL;   // BOOL
  mappedAddress: Pointer   // void** out
): Integer; stdcall;
  external 'vmdevicehost.dll' name 'HdvCreateGuestMemoryAperture';
result := DllCall("vmdevicehost\HdvCreateGuestMemoryAperture"
    , "Ptr", requestor   ; void*
    , "Int64", guestPhysicalAddress   ; ULONGLONG
    , "UInt", byteCount   ; DWORD
    , "Int", writeProtected   ; BOOL
    , "Ptr", mappedAddress   ; void** out
    , "Int")   ; return: HRESULT
●HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress) = DLL("vmdevicehost.dll", "int HdvCreateGuestMemoryAperture(void*, qword, dword, bool, void*)")
# 呼び出し: HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
# requestor : void* -> "void*"
# guestPhysicalAddress : ULONGLONG -> "qword"
# byteCount : DWORD -> "dword"
# writeProtected : BOOL -> "bool"
# mappedAddress : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。