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