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

WHvEmulatorCreateEmulator

関数
命令エミュレータのインスタンスを作成する。
DLLWinHvEmulation.dll呼出規約winapi

シグネチャ

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

HRESULT WHvEmulatorCreateEmulator(
    const WHV_EMULATOR_CALLBACKS* Callbacks,
    void** Emulator
);

パラメーター

名前方向説明
CallbacksWHV_EMULATOR_CALLBACKS*inメモリ/IOアクセスやレジスタ取得を行うコールバック関数群を記述した構造体へのポインタ。
Emulatorvoid**out作成された命令エミュレータのインスタンスハンドルを受け取る出力ポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvEmulatorCreateEmulator(
    const WHV_EMULATOR_CALLBACKS* Callbacks,
    void** Emulator
);
[DllImport("WinHvEmulation.dll", ExactSpelling = true)]
static extern int WHvEmulatorCreateEmulator(
    IntPtr Callbacks,   // WHV_EMULATOR_CALLBACKS*
    IntPtr Emulator   // void** out
);
<DllImport("WinHvEmulation.dll", ExactSpelling:=True)>
Public Shared Function WHvEmulatorCreateEmulator(
    Callbacks As IntPtr,   ' WHV_EMULATOR_CALLBACKS*
    Emulator As IntPtr   ' void** out
) As Integer
End Function
' Callbacks : WHV_EMULATOR_CALLBACKS*
' Emulator : void** out
Declare PtrSafe Function WHvEmulatorCreateEmulator Lib "winhvemulation" ( _
    ByVal Callbacks As LongPtr, _
    ByVal Emulator As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvEmulatorCreateEmulator = ctypes.windll.winhvemulation.WHvEmulatorCreateEmulator
WHvEmulatorCreateEmulator.restype = ctypes.c_int
WHvEmulatorCreateEmulator.argtypes = [
    ctypes.c_void_p,  # Callbacks : WHV_EMULATOR_CALLBACKS*
    ctypes.c_void_p,  # Emulator : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvEmulation.dll')
WHvEmulatorCreateEmulator = Fiddle::Function.new(
  lib['WHvEmulatorCreateEmulator'],
  [
    Fiddle::TYPE_VOIDP,  # Callbacks : WHV_EMULATOR_CALLBACKS*
    Fiddle::TYPE_VOIDP,  # Emulator : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvemulation")]
extern "system" {
    fn WHvEmulatorCreateEmulator(
        Callbacks: *const WHV_EMULATOR_CALLBACKS,  // WHV_EMULATOR_CALLBACKS*
        Emulator: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvEmulation.dll")]
public static extern int WHvEmulatorCreateEmulator(IntPtr Callbacks, IntPtr Emulator);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvEmulation_WHvEmulatorCreateEmulator' -Namespace Win32 -PassThru
# $api::WHvEmulatorCreateEmulator(Callbacks, Emulator)
#uselib "WinHvEmulation.dll"
#func global WHvEmulatorCreateEmulator "WHvEmulatorCreateEmulator" sptr, sptr
; WHvEmulatorCreateEmulator varptr(Callbacks), Emulator   ; 戻り値は stat
; Callbacks : WHV_EMULATOR_CALLBACKS* -> "sptr"
; Emulator : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinHvEmulation.dll"
#cfunc global WHvEmulatorCreateEmulator "WHvEmulatorCreateEmulator" var, sptr
; res = WHvEmulatorCreateEmulator(Callbacks, Emulator)
; Callbacks : WHV_EMULATOR_CALLBACKS* -> "var"
; Emulator : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WHvEmulatorCreateEmulator(WHV_EMULATOR_CALLBACKS* Callbacks, void** Emulator)
#uselib "WinHvEmulation.dll"
#cfunc global WHvEmulatorCreateEmulator "WHvEmulatorCreateEmulator" var, intptr
; res = WHvEmulatorCreateEmulator(Callbacks, Emulator)
; Callbacks : WHV_EMULATOR_CALLBACKS* -> "var"
; Emulator : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvemulation = windows.NewLazySystemDLL("WinHvEmulation.dll")
	procWHvEmulatorCreateEmulator = winhvemulation.NewProc("WHvEmulatorCreateEmulator")
)

// Callbacks (WHV_EMULATOR_CALLBACKS*), Emulator (void** out)
r1, _, err := procWHvEmulatorCreateEmulator.Call(
	uintptr(Callbacks),
	uintptr(Emulator),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WHvEmulatorCreateEmulator(
  Callbacks: Pointer;   // WHV_EMULATOR_CALLBACKS*
  Emulator: Pointer   // void** out
): Integer; stdcall;
  external 'WinHvEmulation.dll' name 'WHvEmulatorCreateEmulator';
result := DllCall("WinHvEmulation\WHvEmulatorCreateEmulator"
    , "Ptr", Callbacks   ; WHV_EMULATOR_CALLBACKS*
    , "Ptr", Emulator   ; void** out
    , "Int")   ; return: HRESULT
●WHvEmulatorCreateEmulator(Callbacks, Emulator) = DLL("WinHvEmulation.dll", "int WHvEmulatorCreateEmulator(void*, void*)")
# 呼び出し: WHvEmulatorCreateEmulator(Callbacks, Emulator)
# Callbacks : WHV_EMULATOR_CALLBACKS* -> "void*"
# Emulator : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winhvemulation" fn WHvEmulatorCreateEmulator(
    Callbacks: [*c]WHV_EMULATOR_CALLBACKS, // WHV_EMULATOR_CALLBACKS*
    Emulator: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
proc WHvEmulatorCreateEmulator(
    Callbacks: ptr WHV_EMULATOR_CALLBACKS,  # WHV_EMULATOR_CALLBACKS*
    Emulator: pointer  # void** out
): int32 {.importc: "WHvEmulatorCreateEmulator", stdcall, dynlib: "WinHvEmulation.dll".}
pragma(lib, "winhvemulation");
extern(Windows)
int WHvEmulatorCreateEmulator(
    WHV_EMULATOR_CALLBACKS* Callbacks,   // WHV_EMULATOR_CALLBACKS*
    void** Emulator   // void** out
);
ccall((:WHvEmulatorCreateEmulator, "WinHvEmulation.dll"), stdcall, Int32,
      (Ptr{WHV_EMULATOR_CALLBACKS}, Ptr{Cvoid}),
      Callbacks, Emulator)
# Callbacks : WHV_EMULATOR_CALLBACKS* -> Ptr{WHV_EMULATOR_CALLBACKS}
# Emulator : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvEmulatorCreateEmulator(
    void* Callbacks,
    void** Emulator);
]]
local winhvemulation = ffi.load("winhvemulation")
-- winhvemulation.WHvEmulatorCreateEmulator(Callbacks, Emulator)
-- Callbacks : WHV_EMULATOR_CALLBACKS*
-- Emulator : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvEmulation.dll');
const WHvEmulatorCreateEmulator = lib.func('__stdcall', 'WHvEmulatorCreateEmulator', 'int32_t', ['void *', 'void *']);
// WHvEmulatorCreateEmulator(Callbacks, Emulator)
// Callbacks : WHV_EMULATOR_CALLBACKS* -> 'void *'
// Emulator : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvEmulation.dll", {
  WHvEmulatorCreateEmulator: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.WHvEmulatorCreateEmulator(Callbacks, Emulator)
// Callbacks : WHV_EMULATOR_CALLBACKS* -> "pointer"
// Emulator : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvEmulatorCreateEmulator(
    void* Callbacks,
    void** Emulator);
C, "WinHvEmulation.dll");
// $ffi->WHvEmulatorCreateEmulator(Callbacks, Emulator);
// Callbacks : WHV_EMULATOR_CALLBACKS*
// Emulator : 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 Winhvemulation extends StdCallLibrary {
    Winhvemulation INSTANCE = Native.load("winhvemulation", Winhvemulation.class);
    int WHvEmulatorCreateEmulator(
        Pointer Callbacks,   // WHV_EMULATOR_CALLBACKS*
        Pointer Emulator   // void** out
    );
}
@[Link("winhvemulation")]
lib LibWinHvEmulation
  fun WHvEmulatorCreateEmulator = WHvEmulatorCreateEmulator(
    Callbacks : WHV_EMULATOR_CALLBACKS*,   # WHV_EMULATOR_CALLBACKS*
    Emulator : 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 WHvEmulatorCreateEmulatorNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef WHvEmulatorCreateEmulatorDart = int Function(Pointer<Void>, Pointer<Void>);
final WHvEmulatorCreateEmulator = DynamicLibrary.open('WinHvEmulation.dll')
    .lookupFunction<WHvEmulatorCreateEmulatorNative, WHvEmulatorCreateEmulatorDart>('WHvEmulatorCreateEmulator');
// Callbacks : WHV_EMULATOR_CALLBACKS* -> Pointer<Void>
// Emulator : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WHvEmulatorCreateEmulator(
  Callbacks: Pointer;   // WHV_EMULATOR_CALLBACKS*
  Emulator: Pointer   // void** out
): Integer; stdcall;
  external 'WinHvEmulation.dll' name 'WHvEmulatorCreateEmulator';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvEmulatorCreateEmulator"
  c_WHvEmulatorCreateEmulator :: Ptr () -> Ptr () -> IO Int32
-- Callbacks : WHV_EMULATOR_CALLBACKS* -> Ptr ()
-- Emulator : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvemulatorcreateemulator =
  foreign "WHvEmulatorCreateEmulator"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* Callbacks : WHV_EMULATOR_CALLBACKS* -> (ptr void) *)
(* Emulator : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhvemulation (t "WinHvEmulation.dll"))
(cffi:use-foreign-library winhvemulation)

(cffi:defcfun ("WHvEmulatorCreateEmulator" whv-emulator-create-emulator :convention :stdcall) :int32
  (callbacks :pointer)   ; WHV_EMULATOR_CALLBACKS*
  (emulator :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvEmulatorCreateEmulator = Win32::API::More->new('WinHvEmulation',
    'int WHvEmulatorCreateEmulator(LPVOID Callbacks, LPVOID Emulator)');
# my $ret = $WHvEmulatorCreateEmulator->Call($Callbacks, $Emulator);
# Callbacks : WHV_EMULATOR_CALLBACKS* -> LPVOID
# Emulator : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型