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

STORAGE_PHYSICAL_DEVICE_DATA

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

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

フィールド

フィールドサイズx64x86説明
DeviceIdDWORD4+0+0物理デバイスの識別番号。
RoleDWORD4+4+4デバイスの役割を示すビットマスク。キャッシュ/ティア等の用途を表す。
HealthStatusSTORAGE_COMPONENT_HEALTH_STATUS4+8+8デバイスの健全性状態を示すSTORAGE_COMPONENT_HEALTH_STATUS列挙値。
CommandProtocolSTORAGE_PROTOCOL_TYPE4+12+12デバイスが使用するコマンドプロトコルを示すSTORAGE_PROTOCOL_TYPE列挙値。
SpecVersionSTORAGE_SPEC_VERSION16/8+16+16デバイスが準拠する仕様バージョンを示すSTORAGE_SPEC_VERSION。
FormFactorSTORAGE_DEVICE_FORM_FACTOR4+32+24デバイスのフォームファクタを示すSTORAGE_DEVICE_FORM_FACTOR列挙値。
VendorBYTE8+36+28ベンダー名を示すバイト配列(文字列)。
ModelBYTE40+44+36モデル名を示すバイト配列(文字列)。
FirmwareRevisionBYTE16+84+76ファームウェアリビジョンを示すバイト配列(文字列)。
CapacityULONGLONG8+104+96デバイスの容量をバイト単位で示す。
PhysicalLocationBYTE32+112+104物理的な設置場所を示すバイト配列(文字列)。
ReservedDWORD8+144+136将来の拡張のために予約された32ビット領域の配列。

各言語での定義

#include <windows.h>

// STORAGE_SPEC_VERSION  (x64 16 / x86 8 バイト)
typedef struct STORAGE_SPEC_VERSION {
    _Anonymous_e__Struct Anonymous;
    DWORD AsUlong;
} STORAGE_SPEC_VERSION;

// STORAGE_PHYSICAL_DEVICE_DATA  (x64 152 / x86 144 バイト)
typedef struct STORAGE_PHYSICAL_DEVICE_DATA {
    DWORD DeviceId;
    DWORD Role;
    STORAGE_COMPONENT_HEALTH_STATUS HealthStatus;
    STORAGE_PROTOCOL_TYPE CommandProtocol;
    STORAGE_SPEC_VERSION SpecVersion;
    STORAGE_DEVICE_FORM_FACTOR FormFactor;
    BYTE Vendor[8];
    BYTE Model[40];
    BYTE FirmwareRevision[16];
    ULONGLONG Capacity;
    BYTE PhysicalLocation[32];
    DWORD Reserved[2];
} STORAGE_PHYSICAL_DEVICE_DATA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_SPEC_VERSION
{
    public _Anonymous_e__Struct Anonymous;
    public uint AsUlong;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_PHYSICAL_DEVICE_DATA
{
    public uint DeviceId;
    public uint Role;
    public int HealthStatus;
    public int CommandProtocol;
    public STORAGE_SPEC_VERSION SpecVersion;
    public int FormFactor;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] Vendor;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)] public byte[] Model;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] FirmwareRevision;
    public ulong Capacity;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] PhysicalLocation;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] Reserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_SPEC_VERSION
    Public Anonymous As _Anonymous_e__Struct
    Public AsUlong As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_PHYSICAL_DEVICE_DATA
    Public DeviceId As UInteger
    Public Role As UInteger
    Public HealthStatus As Integer
    Public CommandProtocol As Integer
    Public SpecVersion As STORAGE_SPEC_VERSION
    Public FormFactor As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public Vendor() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=40)> Public Model() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public FirmwareRevision() As Byte
    Public Capacity As ULong
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public PhysicalLocation() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Reserved() As UInteger
End Structure
import ctypes
from ctypes import wintypes

class STORAGE_SPEC_VERSION(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Struct),
        ("AsUlong", wintypes.DWORD),
    ]

