ホーム › System.Hypervisor › ForceArchitecture
ForceArchitecture
関数指定仮想プロセッサのアーキテクチャを強制設定する。
シグネチャ
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT ForceArchitecture(
void* vmSavedStateDumpHandle,
DWORD vpId,
VIRTUAL_PROCESSOR_ARCH architecture
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| vmSavedStateDumpHandle | void* | inout | 対象の保存状態ダンプハンドルを指定する。 |
| vpId | DWORD | in | 対象とする仮想プロセッサのID(インデックス)を指定する。 |
| architecture | VIRTUAL_PROCESSOR_ARCH | in | 強制的に設定する仮想プロセッサのアーキテクチャ種別の列挙値を指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT ForceArchitecture(
void* vmSavedStateDumpHandle,
DWORD vpId,
VIRTUAL_PROCESSOR_ARCH architecture
);[DllImport("VmSavedStateDumpProvider.dll", ExactSpelling = true)]
static extern int ForceArchitecture(
IntPtr vmSavedStateDumpHandle, // void* in/out
uint vpId, // DWORD
int architecture // VIRTUAL_PROCESSOR_ARCH
);<DllImport("VmSavedStateDumpProvider.dll", ExactSpelling:=True)>
Public Shared Function ForceArchitecture(
vmSavedStateDumpHandle As IntPtr, ' void* in/out
vpId As UInteger, ' DWORD
architecture As Integer ' VIRTUAL_PROCESSOR_ARCH
) As Integer
End Function' vmSavedStateDumpHandle : void* in/out
' vpId : DWORD
' architecture : VIRTUAL_PROCESSOR_ARCH
Declare PtrSafe Function ForceArchitecture Lib "vmsavedstatedumpprovider" ( _
ByVal vmSavedStateDumpHandle As LongPtr, _
ByVal vpId As Long, _
ByVal architecture As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ForceArchitecture = ctypes.windll.vmsavedstatedumpprovider.ForceArchitecture
ForceArchitecture.restype = ctypes.c_int
ForceArchitecture.argtypes = [
ctypes.POINTER(None), # vmSavedStateDumpHandle : void* in/out
wintypes.DWORD, # vpId : DWORD
ctypes.c_int, # architecture : VIRTUAL_PROCESSOR_ARCH
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('VmSavedStateDumpProvider.dll')
ForceArchitecture = Fiddle::Function.new(
lib['ForceArchitecture'],
[
Fiddle::TYPE_VOIDP, # vmSavedStateDumpHandle : void* in/out
-Fiddle::TYPE_INT, # vpId : DWORD
Fiddle::TYPE_INT, # architecture : VIRTUAL_PROCESSOR_ARCH
],
Fiddle::TYPE_INT)#[link(name = "vmsavedstatedumpprovider")]
extern "system" {
fn ForceArchitecture(
vmSavedStateDumpHandle: *mut (), // void* in/out
vpId: u32, // DWORD
architecture: i32 // VIRTUAL_PROCESSOR_ARCH
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("VmSavedStateDumpProvider.dll")]
public static extern int ForceArchitecture(IntPtr vmSavedStateDumpHandle, uint vpId, int architecture);
"@
$api = Add-Type -MemberDefinition $sig -Name 'VmSavedStateDumpProvider_ForceArchitecture' -Namespace Win32 -PassThru
# $api::ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)#uselib "VmSavedStateDumpProvider.dll"
#func global ForceArchitecture "ForceArchitecture" sptr, sptr, sptr
; ForceArchitecture vmSavedStateDumpHandle, vpId, architecture ; 戻り値は stat
; vmSavedStateDumpHandle : void* in/out -> "sptr"
; vpId : DWORD -> "sptr"
; architecture : VIRTUAL_PROCESSOR_ARCH -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "VmSavedStateDumpProvider.dll"
#cfunc global ForceArchitecture "ForceArchitecture" sptr, int, int
; res = ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)
; vmSavedStateDumpHandle : void* in/out -> "sptr"
; vpId : DWORD -> "int"
; architecture : VIRTUAL_PROCESSOR_ARCH -> "int"; HRESULT ForceArchitecture(void* vmSavedStateDumpHandle, DWORD vpId, VIRTUAL_PROCESSOR_ARCH architecture)
#uselib "VmSavedStateDumpProvider.dll"
#cfunc global ForceArchitecture "ForceArchitecture" intptr, int, int
; res = ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)
; vmSavedStateDumpHandle : void* in/out -> "intptr"
; vpId : DWORD -> "int"
; architecture : VIRTUAL_PROCESSOR_ARCH -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
vmsavedstatedumpprovider = windows.NewLazySystemDLL("VmSavedStateDumpProvider.dll")
procForceArchitecture = vmsavedstatedumpprovider.NewProc("ForceArchitecture")
)
// vmSavedStateDumpHandle (void* in/out), vpId (DWORD), architecture (VIRTUAL_PROCESSOR_ARCH)
r1, _, err := procForceArchitecture.Call(
uintptr(vmSavedStateDumpHandle),
uintptr(vpId),
uintptr(architecture),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ForceArchitecture(
vmSavedStateDumpHandle: Pointer; // void* in/out
vpId: DWORD; // DWORD
architecture: Integer // VIRTUAL_PROCESSOR_ARCH
): Integer; stdcall;
external 'VmSavedStateDumpProvider.dll' name 'ForceArchitecture';result := DllCall("VmSavedStateDumpProvider\ForceArchitecture"
, "Ptr", vmSavedStateDumpHandle ; void* in/out
, "UInt", vpId ; DWORD
, "Int", architecture ; VIRTUAL_PROCESSOR_ARCH
, "Int") ; return: HRESULT●ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture) = DLL("VmSavedStateDumpProvider.dll", "int ForceArchitecture(void*, dword, int)")
# 呼び出し: ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)
# vmSavedStateDumpHandle : void* in/out -> "void*"
# vpId : DWORD -> "dword"
# architecture : VIRTUAL_PROCESSOR_ARCH -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "vmsavedstatedumpprovider" fn ForceArchitecture(
vmSavedStateDumpHandle: ?*anyopaque, // void* in/out
vpId: u32, // DWORD
architecture: i32 // VIRTUAL_PROCESSOR_ARCH
) callconv(std.os.windows.WINAPI) i32;proc ForceArchitecture(
vmSavedStateDumpHandle: pointer, # void* in/out
vpId: uint32, # DWORD
architecture: int32 # VIRTUAL_PROCESSOR_ARCH
): int32 {.importc: "ForceArchitecture", stdcall, dynlib: "VmSavedStateDumpProvider.dll".}pragma(lib, "vmsavedstatedumpprovider");
extern(Windows)
int ForceArchitecture(
void* vmSavedStateDumpHandle, // void* in/out
uint vpId, // DWORD
int architecture // VIRTUAL_PROCESSOR_ARCH
);ccall((:ForceArchitecture, "VmSavedStateDumpProvider.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Int32),
vmSavedStateDumpHandle, vpId, architecture)
# vmSavedStateDumpHandle : void* in/out -> Ptr{Cvoid}
# vpId : DWORD -> UInt32
# architecture : VIRTUAL_PROCESSOR_ARCH -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ForceArchitecture(
void* vmSavedStateDumpHandle,
uint32_t vpId,
int32_t architecture);
]]
local vmsavedstatedumpprovider = ffi.load("vmsavedstatedumpprovider")
-- vmsavedstatedumpprovider.ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)
-- vmSavedStateDumpHandle : void* in/out
-- vpId : DWORD
-- architecture : VIRTUAL_PROCESSOR_ARCH
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('VmSavedStateDumpProvider.dll');
const ForceArchitecture = lib.func('__stdcall', 'ForceArchitecture', 'int32_t', ['void *', 'uint32_t', 'int32_t']);
// ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)
// vmSavedStateDumpHandle : void* in/out -> 'void *'
// vpId : DWORD -> 'uint32_t'
// architecture : VIRTUAL_PROCESSOR_ARCH -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("VmSavedStateDumpProvider.dll", {
ForceArchitecture: { parameters: ["pointer", "u32", "i32"], result: "i32" },
});
// lib.symbols.ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture)
// vmSavedStateDumpHandle : void* in/out -> "pointer"
// vpId : DWORD -> "u32"
// architecture : VIRTUAL_PROCESSOR_ARCH -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ForceArchitecture(
void* vmSavedStateDumpHandle,
uint32_t vpId,
int32_t architecture);
C, "VmSavedStateDumpProvider.dll");
// $ffi->ForceArchitecture(vmSavedStateDumpHandle, vpId, architecture);
// vmSavedStateDumpHandle : void* in/out
// vpId : DWORD
// architecture : VIRTUAL_PROCESSOR_ARCH
// 構造体/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 ForceArchitecture(
Pointer vmSavedStateDumpHandle, // void* in/out
int vpId, // DWORD
int architecture // VIRTUAL_PROCESSOR_ARCH
);
}@[Link("vmsavedstatedumpprovider")]
lib LibVmSavedStateDumpProvider
fun ForceArchitecture = ForceArchitecture(
vmSavedStateDumpHandle : Void*, # void* in/out
vpId : UInt32, # DWORD
architecture : Int32 # VIRTUAL_PROCESSOR_ARCH
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ForceArchitectureNative = Int32 Function(Pointer<Void>, Uint32, Int32);
typedef ForceArchitectureDart = int Function(Pointer<Void>, int, int);
final ForceArchitecture = DynamicLibrary.open('VmSavedStateDumpProvider.dll')
.lookupFunction<ForceArchitectureNative, ForceArchitectureDart>('ForceArchitecture');
// vmSavedStateDumpHandle : void* in/out -> Pointer<Void>
// vpId : DWORD -> Uint32
// architecture : VIRTUAL_PROCESSOR_ARCH -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ForceArchitecture(
vmSavedStateDumpHandle: Pointer; // void* in/out
vpId: DWORD; // DWORD
architecture: Integer // VIRTUAL_PROCESSOR_ARCH
): Integer; stdcall;
external 'VmSavedStateDumpProvider.dll' name 'ForceArchitecture';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ForceArchitecture"
c_ForceArchitecture :: Ptr () -> Word32 -> Int32 -> IO Int32
-- vmSavedStateDumpHandle : void* in/out -> Ptr ()
-- vpId : DWORD -> Word32
-- architecture : VIRTUAL_PROCESSOR_ARCH -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let forcearchitecture =
foreign "ForceArchitecture"
((ptr void) @-> uint32_t @-> int32_t @-> returning int32_t)
(* vmSavedStateDumpHandle : void* in/out -> (ptr void) *)
(* vpId : DWORD -> uint32_t *)
(* architecture : VIRTUAL_PROCESSOR_ARCH -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library vmsavedstatedumpprovider (t "VmSavedStateDumpProvider.dll"))
(cffi:use-foreign-library vmsavedstatedumpprovider)
(cffi:defcfun ("ForceArchitecture" force-architecture :convention :stdcall) :int32
(vm-saved-state-dump-handle :pointer) ; void* in/out
(vp-id :uint32) ; DWORD
(architecture :int32)) ; VIRTUAL_PROCESSOR_ARCH
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ForceArchitecture = Win32::API::More->new('VmSavedStateDumpProvider',
'int ForceArchitecture(LPVOID vmSavedStateDumpHandle, DWORD vpId, int architecture)');
# my $ret = $ForceArchitecture->Call($vmSavedStateDumpHandle, $vpId, $architecture);
# vmSavedStateDumpHandle : void* in/out -> LPVOID
# vpId : DWORD -> DWORD
# architecture : VIRTUAL_PROCESSOR_ARCH -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。