ホーム › System.SystemInformation › IsWow64GuestMachineSupported
IsWow64GuestMachineSupported
関数指定アーキテクチャのWOW64エミュレーション対応可否を調べる。
シグネチャ
// KERNEL32.dll
#include <windows.h>
HRESULT IsWow64GuestMachineSupported(
IMAGE_FILE_MACHINE WowGuestMachine,
BOOL* MachineIsSupported
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| WowGuestMachine | IMAGE_FILE_MACHINE | in | テスト対象のマシンを指定する IMAGE_FILE_MACHINE_* 値です。 |
| MachineIsSupported | BOOL* | out | 成功時に、マシンが WOW64 をサポートする場合は true、サポートしない場合は false を受け取る変数へのポインターです。 |
戻り値の型: HRESULT
公式ドキュメント
指定したマシンアーキテクチャ上で(WOW64 配下において)どのアーキテクチャがサポートされているかを判定します。
戻り値
成功した場合は S_OK を返します。それ以外の場合はエラーを返します。拡張エラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
IsWow64GuestMachineSupported は、次のシナリオを想定して設計されています。
- システムにインストールする必要があるデバッガー拡張機能を判別したいデバッガー(Visual Studio など)。
- WOW64 が無効になっているかどうかを判別する必要があるアプリ。たとえば、多くのアプリは x86-64 システムが常にどこでも x86-32 コードを実行できると想定しています。この機能は WinPE や Xbox には存在せず、Server ではオプションのコンポーネントである点に注意してください。
- システム内のサポートされているすべてのアーキテクチャでテストを実行し、機能を完全に網羅する必要があるテストスイート。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
HRESULT IsWow64GuestMachineSupported(
IMAGE_FILE_MACHINE WowGuestMachine,
BOOL* MachineIsSupported
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern int IsWow64GuestMachineSupported(
ushort WowGuestMachine, // IMAGE_FILE_MACHINE
out bool MachineIsSupported // BOOL* out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function IsWow64GuestMachineSupported(
WowGuestMachine As UShort, ' IMAGE_FILE_MACHINE
<Out> ByRef MachineIsSupported As Boolean ' BOOL* out
) As Integer
End Function' WowGuestMachine : IMAGE_FILE_MACHINE
' MachineIsSupported : BOOL* out
Declare PtrSafe Function IsWow64GuestMachineSupported Lib "kernel32" ( _
ByVal WowGuestMachine As Integer, _
ByRef MachineIsSupported As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsWow64GuestMachineSupported = ctypes.windll.kernel32.IsWow64GuestMachineSupported
IsWow64GuestMachineSupported.restype = ctypes.c_int
IsWow64GuestMachineSupported.argtypes = [
ctypes.c_ushort, # WowGuestMachine : IMAGE_FILE_MACHINE
ctypes.c_void_p, # MachineIsSupported : BOOL* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
IsWow64GuestMachineSupported = Fiddle::Function.new(
lib['IsWow64GuestMachineSupported'],
[
-Fiddle::TYPE_SHORT, # WowGuestMachine : IMAGE_FILE_MACHINE
Fiddle::TYPE_VOIDP, # MachineIsSupported : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn IsWow64GuestMachineSupported(
WowGuestMachine: u16, // IMAGE_FILE_MACHINE
MachineIsSupported: *mut i32 // BOOL* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern int IsWow64GuestMachineSupported(ushort WowGuestMachine, out bool MachineIsSupported);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsWow64GuestMachineSupported' -Namespace Win32 -PassThru
# $api::IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)#uselib "KERNEL32.dll"
#func global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" sptr, sptr
; IsWow64GuestMachineSupported WowGuestMachine, varptr(MachineIsSupported) ; 戻り値は stat
; WowGuestMachine : IMAGE_FILE_MACHINE -> "sptr"
; MachineIsSupported : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" int, var ; res = IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported) ; WowGuestMachine : IMAGE_FILE_MACHINE -> "int" ; MachineIsSupported : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" int, sptr ; res = IsWow64GuestMachineSupported(WowGuestMachine, varptr(MachineIsSupported)) ; WowGuestMachine : IMAGE_FILE_MACHINE -> "int" ; MachineIsSupported : BOOL* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT IsWow64GuestMachineSupported(IMAGE_FILE_MACHINE WowGuestMachine, BOOL* MachineIsSupported) #uselib "KERNEL32.dll" #cfunc global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" int, var ; res = IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported) ; WowGuestMachine : IMAGE_FILE_MACHINE -> "int" ; MachineIsSupported : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT IsWow64GuestMachineSupported(IMAGE_FILE_MACHINE WowGuestMachine, BOOL* MachineIsSupported) #uselib "KERNEL32.dll" #cfunc global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" int, intptr ; res = IsWow64GuestMachineSupported(WowGuestMachine, varptr(MachineIsSupported)) ; WowGuestMachine : IMAGE_FILE_MACHINE -> "int" ; MachineIsSupported : BOOL* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procIsWow64GuestMachineSupported = kernel32.NewProc("IsWow64GuestMachineSupported")
)
// WowGuestMachine (IMAGE_FILE_MACHINE), MachineIsSupported (BOOL* out)
r1, _, err := procIsWow64GuestMachineSupported.Call(
uintptr(WowGuestMachine),
uintptr(MachineIsSupported),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction IsWow64GuestMachineSupported(
WowGuestMachine: Word; // IMAGE_FILE_MACHINE
MachineIsSupported: Pointer // BOOL* out
): Integer; stdcall;
external 'KERNEL32.dll' name 'IsWow64GuestMachineSupported';result := DllCall("KERNEL32\IsWow64GuestMachineSupported"
, "UShort", WowGuestMachine ; IMAGE_FILE_MACHINE
, "Ptr", MachineIsSupported ; BOOL* out
, "Int") ; return: HRESULT●IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported) = DLL("KERNEL32.dll", "int IsWow64GuestMachineSupported(int, void*)")
# 呼び出し: IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
# WowGuestMachine : IMAGE_FILE_MACHINE -> "int"
# MachineIsSupported : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn IsWow64GuestMachineSupported(
WowGuestMachine: u16, // IMAGE_FILE_MACHINE
MachineIsSupported: [*c]i32 // BOOL* out
) callconv(std.os.windows.WINAPI) i32;proc IsWow64GuestMachineSupported(
WowGuestMachine: uint16, # IMAGE_FILE_MACHINE
MachineIsSupported: ptr int32 # BOOL* out
): int32 {.importc: "IsWow64GuestMachineSupported", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int IsWow64GuestMachineSupported(
ushort WowGuestMachine, // IMAGE_FILE_MACHINE
int* MachineIsSupported // BOOL* out
);ccall((:IsWow64GuestMachineSupported, "KERNEL32.dll"), stdcall, Int32,
(UInt16, Ptr{Int32}),
WowGuestMachine, MachineIsSupported)
# WowGuestMachine : IMAGE_FILE_MACHINE -> UInt16
# MachineIsSupported : BOOL* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IsWow64GuestMachineSupported(
uint16_t WowGuestMachine,
int32_t* MachineIsSupported);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
-- WowGuestMachine : IMAGE_FILE_MACHINE
-- MachineIsSupported : BOOL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const IsWow64GuestMachineSupported = lib.func('__stdcall', 'IsWow64GuestMachineSupported', 'int32_t', ['uint16_t', 'int32_t *']);
// IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
// WowGuestMachine : IMAGE_FILE_MACHINE -> 'uint16_t'
// MachineIsSupported : BOOL* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
IsWow64GuestMachineSupported: { parameters: ["u16", "pointer"], result: "i32" },
});
// lib.symbols.IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
// WowGuestMachine : IMAGE_FILE_MACHINE -> "u16"
// MachineIsSupported : BOOL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IsWow64GuestMachineSupported(
uint16_t WowGuestMachine,
int32_t* MachineIsSupported);
C, "KERNEL32.dll");
// $ffi->IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported);
// WowGuestMachine : IMAGE_FILE_MACHINE
// MachineIsSupported : BOOL* 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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
int IsWow64GuestMachineSupported(
short WowGuestMachine, // IMAGE_FILE_MACHINE
IntByReference MachineIsSupported // BOOL* out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun IsWow64GuestMachineSupported = IsWow64GuestMachineSupported(
WowGuestMachine : UInt16, # IMAGE_FILE_MACHINE
MachineIsSupported : Int32* # BOOL* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IsWow64GuestMachineSupportedNative = Int32 Function(Uint16, Pointer<Int32>);
typedef IsWow64GuestMachineSupportedDart = int Function(int, Pointer<Int32>);
final IsWow64GuestMachineSupported = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<IsWow64GuestMachineSupportedNative, IsWow64GuestMachineSupportedDart>('IsWow64GuestMachineSupported');
// WowGuestMachine : IMAGE_FILE_MACHINE -> Uint16
// MachineIsSupported : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IsWow64GuestMachineSupported(
WowGuestMachine: Word; // IMAGE_FILE_MACHINE
MachineIsSupported: Pointer // BOOL* out
): Integer; stdcall;
external 'KERNEL32.dll' name 'IsWow64GuestMachineSupported';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IsWow64GuestMachineSupported"
c_IsWow64GuestMachineSupported :: Word16 -> Ptr CInt -> IO Int32
-- WowGuestMachine : IMAGE_FILE_MACHINE -> Word16
-- MachineIsSupported : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let iswow64guestmachinesupported =
foreign "IsWow64GuestMachineSupported"
(uint16_t @-> (ptr int32_t) @-> returning int32_t)
(* WowGuestMachine : IMAGE_FILE_MACHINE -> uint16_t *)
(* MachineIsSupported : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("IsWow64GuestMachineSupported" is-wow64-guest-machine-supported :convention :stdcall) :int32
(wow-guest-machine :uint16) ; IMAGE_FILE_MACHINE
(machine-is-supported :pointer)) ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IsWow64GuestMachineSupported = Win32::API::More->new('KERNEL32',
'int IsWow64GuestMachineSupported(WORD WowGuestMachine, LPVOID MachineIsSupported)');
# my $ret = $IsWow64GuestMachineSupported->Call($WowGuestMachine, $MachineIsSupported);
# WowGuestMachine : IMAGE_FILE_MACHINE -> WORD
# MachineIsSupported : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型