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

WHV_EMULATOR_CALLBACKS

構造体
サイズx64: 48 バイト / x86: 28 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
SizeDWORD4+0+0この構造体のバイトサイズを示すDWORD。バージョン互換性確認に使う。
ReservedDWORD4+4+4予約フィールド。アライメント用で0とする。
WHvEmulatorIoPortCallbackWHV_EMULATOR_IO_PORT_CALLBACK8/4+8+8I/Oポートアクセスをエミュレータに処理させるコールバック関数ポインタである。
WHvEmulatorMemoryCallbackWHV_EMULATOR_MEMORY_CALLBACK8/4+16+12メモリアクセスをエミュレータに処理させるコールバック関数ポインタである。
WHvEmulatorGetVirtualProcessorRegistersWHV_EMULATOR_GET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK8/4+24+16仮想プロセッサのレジスタを取得するコールバック関数ポインタである。
WHvEmulatorSetVirtualProcessorRegistersWHV_EMULATOR_SET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK8/4+32+20仮想プロセッサのレジスタを設定するコールバック関数ポインタである。
WHvEmulatorTranslateGvaPageWHV_EMULATOR_TRANSLATE_GVA_PAGE_CALLBACK8/4+40+24GVAページをGPAに変換するコールバック関数ポインタである。

各言語での定義

#include <windows.h>

