ホーム › System.Hypervisor › LoadSavedStateFiles
LoadSavedStateFiles
関数BINとVSV保存状態ファイルを読み込んでハンドルを取得する。
シグネチャ
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT LoadSavedStateFiles(
LPCWSTR binFile,
LPCWSTR vsvFile,
void** vmSavedStateDumpHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| binFile | LPCWSTR | in | 読み込む保存状態のbinファイル(メモリ内容)のパスを指定する文字列。 |
| vsvFile | LPCWSTR | in | 読み込む保存状態のvsvファイル(デバイス/VP状態)のパスを指定する文字列。 |
| vmSavedStateDumpHandle | void** | out | 読み込んだ保存状態ダンプを表すハンドルを受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT LoadSavedStateFiles(
LPCWSTR binFile,
LPCWSTR vsvFile,
void** vmSavedStateDumpHandle
);[DllImport("VmSavedStateDumpProvider.dll", ExactSpelling = true)]
static extern int LoadSavedStateFiles(
[MarshalAs(UnmanagedType.LPWStr)] string binFile, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string vsvFile, // LPCWSTR
IntPtr vmSavedStateDumpHandle // void** out
);<DllImport("VmSavedStateDumpProvider.dll", ExactSpelling:=True)>
Public Shared Function LoadSavedStateFiles(
<MarshalAs(UnmanagedType.LPWStr)> binFile As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> vsvFile As String, ' LPCWSTR
vmSavedStateDumpHandle As IntPtr ' void** out
) As Integer
End Function' binFile : LPCWSTR
' vsvFile : LPCWSTR
' vmSavedStateDumpHandle : void** out
Declare PtrSafe Function LoadSavedStateFiles Lib "vmsavedstatedumpprovider" ( _
ByVal binFile As LongPtr, _
ByVal vsvFile As LongPtr, _
ByVal vmSavedStateDumpHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LoadSavedStateFiles = ctypes.windll.vmsavedstatedumpprovider.LoadSavedStateFiles
LoadSavedStateFiles.restype = ctypes.c_int
LoadSavedStateFiles.argtypes = [
wintypes.LPCWSTR, # binFile : LPCWSTR
wintypes.LPCWSTR, # vsvFile : LPCWSTR
ctypes.c_void_p, # vmSavedStateDumpHandle : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('VmSavedStateDumpProvider.dll')
LoadSavedStateFiles = Fiddle::Function.new(
lib['LoadSavedStateFiles'],
[
Fiddle::TYPE_VOIDP, # binFile : LPCWSTR
Fiddle::TYPE_VOIDP, # vsvFile : LPCWSTR
Fiddle::TYPE_VOIDP, # vmSavedStateDumpHandle : void** out
],
Fiddle::TYPE_INT)#[link(name = "vmsavedstatedumpprovider")]
extern "system" {
fn LoadSavedStateFiles(
binFile: *const u16, // LPCWSTR
vsvFile: *const u16, // LPCWSTR
vmSavedStateDumpHandle: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("VmSavedStateDumpProvider.dll")]
public static extern int LoadSavedStateFiles([MarshalAs(UnmanagedType.LPWStr)] string binFile, [MarshalAs(UnmanagedType.LPWStr)] string vsvFile, IntPtr vmSavedStateDumpHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'VmSavedStateDumpProvider_LoadSavedStateFiles' -Namespace Win32 -PassThru
# $api::LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)#uselib "VmSavedStateDumpProvider.dll"
#func global LoadSavedStateFiles "LoadSavedStateFiles" sptr, sptr, sptr
; LoadSavedStateFiles binFile, vsvFile, vmSavedStateDumpHandle ; 戻り値は stat
; binFile : LPCWSTR -> "sptr"
; vsvFile : LPCWSTR -> "sptr"
; vmSavedStateDumpHandle : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "VmSavedStateDumpProvider.dll"
#cfunc global LoadSavedStateFiles "LoadSavedStateFiles" wstr, wstr, sptr
; res = LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)
; binFile : LPCWSTR -> "wstr"
; vsvFile : LPCWSTR -> "wstr"
; vmSavedStateDumpHandle : void** out -> "sptr"; HRESULT LoadSavedStateFiles(LPCWSTR binFile, LPCWSTR vsvFile, void** vmSavedStateDumpHandle)
#uselib "VmSavedStateDumpProvider.dll"
#cfunc global LoadSavedStateFiles "LoadSavedStateFiles" wstr, wstr, intptr
; res = LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)
; binFile : LPCWSTR -> "wstr"
; vsvFile : LPCWSTR -> "wstr"
; vmSavedStateDumpHandle : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
vmsavedstatedumpprovider = windows.NewLazySystemDLL("VmSavedStateDumpProvider.dll")
procLoadSavedStateFiles = vmsavedstatedumpprovider.NewProc("LoadSavedStateFiles")
)
// binFile (LPCWSTR), vsvFile (LPCWSTR), vmSavedStateDumpHandle (void** out)
r1, _, err := procLoadSavedStateFiles.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(binFile))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(vsvFile))),
uintptr(vmSavedStateDumpHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction LoadSavedStateFiles(
binFile: PWideChar; // LPCWSTR
vsvFile: PWideChar; // LPCWSTR
vmSavedStateDumpHandle: Pointer // void** out
): Integer; stdcall;
external 'VmSavedStateDumpProvider.dll' name 'LoadSavedStateFiles';result := DllCall("VmSavedStateDumpProvider\LoadSavedStateFiles"
, "WStr", binFile ; LPCWSTR
, "WStr", vsvFile ; LPCWSTR
, "Ptr", vmSavedStateDumpHandle ; void** out
, "Int") ; return: HRESULT●LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle) = DLL("VmSavedStateDumpProvider.dll", "int LoadSavedStateFiles(char*, char*, void*)")
# 呼び出し: LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)
# binFile : LPCWSTR -> "char*"
# vsvFile : LPCWSTR -> "char*"
# vmSavedStateDumpHandle : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "vmsavedstatedumpprovider" fn LoadSavedStateFiles(
binFile: [*c]const u16, // LPCWSTR
vsvFile: [*c]const u16, // LPCWSTR
vmSavedStateDumpHandle: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc LoadSavedStateFiles(
binFile: WideCString, # LPCWSTR
vsvFile: WideCString, # LPCWSTR
vmSavedStateDumpHandle: pointer # void** out
): int32 {.importc: "LoadSavedStateFiles", stdcall, dynlib: "VmSavedStateDumpProvider.dll".}pragma(lib, "vmsavedstatedumpprovider");
extern(Windows)
int LoadSavedStateFiles(
const(wchar)* binFile, // LPCWSTR
const(wchar)* vsvFile, // LPCWSTR
void** vmSavedStateDumpHandle // void** out
);ccall((:LoadSavedStateFiles, "VmSavedStateDumpProvider.dll"), stdcall, Int32,
(Cwstring, Cwstring, Ptr{Cvoid}),
binFile, vsvFile, vmSavedStateDumpHandle)
# binFile : LPCWSTR -> Cwstring
# vsvFile : LPCWSTR -> Cwstring
# vmSavedStateDumpHandle : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t LoadSavedStateFiles(
const uint16_t* binFile,
const uint16_t* vsvFile,
void** vmSavedStateDumpHandle);
]]
local vmsavedstatedumpprovider = ffi.load("vmsavedstatedumpprovider")
-- vmsavedstatedumpprovider.LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)
-- binFile : LPCWSTR
-- vsvFile : LPCWSTR
-- vmSavedStateDumpHandle : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('VmSavedStateDumpProvider.dll');
const LoadSavedStateFiles = lib.func('__stdcall', 'LoadSavedStateFiles', 'int32_t', ['str16', 'str16', 'void *']);
// LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)
// binFile : LPCWSTR -> 'str16'
// vsvFile : LPCWSTR -> 'str16'
// vmSavedStateDumpHandle : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("VmSavedStateDumpProvider.dll", {
LoadSavedStateFiles: { parameters: ["buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle)
// binFile : LPCWSTR -> "buffer"
// vsvFile : LPCWSTR -> "buffer"
// vmSavedStateDumpHandle : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t LoadSavedStateFiles(
const uint16_t* binFile,
const uint16_t* vsvFile,
void** vmSavedStateDumpHandle);
C, "VmSavedStateDumpProvider.dll");
// $ffi->LoadSavedStateFiles(binFile, vsvFile, vmSavedStateDumpHandle);
// binFile : LPCWSTR
// vsvFile : LPCWSTR
// vmSavedStateDumpHandle : 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 Vmsavedstatedumpprovider extends StdCallLibrary {
Vmsavedstatedumpprovider INSTANCE = Native.load("vmsavedstatedumpprovider", Vmsavedstatedumpprovider.class);
int LoadSavedStateFiles(
WString binFile, // LPCWSTR
WString vsvFile, // LPCWSTR
Pointer vmSavedStateDumpHandle // void** out
);
}@[Link("vmsavedstatedumpprovider")]
lib LibVmSavedStateDumpProvider
fun LoadSavedStateFiles = LoadSavedStateFiles(
binFile : UInt16*, # LPCWSTR
vsvFile : UInt16*, # LPCWSTR
vmSavedStateDumpHandle : 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 LoadSavedStateFilesNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
typedef LoadSavedStateFilesDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
final LoadSavedStateFiles = DynamicLibrary.open('VmSavedStateDumpProvider.dll')
.lookupFunction<LoadSavedStateFilesNative, LoadSavedStateFilesDart>('LoadSavedStateFiles');
// binFile : LPCWSTR -> Pointer<Utf16>
// vsvFile : LPCWSTR -> Pointer<Utf16>
// vmSavedStateDumpHandle : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function LoadSavedStateFiles(
binFile: PWideChar; // LPCWSTR
vsvFile: PWideChar; // LPCWSTR
vmSavedStateDumpHandle: Pointer // void** out
): Integer; stdcall;
external 'VmSavedStateDumpProvider.dll' name 'LoadSavedStateFiles';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "LoadSavedStateFiles"
c_LoadSavedStateFiles :: CWString -> CWString -> Ptr () -> IO Int32
-- binFile : LPCWSTR -> CWString
-- vsvFile : LPCWSTR -> CWString
-- vmSavedStateDumpHandle : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let loadsavedstatefiles =
foreign "LoadSavedStateFiles"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* binFile : LPCWSTR -> (ptr uint16_t) *)
(* vsvFile : LPCWSTR -> (ptr uint16_t) *)
(* vmSavedStateDumpHandle : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library vmsavedstatedumpprovider (t "VmSavedStateDumpProvider.dll"))
(cffi:use-foreign-library vmsavedstatedumpprovider)
(cffi:defcfun ("LoadSavedStateFiles" load-saved-state-files :convention :stdcall) :int32
(bin-file (:string :encoding :utf-16le)) ; LPCWSTR
(vsv-file (:string :encoding :utf-16le)) ; LPCWSTR
(vm-saved-state-dump-handle :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $LoadSavedStateFiles = Win32::API::More->new('VmSavedStateDumpProvider',
'int LoadSavedStateFiles(LPCWSTR binFile, LPCWSTR vsvFile, LPVOID vmSavedStateDumpHandle)');
# my $ret = $LoadSavedStateFiles->Call($binFile, $vsvFile, $vmSavedStateDumpHandle);
# binFile : LPCWSTR -> LPCWSTR
# vsvFile : LPCWSTR -> LPCWSTR
# vmSavedStateDumpHandle : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。