Win32 API 日本語リファレンス
ホームSystem.Hypervisor › WHV_X64_CPUID_RESULT

WHV_X64_CPUID_RESULT

構造体
サイズx64: 32 バイト / x86: 32 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
FunctionDWORD4+0+0対象とするCPUID命令のリーフ番号(EAX入力値)を示す。
ReservedDWORD12+4+4予約フィールド。アライメント用で0とする。
EaxDWORD4+16+16CPUID命令の戻り値として設定するEAXレジスタ値である。
EbxDWORD4+20+20CPUID命令の戻り値として設定するEBXレジスタ値である。
EcxDWORD4+24+24CPUID命令の戻り値として設定するECXレジスタ値である。
EdxDWORD4+28+28CPUID命令の戻り値として設定するEDXレジスタ値である。

各言語での定義

#include <windows.h>

// WHV_X64_CPUID_RESULT  (x64 32 / x86 32 バイト)
typedef struct WHV_X64_CPUID_RESULT {
    DWORD Function;
    DWORD Reserved[3];
    DWORD Eax;
    DWORD Ebx;
    DWORD Ecx;
    DWORD Edx;
} WHV_X64_CPUID_RESULT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WHV_X64_CPUID_RESULT
{
    public uint Function;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] Reserved;
    public uint Eax;
    public uint Ebx;
    public uint Ecx;
    public uint Edx;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WHV_X64_CPUID_RESULT
    Public Function As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved() As UInteger
    Public Eax As UInteger
    Public Ebx As UInteger
    Public Ecx As UInteger
    Public Edx As UInteger
End Structure
import ctypes
from ctypes import wintypes

class WHV_X64_CPUID_RESULT(ctypes.Structure):
    _fields_ = [
        ("Function", wintypes.DWORD),
        ("Reserved", wintypes.DWORD * 3),
        ("Eax", wintypes.DWORD),
        ("Ebx", wintypes.DWORD),
        ("Ecx", wintypes.DWORD),
        ("Edx", wintypes.DWORD),
    ]
#[repr(C)]
pub struct WHV_X64_CPUID_RESULT {
    pub Function: u32,
    pub Reserved: [u32; 3],
    pub Eax: u32,
    pub Ebx: u32,
    pub Ecx: u32,
    pub Edx: u32,
}
import "golang.org/x/sys/windows"

type WHV_X64_CPUID_RESULT struct {
	Function uint32
	Reserved [3]uint32
	Eax uint32
	Ebx uint32
	Ecx uint32
	Edx uint32
}
type
  WHV_X64_CPUID_RESULT = record
    Function: DWORD;
    Reserved: array[0..2] of DWORD;
    Eax: DWORD;
    Ebx: DWORD;
    Ecx: DWORD;
    Edx: DWORD;
  end;
const WHV_X64_CPUID_RESULT = extern struct {
    Function: u32,
    Reserved: [3]u32,
    Eax: u32,
    Ebx: u32,
    Ecx: u32,
    Edx: u32,
};
type
  WHV_X64_CPUID_RESULT {.bycopy.} = object
    Function: uint32
    Reserved: array[3, uint32]
    Eax: uint32
    Ebx: uint32
    Ecx: uint32
    Edx: uint32
struct WHV_X64_CPUID_RESULT
{
    uint Function;
    uint[3] Reserved;
    uint Eax;
    uint Ebx;
    uint Ecx;
    uint Edx;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WHV_X64_CPUID_RESULT サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Function : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Reserved : DWORD (+4, 12byte)  varptr(st)+4 を基点に操作(12byte:入れ子/配列)
; Eax : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Ebx : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; Ecx : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; Edx : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WHV_X64_CPUID_RESULT
    #field int Function
    #field int Reserved 3
    #field int Eax
    #field int Ebx
    #field int Ecx
    #field int Edx
#endstruct

stdim st, WHV_X64_CPUID_RESULT        ; NSTRUCT 変数を確保
st->Function = 100
mes "Function=" + st->Function