ホーム › System.Hypervisor › HdvCreateGuestMemoryAperture
HdvCreateGuestMemoryAperture
関数ゲストメモリへのアパーチャマッピングを作成する。
シグネチャ
// vmdevicehost.dll
#include <windows.h>
HRESULT HdvCreateGuestMemoryAperture(
void* requestor,
ULONGLONG guestPhysicalAddress,
DWORD byteCount,
BOOL writeProtected,
void** mappedAddress
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| requestor | void* | in | 操作を要求するデバイス等を表すリクエスタコンテキストへのポインタ。 |
| guestPhysicalAddress | ULONGLONG | in | アパチャを作成するゲスト物理アドレスの開始位置を指定する。 |
| byteCount | DWORD | in | マップするゲストメモリのバイト数を指定する。 |
| writeProtected | BOOL | in | TRUEで読み取り専用、FALSEで読み書き可能としてマップするかを指定する。 |
| mappedAddress | void** | 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 // HRESULTfunction 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)。const std = @import("std");
extern "vmdevicehost" fn HdvCreateGuestMemoryAperture(
requestor: ?*anyopaque, // void*
guestPhysicalAddress: u64, // ULONGLONG
byteCount: u32, // DWORD
writeProtected: i32, // BOOL
mappedAddress: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc HdvCreateGuestMemoryAperture(
requestor: pointer, # void*
guestPhysicalAddress: uint64, # ULONGLONG
byteCount: uint32, # DWORD
writeProtected: int32, # BOOL
mappedAddress: pointer # void** out
): int32 {.importc: "HdvCreateGuestMemoryAperture", stdcall, dynlib: "vmdevicehost.dll".}pragma(lib, "vmdevicehost");
extern(Windows)
int HdvCreateGuestMemoryAperture(
void* requestor, // void*
ulong guestPhysicalAddress, // ULONGLONG
uint byteCount, // DWORD
int writeProtected, // BOOL
void** mappedAddress // void** out
);ccall((:HdvCreateGuestMemoryAperture, "vmdevicehost.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt64, UInt32, Int32, Ptr{Cvoid}),
requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
# requestor : void* -> Ptr{Cvoid}
# guestPhysicalAddress : ULONGLONG -> UInt64
# byteCount : DWORD -> UInt32
# writeProtected : BOOL -> Int32
# mappedAddress : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HdvCreateGuestMemoryAperture(
void* requestor,
uint64_t guestPhysicalAddress,
uint32_t byteCount,
int32_t writeProtected,
void** mappedAddress);
]]
local vmdevicehost = ffi.load("vmdevicehost")
-- vmdevicehost.HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
-- requestor : void*
-- guestPhysicalAddress : ULONGLONG
-- byteCount : DWORD
-- writeProtected : BOOL
-- mappedAddress : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('vmdevicehost.dll');
const HdvCreateGuestMemoryAperture = lib.func('__stdcall', 'HdvCreateGuestMemoryAperture', 'int32_t', ['void *', 'uint64_t', 'uint32_t', 'int32_t', 'void *']);
// HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
// requestor : void* -> 'void *'
// guestPhysicalAddress : ULONGLONG -> 'uint64_t'
// byteCount : DWORD -> 'uint32_t'
// writeProtected : BOOL -> 'int32_t'
// mappedAddress : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("vmdevicehost.dll", {
HdvCreateGuestMemoryAperture: { parameters: ["pointer", "u64", "u32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress)
// requestor : void* -> "pointer"
// guestPhysicalAddress : ULONGLONG -> "u64"
// byteCount : DWORD -> "u32"
// writeProtected : BOOL -> "i32"
// mappedAddress : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HdvCreateGuestMemoryAperture(
void* requestor,
uint64_t guestPhysicalAddress,
uint32_t byteCount,
int32_t writeProtected,
void** mappedAddress);
C, "vmdevicehost.dll");
// $ffi->HdvCreateGuestMemoryAperture(requestor, guestPhysicalAddress, byteCount, writeProtected, mappedAddress);
// requestor : void*
// guestPhysicalAddress : ULONGLONG
// byteCount : DWORD
// writeProtected : BOOL
// mappedAddress : void** 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 Vmdevicehost extends StdCallLibrary {
Vmdevicehost INSTANCE = Native.load("vmdevicehost", Vmdevicehost.class);
int HdvCreateGuestMemoryAperture(
Pointer requestor, // void*
long guestPhysicalAddress, // ULONGLONG
int byteCount, // DWORD
boolean writeProtected, // BOOL
Pointer mappedAddress // void** out
);
}@[Link("vmdevicehost")]
lib Libvmdevicehost
fun HdvCreateGuestMemoryAperture = HdvCreateGuestMemoryAperture(
requestor : Void*, # void*
guestPhysicalAddress : UInt64, # ULONGLONG
byteCount : UInt32, # DWORD
writeProtected : Int32, # BOOL
mappedAddress : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HdvCreateGuestMemoryApertureNative = Int32 Function(Pointer<Void>, Uint64, Uint32, Int32, Pointer<Void>);
typedef HdvCreateGuestMemoryApertureDart = int Function(Pointer<Void>, int, int, int, Pointer<Void>);
final HdvCreateGuestMemoryAperture = DynamicLibrary.open('vmdevicehost.dll')
.lookupFunction<HdvCreateGuestMemoryApertureNative, HdvCreateGuestMemoryApertureDart>('HdvCreateGuestMemoryAperture');
// requestor : void* -> Pointer<Void>
// guestPhysicalAddress : ULONGLONG -> Uint64
// byteCount : DWORD -> Uint32
// writeProtected : BOOL -> Int32
// mappedAddress : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HdvCreateGuestMemoryAperture"
c_HdvCreateGuestMemoryAperture :: Ptr () -> Word64 -> Word32 -> CInt -> Ptr () -> IO Int32
-- requestor : void* -> Ptr ()
-- guestPhysicalAddress : ULONGLONG -> Word64
-- byteCount : DWORD -> Word32
-- writeProtected : BOOL -> CInt
-- mappedAddress : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hdvcreateguestmemoryaperture =
foreign "HdvCreateGuestMemoryAperture"
((ptr void) @-> uint64_t @-> uint32_t @-> int32_t @-> (ptr void) @-> returning int32_t)
(* requestor : void* -> (ptr void) *)
(* guestPhysicalAddress : ULONGLONG -> uint64_t *)
(* byteCount : DWORD -> uint32_t *)
(* writeProtected : BOOL -> int32_t *)
(* mappedAddress : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library vmdevicehost (t "vmdevicehost.dll"))
(cffi:use-foreign-library vmdevicehost)
(cffi:defcfun ("HdvCreateGuestMemoryAperture" hdv-create-guest-memory-aperture :convention :stdcall) :int32
(requestor :pointer) ; void*
(guest-physical-address :uint64) ; ULONGLONG
(byte-count :uint32) ; DWORD
(write-protected :int32) ; BOOL
(mapped-address :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HdvCreateGuestMemoryAperture = Win32::API::More->new('vmdevicehost',
'int HdvCreateGuestMemoryAperture(LPVOID requestor, UINT64 guestPhysicalAddress, DWORD byteCount, BOOL writeProtected, LPVOID mappedAddress)');
# my $ret = $HdvCreateGuestMemoryAperture->Call($requestor, $guestPhysicalAddress, $byteCount, $writeProtected, $mappedAddress);
# requestor : void* -> LPVOID
# guestPhysicalAddress : ULONGLONG -> UINT64
# byteCount : DWORD -> DWORD
# writeProtected : BOOL -> BOOL
# mappedAddress : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。