ホーム › System.Hypervisor › ReadSavedStateGlobalVariable
ReadSavedStateGlobalVariable
関数保存状態のグローバル変数の値を読み取る。
シグネチャ
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT ReadSavedStateGlobalVariable(
void* vmSavedStateDumpHandle,
DWORD vpId,
LPCSTR globalName,
void* buffer,
DWORD bufferSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| vmSavedStateDumpHandle | void* | inout |
| vpId | DWORD | in |
| globalName | LPCSTR | in |
| buffer | void* | out |
| bufferSize | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT ReadSavedStateGlobalVariable(
void* vmSavedStateDumpHandle,
DWORD vpId,
LPCSTR globalName,
void* buffer,
DWORD bufferSize
);[DllImport("VmSavedStateDumpProvider.dll", ExactSpelling = true)]
static extern int ReadSavedStateGlobalVariable(
IntPtr vmSavedStateDumpHandle, // void* in/out
uint vpId, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string globalName, // LPCSTR
IntPtr buffer, // void* out
uint bufferSize // DWORD
);<DllImport("VmSavedStateDumpProvider.dll", ExactSpelling:=True)>
Public Shared Function ReadSavedStateGlobalVariable(
vmSavedStateDumpHandle As IntPtr, ' void* in/out
vpId As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> globalName As String, ' LPCSTR
buffer As IntPtr, ' void* out
bufferSize As UInteger ' DWORD
) As Integer
End Function' vmSavedStateDumpHandle : void* in/out
' vpId : DWORD
' globalName : LPCSTR
' buffer : void* out
' bufferSize : DWORD
Declare PtrSafe Function ReadSavedStateGlobalVariable Lib "vmsavedstatedumpprovider" ( _
ByVal vmSavedStateDumpHandle As LongPtr, _
ByVal vpId As Long, _
ByVal globalName As String, _
ByVal buffer As LongPtr, _
ByVal bufferSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ReadSavedStateGlobalVariable = ctypes.windll.vmsavedstatedumpprovider.ReadSavedStateGlobalVariable
ReadSavedStateGlobalVariable.restype = ctypes.c_int
ReadSavedStateGlobalVariable.argtypes = [
ctypes.POINTER(None), # vmSavedStateDumpHandle : void* in/out
wintypes.DWORD, # vpId : DWORD
wintypes.LPCSTR, # globalName : LPCSTR
ctypes.POINTER(None), # buffer : void* out
wintypes.DWORD, # bufferSize : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('VmSavedStateDumpProvider.dll')
ReadSavedStateGlobalVariable = Fiddle::Function.new(
lib['ReadSavedStateGlobalVariable'],
[
Fiddle::TYPE_VOIDP, # vmSavedStateDumpHandle : void* in/out
-Fiddle::TYPE_INT, # vpId : DWORD
Fiddle::TYPE_VOIDP, # globalName : LPCSTR
Fiddle::TYPE_VOIDP, # buffer : void* out
-Fiddle::TYPE_INT, # bufferSize : DWORD
],
Fiddle::TYPE_INT)#[link(name = "vmsavedstatedumpprovider")]
extern "system" {
fn ReadSavedStateGlobalVariable(
vmSavedStateDumpHandle: *mut (), // void* in/out
vpId: u32, // DWORD
globalName: *const u8, // LPCSTR
buffer: *mut (), // void* out
bufferSize: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("VmSavedStateDumpProvider.dll")]
public static extern int ReadSavedStateGlobalVariable(IntPtr vmSavedStateDumpHandle, uint vpId, [MarshalAs(UnmanagedType.LPStr)] string globalName, IntPtr buffer, uint bufferSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'VmSavedStateDumpProvider_ReadSavedStateGlobalVariable' -Namespace Win32 -PassThru
# $api::ReadSavedStateGlobalVariable(vmSavedStateDumpHandle, vpId, globalName, buffer, bufferSize)#uselib "VmSavedStateDumpProvider.dll"
#func global ReadSavedStateGlobalVariable "ReadSavedStateGlobalVariable" sptr, sptr, sptr, sptr, sptr
; ReadSavedStateGlobalVariable vmSavedStateDumpHandle, vpId, globalName, buffer, bufferSize ; 戻り値は stat
; vmSavedStateDumpHandle : void* in/out -> "sptr"
; vpId : DWORD -> "sptr"
; globalName : LPCSTR -> "sptr"
; buffer : void* out -> "sptr"
; bufferSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "VmSavedStateDumpProvider.dll"
#cfunc global ReadSavedStateGlobalVariable "ReadSavedStateGlobalVariable" sptr, int, str, sptr, int
; res = ReadSavedStateGlobalVariable(vmSavedStateDumpHandle, vpId, globalName, buffer, bufferSize)
; vmSavedStateDumpHandle : void* in/out -> "sptr"
; vpId : DWORD -> "int"
; globalName : LPCSTR -> "str"
; buffer : void* out -> "sptr"
; bufferSize : DWORD -> "int"; HRESULT ReadSavedStateGlobalVariable(void* vmSavedStateDumpHandle, DWORD vpId, LPCSTR globalName, void* buffer, DWORD bufferSize)
#uselib "VmSavedStateDumpProvider.dll"
#cfunc global ReadSavedStateGlobalVariable "ReadSavedStateGlobalVariable" intptr, int, str, intptr, int
; res = ReadSavedStateGlobalVariable(vmSavedStateDumpHandle, vpId, globalName, buffer, bufferSize)
; vmSavedStateDumpHandle : void* in/out -> "intptr"
; vpId : DWORD -> "int"
; globalName : LPCSTR -> "str"
; buffer : void* out -> "intptr"
; bufferSize : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
vmsavedstatedumpprovider = windows.NewLazySystemDLL("VmSavedStateDumpProvider.dll")
procReadSavedStateGlobalVariable = vmsavedstatedumpprovider.NewProc("ReadSavedStateGlobalVariable")
)
// vmSavedStateDumpHandle (void* in/out), vpId (DWORD), globalName (LPCSTR), buffer (void* out), bufferSize (DWORD)
r1, _, err := procReadSavedStateGlobalVariable.Call(
uintptr(vmSavedStateDumpHandle),
uintptr(vpId),
uintptr(unsafe.Pointer(windows.BytePtrFromString(globalName))),
uintptr(buffer),
uintptr(bufferSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ReadSavedStateGlobalVariable(
vmSavedStateDumpHandle: Pointer; // void* in/out
vpId: DWORD; // DWORD
globalName: PAnsiChar; // LPCSTR
buffer: Pointer; // void* out
bufferSize: DWORD // DWORD
): Integer; stdcall;
external 'VmSavedStateDumpProvider.dll' name 'ReadSavedStateGlobalVariable';result := DllCall("VmSavedStateDumpProvider\ReadSavedStateGlobalVariable"
, "Ptr", vmSavedStateDumpHandle ; void* in/out
, "UInt", vpId ; DWORD
, "AStr", globalName ; LPCSTR
, "Ptr", buffer ; void* out
, "UInt", bufferSize ; DWORD
, "Int") ; return: HRESULT●ReadSavedStateGlobalVariable(vmSavedStateDumpHandle, vpId, globalName, buffer, bufferSize) = DLL("VmSavedStateDumpProvider.dll", "int ReadSavedStateGlobalVariable(void*, dword, char*, void*, dword)")
# 呼び出し: ReadSavedStateGlobalVariable(vmSavedStateDumpHandle, vpId, globalName, buffer, bufferSize)
# vmSavedStateDumpHandle : void* in/out -> "void*"
# vpId : DWORD -> "dword"
# globalName : LPCSTR -> "char*"
# buffer : void* out -> "void*"
# bufferSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。