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

WHvReadGpaRange

関数
ゲスト物理アドレス範囲からメモリを読み取る。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvReadGpaRange(
    WHV_PARTITION_HANDLE Partition,
    DWORD VpIndex,
    ULONGLONG GuestAddress,
    WHV_ACCESS_GPA_CONTROLS Controls,
    void* Data,
    DWORD DataSizeInBytes
);

パラメーター

名前方向
PartitionWHV_PARTITION_HANDLEin
VpIndexDWORDin
GuestAddressULONGLONGin
ControlsWHV_ACCESS_GPA_CONTROLSin
Datavoid*out
DataSizeInBytesDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvReadGpaRange(
    WHV_PARTITION_HANDLE Partition,
    DWORD VpIndex,
    ULONGLONG GuestAddress,
    WHV_ACCESS_GPA_CONTROLS Controls,
    void* Data,
    DWORD DataSizeInBytes
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvReadGpaRange(
    IntPtr Partition,   // WHV_PARTITION_HANDLE
    uint VpIndex,   // DWORD
    ulong GuestAddress,   // ULONGLONG
    WHV_ACCESS_GPA_CONTROLS Controls,   // WHV_ACCESS_GPA_CONTROLS
    IntPtr Data,   // void* out
    uint DataSizeInBytes   // DWORD
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvReadGpaRange(
    Partition As IntPtr,   ' WHV_PARTITION_HANDLE
    VpIndex As UInteger,   ' DWORD
    GuestAddress As ULong,   ' ULONGLONG
    Controls As WHV_ACCESS_GPA_CONTROLS,   ' WHV_ACCESS_GPA_CONTROLS
    Data As IntPtr,   ' void* out
    DataSizeInBytes As UInteger   ' DWORD
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
' VpIndex : DWORD
' GuestAddress : ULONGLONG
' Controls : WHV_ACCESS_GPA_CONTROLS
' Data : void* out
' DataSizeInBytes : DWORD
Declare PtrSafe Function WHvReadGpaRange Lib "winhvplatform" ( _
    ByVal Partition As LongPtr, _
    ByVal VpIndex As Long, _
    ByVal GuestAddress As LongLong, _
    ByVal Controls As LongPtr, _
    ByVal Data As LongPtr, _
    ByVal DataSizeInBytes As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvReadGpaRange = ctypes.windll.winhvplatform.WHvReadGpaRange
WHvReadGpaRange.restype = ctypes.c_int
WHvReadGpaRange.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    wintypes.DWORD,  # VpIndex : DWORD
    ctypes.c_ulonglong,  # GuestAddress : ULONGLONG
    WHV_ACCESS_GPA_CONTROLS,  # Controls : WHV_ACCESS_GPA_CONTROLS
    ctypes.POINTER(None),  # Data : void* out
    wintypes.DWORD,  # DataSizeInBytes : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvReadGpaRange = Fiddle::Function.new(
  lib['WHvReadGpaRange'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    -Fiddle::TYPE_INT,  # VpIndex : DWORD
    -Fiddle::TYPE_LONG_LONG,  # GuestAddress : ULONGLONG
    Fiddle::TYPE_VOIDP,  # Controls : WHV_ACCESS_GPA_CONTROLS
    Fiddle::TYPE_VOIDP,  # Data : void* out
    -Fiddle::TYPE_INT,  # DataSizeInBytes : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvReadGpaRange(
        Partition: isize,  // WHV_PARTITION_HANDLE
        VpIndex: u32,  // DWORD
        GuestAddress: u64,  // ULONGLONG
        Controls: WHV_ACCESS_GPA_CONTROLS,  // WHV_ACCESS_GPA_CONTROLS
        Data: *mut (),  // void* out
        DataSizeInBytes: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvReadGpaRange(IntPtr Partition, uint VpIndex, ulong GuestAddress, WHV_ACCESS_GPA_CONTROLS Controls, IntPtr Data, uint DataSizeInBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvReadGpaRange' -Namespace Win32 -PassThru
# $api::WHvReadGpaRange(Partition, VpIndex, GuestAddress, Controls, Data, DataSizeInBytes)
#uselib "WinHvPlatform.dll"
#func global WHvReadGpaRange "WHvReadGpaRange" sptr, sptr, sptr, sptr, sptr, sptr
; WHvReadGpaRange Partition, VpIndex, GuestAddress, Controls, Data, DataSizeInBytes   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; VpIndex : DWORD -> "sptr"
; GuestAddress : ULONGLONG -> "sptr"
; Controls : WHV_ACCESS_GPA_CONTROLS -> "sptr"
; Data : void* out -> "sptr"
; DataSizeInBytes : DWORD -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WinHvPlatform.dll"
#cfunc global WHvReadGpaRange "WHvReadGpaRange" sptr, int, int64, int, sptr, int
; res = WHvReadGpaRange(Partition, VpIndex, GuestAddress, Controls, Data, DataSizeInBytes)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; VpIndex : DWORD -> "int"
; GuestAddress : ULONGLONG -> "int64"
; Controls : WHV_ACCESS_GPA_CONTROLS -> "int"
; Data : void* out -> "sptr"
; DataSizeInBytes : DWORD -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; HRESULT WHvReadGpaRange(WHV_PARTITION_HANDLE Partition, DWORD VpIndex, ULONGLONG GuestAddress, WHV_ACCESS_GPA_CONTROLS Controls, void* Data, DWORD DataSizeInBytes)
#uselib "WinHvPlatform.dll"
#cfunc global WHvReadGpaRange "WHvReadGpaRange" intptr, int, int64, int, intptr, int
; res = WHvReadGpaRange(Partition, VpIndex, GuestAddress, Controls, Data, DataSizeInBytes)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; VpIndex : DWORD -> "int"
; GuestAddress : ULONGLONG -> "int64"
; Controls : WHV_ACCESS_GPA_CONTROLS -> "int"
; Data : void* out -> "intptr"
; DataSizeInBytes : DWORD -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvReadGpaRange = winhvplatform.NewProc("WHvReadGpaRange")
)

// Partition (WHV_PARTITION_HANDLE), VpIndex (DWORD), GuestAddress (ULONGLONG), Controls (WHV_ACCESS_GPA_CONTROLS), Data (void* out), DataSizeInBytes (DWORD)
r1, _, err := procWHvReadGpaRange.Call(
	uintptr(Partition),
	uintptr(VpIndex),
	uintptr(GuestAddress),
	uintptr(Controls),
	uintptr(Data),
	uintptr(DataSizeInBytes),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WHvReadGpaRange(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  VpIndex: DWORD;   // DWORD
  GuestAddress: UInt64;   // ULONGLONG
  Controls: WHV_ACCESS_GPA_CONTROLS;   // WHV_ACCESS_GPA_CONTROLS
  Data: Pointer;   // void* out
  DataSizeInBytes: DWORD   // DWORD
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvReadGpaRange';
result := DllCall("WinHvPlatform\WHvReadGpaRange"
    , "Ptr", Partition   ; WHV_PARTITION_HANDLE
    , "UInt", VpIndex   ; DWORD
    , "Int64", GuestAddress   ; ULONGLONG
    , "Ptr", Controls   ; WHV_ACCESS_GPA_CONTROLS
    , "Ptr", Data   ; void* out
    , "UInt", DataSizeInBytes   ; DWORD
    , "Int")   ; return: HRESULT
●WHvReadGpaRange(Partition, VpIndex, GuestAddress, Controls, Data, DataSizeInBytes) = DLL("WinHvPlatform.dll", "int WHvReadGpaRange(int, dword, qword, void*, void*, dword)")
# 呼び出し: WHvReadGpaRange(Partition, VpIndex, GuestAddress, Controls, Data, DataSizeInBytes)
# Partition : WHV_PARTITION_HANDLE -> "int"
# VpIndex : DWORD -> "dword"
# GuestAddress : ULONGLONG -> "qword"
# Controls : WHV_ACCESS_GPA_CONTROLS -> "void*"
# Data : void* out -> "void*"
# DataSizeInBytes : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。