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