class STORAGE_PHYSICAL_DEVICE_DATA(ctypes.Structure):
    _fields_ = [
        ("DeviceId", wintypes.DWORD),
        ("Role", wintypes.DWORD),
        ("HealthStatus", ctypes.c_int),
        ("CommandProtocol", ctypes.c_int),
        ("SpecVersion", STORAGE_SPEC_VERSION),
        ("FormFactor", ctypes.c_int),
        ("Vendor", ctypes.c_ubyte * 8),
        ("Model", ctypes.c_ubyte * 40),
        ("FirmwareRevision", ctypes.c_ubyte * 16),
        ("Capacity", ctypes.c_ulonglong),
        ("PhysicalLocation", ctypes.c_ubyte * 32),
        ("Reserved", wintypes.DWORD * 2),
    ]
#[repr(C)]
pub struct STORAGE_SPEC_VERSION {
    pub Anonymous: _Anonymous_e__Struct,
    pub AsUlong: u32,
}

#[repr(C)]
pub struct STORAGE_PHYSICAL_DEVICE_DATA {
    pub DeviceId: u32,
    pub Role: u32,
    pub HealthStatus: i32,
    pub CommandProtocol: i32,
    pub SpecVersion: STORAGE_SPEC_VERSION,
    pub FormFactor: i32,
    pub Vendor: [u8; 8],
    pub Model: [u8; 40],
    pub FirmwareRevision: [u8; 16],
    pub Capacity: u64,
    pub PhysicalLocation: [u8; 32],
    pub Reserved: [u32; 2],
}
import "golang.org/x/sys/windows"

type STORAGE_SPEC_VERSION struct {
	Anonymous _Anonymous_e__Struct
	AsUlong uint32
}

type STORAGE_PHYSICAL_DEVICE_DATA struct {
	DeviceId uint32
	Role uint32
	HealthStatus int32
	CommandProtocol int32
	SpecVersion STORAGE_SPEC_VERSION
	FormFactor int32
	Vendor [8]byte
	Model [40]byte
	FirmwareRevision [16]byte
	Capacity uint64
	PhysicalLocation [32]byte
	Reserved [2]uint32
}
type
  STORAGE_SPEC_VERSION = record
    Anonymous: _Anonymous_e__Struct;
    AsUlong: DWORD;
  end;

  STORAGE_PHYSICAL_DEVICE_DATA = record
    DeviceId: DWORD;
    Role: DWORD;
    HealthStatus: Integer;
    CommandProtocol: Integer;
    SpecVersion: STORAGE_SPEC_VERSION;
    FormFactor: Integer;
    Vendor: array[0..7] of Byte;
    Model: array[0..39] of Byte;
    FirmwareRevision: array[0..15] of Byte;
    Capacity: UInt64;
    PhysicalLocation: array[0..31] of Byte;
    Reserved: array[0..1] of DWORD;
  end;
const STORAGE_SPEC_VERSION = extern struct {
    Anonymous: _Anonymous_e__Struct,
    AsUlong: u32,
};

const STORAGE_PHYSICAL_DEVICE_DATA = extern struct {
    DeviceId: u32,
    Role: u32,
    HealthStatus: i32,
    CommandProtocol: i32,
    SpecVersion: STORAGE_SPEC_VERSION,
    FormFactor: i32,
    Vendor: [8]u8,
    Model: [40]u8,
    FirmwareRevision: [16]u8,
    Capacity: u64,
    PhysicalLocation: [32]u8,
    Reserved: [2]u32,
};
type
  STORAGE_SPEC_VERSION {.bycopy.} = object
    Anonymous: _Anonymous_e__Struct
    AsUlong: uint32

  STORAGE_PHYSICAL_DEVICE_DATA {.bycopy.} = object
    DeviceId: uint32
    Role: uint32
    HealthStatus: int32
    CommandProtocol: int32
    SpecVersion: STORAGE_SPEC_VERSION
    FormFactor: int32
    Vendor: array[8, uint8]
    Model: array[40, uint8]
    FirmwareRevision: array[16, uint8]
    Capacity: uint64
    PhysicalLocation: array[32, uint8]
    Reserved: array[2, uint32]