// WHV_EMULATOR_CALLBACKS  (x64 48 / x86 28 バイト)
typedef struct WHV_EMULATOR_CALLBACKS {
    DWORD Size;
    DWORD Reserved;
    WHV_EMULATOR_IO_PORT_CALLBACK WHvEmulatorIoPortCallback;
    WHV_EMULATOR_MEMORY_CALLBACK WHvEmulatorMemoryCallback;
    WHV_EMULATOR_GET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK WHvEmulatorGetVirtualProcessorRegisters;
    WHV_EMULATOR_SET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK WHvEmulatorSetVirtualProcessorRegisters;
    WHV_EMULATOR_TRANSLATE_GVA_PAGE_CALLBACK WHvEmulatorTranslateGvaPage;
} WHV_EMULATOR_CALLBACKS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WHV_EMULATOR_CALLBACKS
{
    public uint Size;
    public uint Reserved;
    public IntPtr WHvEmulatorIoPortCallback;
    public IntPtr WHvEmulatorMemoryCallback;
    public IntPtr WHvEmulatorGetVirtualProcessorRegisters;
    public IntPtr WHvEmulatorSetVirtualProcessorRegisters;
    public IntPtr WHvEmulatorTranslateGvaPage;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WHV_EMULATOR_CALLBACKS
    Public Size As UInteger
    Public Reserved As UInteger
    Public WHvEmulatorIoPortCallback As IntPtr
    Public WHvEmulatorMemoryCallback As IntPtr
    Public WHvEmulatorGetVirtualProcessorRegisters As IntPtr
    Public WHvEmulatorSetVirtualProcessorRegisters As IntPtr
    Public WHvEmulatorTranslateGvaPage As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class WHV_EMULATOR_CALLBACKS(ctypes.Structure):
    _fields_ = [
        ("Size", wintypes.DWORD),
        ("Reserved", wintypes.DWORD),
        ("WHvEmulatorIoPortCallback", ctypes.c_void_p),
        ("WHvEmulatorMemoryCallback", ctypes.c_void_p),
        ("WHvEmulatorGetVirtualProcessorRegisters", ctypes.c_void_p),
        ("WHvEmulatorSetVirtualProcessorRegisters", ctypes.c_void_p),
        ("WHvEmulatorTranslateGvaPage", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct WHV_EMULATOR_CALLBACKS {
    pub Size: u32,
    pub Reserved: u32,
    pub WHvEmulatorIoPortCallback: *mut core::ffi::c_void,
    pub WHvEmulatorMemoryCallback: *mut core::ffi::c_void,
    pub WHvEmulatorGetVirtualProcessorRegisters: *mut core::ffi::c_void,
    pub WHvEmulatorSetVirtualProcessorRegisters: *mut core::ffi::c_void,
    pub WHvEmulatorTranslateGvaPage: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type WHV_EMULATOR_CALLBACKS struct {
	Size uint32
	Reserved uint32
	WHvEmulatorIoPortCallback uintptr
	WHvEmulatorMemoryCallback uintptr
	WHvEmulatorGetVirtualProcessorRegisters uintptr
	WHvEmulatorSetVirtualProcessorRegisters uintptr
	WHvEmulatorTranslateGvaPage uintptr
}
type
  WHV_EMULATOR_CALLBACKS = record
    Size: DWORD;
    Reserved: DWORD;
    WHvEmulatorIoPortCallback: Pointer;
    WHvEmulatorMemoryCallback: Pointer;
    WHvEmulatorGetVirtualProcessorRegisters: Pointer;
    WHvEmulatorSetVirtualProcessorRegisters: Pointer;
    WHvEmulatorTranslateGvaPage: Pointer;
  end;
const WHV_EMULATOR_CALLBACKS = extern struct {
    Size: u32,
    Reserved: u32,
    WHvEmulatorIoPortCallback: ?*anyopaque,
    WHvEmulatorMemoryCallback: ?*anyopaque,
    WHvEmulatorGetVirtualProcessorRegisters: ?*anyopaque,
    WHvEmulatorSetVirtualProcessorRegisters: ?*anyopaque,
    WHvEmulatorTranslateGvaPage: ?*anyopaque,
};
type
  WHV_EMULATOR_CALLBACKS {.bycopy.} = object
    Size: uint32
    Reserved: uint32
    WHvEmulatorIoPortCallback: pointer
    WHvEmulatorMemoryCallback: pointer
    WHvEmulatorGetVirtualProcessorRegisters: pointer
    WHvEmulatorSetVirtualProcessorRegisters: pointer
    WHvEmulatorTranslateGvaPage: pointer
struct WHV_EMULATOR_CALLBACKS
{
    uint Size;
    uint Reserved;
    void* WHvEmulatorIoPortCallback;
    void* WHvEmulatorMemoryCallback;
    void* WHvEmulatorGetVirtualProcessorRegisters;
    void* WHvEmulatorSetVirtualProcessorRegisters;
    void* WHvEmulatorTranslateGvaPage;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WHV_EMULATOR_CALLBACKS サイズ: 28 バイト(x86)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; Size : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Reserved : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; WHvEmulatorIoPortCallback : WHV_EMULATOR_IO_PORT_CALLBACK (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; WHvEmulatorMemoryCallback : WHV_EMULATOR_MEMORY_CALLBACK (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; WHvEmulatorGetVirtualProcessorRegisters : WHV_EMULATOR_GET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; WHvEmulatorSetVirtualProcessorRegisters : WHV_EMULATOR_SET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; WHvEmulatorTranslateGvaPage : WHV_EMULATOR_TRANSLATE_GVA_PAGE_CALLBACK (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WHV_EMULATOR_CALLBACKS サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Size : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Reserved : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; WHvEmulatorIoPortCallback : WHV_EMULATOR_IO_PORT_CALLBACK (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; WHvEmulatorMemoryCallback : WHV_EMULATOR_MEMORY_CALLBACK (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; WHvEmulatorGetVirtualProcessorRegisters : WHV_EMULATOR_GET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; WHvEmulatorSetVirtualProcessorRegisters : WHV_EMULATOR_SET_VIRTUAL_PROCESSOR_REGISTERS_CALLBACK (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; WHvEmulatorTranslateGvaPage : WHV_EMULATOR_TRANSLATE_GVA_PAGE_CALLBACK (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WHV_EMULATOR_CALLBACKS
    #field int Size
    #field int Reserved
    #field intptr WHvEmulatorIoPortCallback
    #field intptr WHvEmulatorMemoryCallback
    #field intptr WHvEmulatorGetVirtualProcessorRegisters
    #field intptr WHvEmulatorSetVirtualProcessorRegisters
    #field intptr WHvEmulatorTranslateGvaPage
#endstruct

stdim st, WHV_EMULATOR_CALLBACKS        ; NSTRUCT 変数を確保
st->Size = 100
mes "Size=" + st->Size