struct STORAGE_SPEC_VERSION
{
    _Anonymous_e__Struct Anonymous;
    uint AsUlong;
}

struct STORAGE_PHYSICAL_DEVICE_DATA
{
    uint DeviceId;
    uint Role;
    int HealthStatus;
    int CommandProtocol;
    STORAGE_SPEC_VERSION SpecVersion;
    int FormFactor;
    ubyte[8] Vendor;
    ubyte[40] Model;
    ubyte[16] FirmwareRevision;
    ulong Capacity;
    ubyte[32] PhysicalLocation;
    uint[2] Reserved;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; STORAGE_PHYSICAL_DEVICE_DATA サイズ: 144 バイト(x86)
dim st, 36    ; 4byte整数×36(構造体サイズ 144 / 4 切り上げ)
; DeviceId : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Role : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; HealthStatus : STORAGE_COMPONENT_HEALTH_STATUS (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; CommandProtocol : STORAGE_PROTOCOL_TYPE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; SpecVersion : STORAGE_SPEC_VERSION (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; FormFactor : STORAGE_DEVICE_FORM_FACTOR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; Vendor : BYTE (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; Model : BYTE (+36, 40byte)  varptr(st)+36 を基点に操作(40byte:入れ子/配列)
; FirmwareRevision : BYTE (+76, 16byte)  varptr(st)+76 を基点に操作(16byte:入れ子/配列)
; Capacity : ULONGLONG (+96, 8byte)  qpoke st,96,値 / qpeek(st,96)  ※IronHSPのみ。3.7/3.8は lpoke st,96,下位 : lpoke st,100,上位
; PhysicalLocation : BYTE (+104, 32byte)  varptr(st)+104 を基点に操作(32byte:入れ子/配列)
; Reserved : DWORD (+136, 8byte)  varptr(st)+136 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_PHYSICAL_DEVICE_DATA サイズ: 152 バイト(x64)
dim st, 38    ; 4byte整数×38(構造体サイズ 152 / 4 切り上げ)
; DeviceId : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Role : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; HealthStatus : STORAGE_COMPONENT_HEALTH_STATUS (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; CommandProtocol : STORAGE_PROTOCOL_TYPE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; SpecVersion : STORAGE_SPEC_VERSION (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; FormFactor : STORAGE_DEVICE_FORM_FACTOR (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; Vendor : BYTE (+36, 8byte)  varptr(st)+36 を基点に操作(8byte:入れ子/配列)
; Model : BYTE (+44, 40byte)  varptr(st)+44 を基点に操作(40byte:入れ子/配列)
; FirmwareRevision : BYTE (+84, 16byte)  varptr(st)+84 を基点に操作(16byte:入れ子/配列)
; Capacity : ULONGLONG (+104, 8byte)  qpoke st,104,値 / qpeek(st,104)  ※IronHSPのみ。3.7/3.8は lpoke st,104,下位 : lpoke st,108,上位
; PhysicalLocation : BYTE (+112, 32byte)  varptr(st)+112 を基点に操作(32byte:入れ子/配列)
; Reserved : DWORD (+144, 8byte)  varptr(st)+144 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global STORAGE_PHYSICAL_DEVICE_DATA
    #field int DeviceId
    #field int Role
    #field int HealthStatus
    #field int CommandProtocol
    #field byte SpecVersion 16
    #field int FormFactor
    #field byte Vendor 8
    #field byte Model 40
    #field byte FirmwareRevision 16
    #field int64 Capacity
    #field byte PhysicalLocation 32
    #field int Reserved 2
#endstruct

stdim st, STORAGE_PHYSICAL_DEVICE_DATA        ; NSTRUCT 変数を確保
st->DeviceId = 100
mes "DeviceId=" + st->DeviceId
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。