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

STORAGE_DEVICE_DESCRIPTOR

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

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号。
SizeDWORD4+4+4この構造体全体のサイズをバイト単位で示す。
DeviceTypeBYTE1+8+8SCSI規格のデバイスタイプコード(Peripheral Device Type)。
DeviceTypeModifierBYTE1+9+9SCSIデバイスタイプ修飾子。デバイスの細分類を示す。
RemovableMediaBOOLEAN1+10+10リムーバブルメディアを使用するかを示す真偽値。
CommandQueueingBOOLEAN1+11+11デバイスがコマンドキューイングをサポートするかを示す真偽値。
VendorIdOffsetDWORD4+12+12ベンダーID文字列の本構造体先頭からのバイトオフセット。0なら無し。
ProductIdOffsetDWORD4+16+16製品ID文字列の本構造体先頭からのバイトオフセット。0なら無し。
ProductRevisionOffsetDWORD4+20+20製品リビジョン文字列のバイトオフセット。0なら無し。
SerialNumberOffsetDWORD4+24+24シリアル番号文字列のバイトオフセット。0なら無し。
BusTypeSTORAGE_BUS_TYPE4+28+28デバイスが接続されるバスの種類を示すSTORAGE_BUS_TYPE列挙値。
RawPropertiesLengthDWORD4+32+32RawDeviceProperties領域のバイト長。
RawDevicePropertiesBYTE1+36+36ベンダー固有の生プロパティデータを格納する可変長バイト配列。

各言語での定義

#include <windows.h>

// STORAGE_DEVICE_DESCRIPTOR  (x64 40 / x86 40 バイト)
typedef struct STORAGE_DEVICE_DESCRIPTOR {
    DWORD Version;
    DWORD Size;
    BYTE DeviceType;
    BYTE DeviceTypeModifier;
    BOOLEAN RemovableMedia;
    BOOLEAN CommandQueueing;
    DWORD VendorIdOffset;
    DWORD ProductIdOffset;
    DWORD ProductRevisionOffset;
    DWORD SerialNumberOffset;
    STORAGE_BUS_TYPE BusType;
    DWORD RawPropertiesLength;
    BYTE RawDeviceProperties[1];
} STORAGE_DEVICE_DESCRIPTOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_DEVICE_DESCRIPTOR
{
    public uint Version;
    public uint Size;
    public byte DeviceType;
    public byte DeviceTypeModifier;
    [MarshalAs(UnmanagedType.U1)] public bool RemovableMedia;
    [MarshalAs(UnmanagedType.U1)] public bool CommandQueueing;
    public uint VendorIdOffset;
    public uint ProductIdOffset;
    public uint ProductRevisionOffset;
    public uint SerialNumberOffset;
    public int BusType;
    public uint RawPropertiesLength;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] RawDeviceProperties;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_DEVICE_DESCRIPTOR
    Public Version As UInteger
    Public Size As UInteger
    Public DeviceType As Byte
    Public DeviceTypeModifier As Byte
    <MarshalAs(UnmanagedType.U1)> Public RemovableMedia As Boolean
    <MarshalAs(UnmanagedType.U1)> Public CommandQueueing As Boolean
    Public VendorIdOffset As UInteger
    Public ProductIdOffset As UInteger
    Public ProductRevisionOffset As UInteger
    Public SerialNumberOffset As UInteger
    Public BusType As Integer
    Public RawPropertiesLength As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public RawDeviceProperties() As Byte
End Structure
import ctypes
from ctypes import wintypes

class STORAGE_DEVICE_DESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("DeviceType", ctypes.c_ubyte),
        ("DeviceTypeModifier", ctypes.c_ubyte),
        ("RemovableMedia", ctypes.c_byte),
        ("CommandQueueing", ctypes.c_byte),
        ("VendorIdOffset", wintypes.DWORD),
        ("ProductIdOffset", wintypes.DWORD),
        ("ProductRevisionOffset", wintypes.DWORD),
        ("SerialNumberOffset", wintypes.DWORD),
        ("BusType", ctypes.c_int),
        ("RawPropertiesLength", wintypes.DWORD),
        ("RawDeviceProperties", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct STORAGE_DEVICE_DESCRIPTOR {
    pub Version: u32,
    pub Size: u32,
    pub DeviceType: u8,
    pub DeviceTypeModifier: u8,
    pub RemovableMedia: u8,
    pub CommandQueueing: u8,
    pub VendorIdOffset: u32,
    pub ProductIdOffset: u32,
    pub ProductRevisionOffset: u32,
    pub SerialNumberOffset: u32,
    pub BusType: i32,
    pub RawPropertiesLength: u32,
    pub RawDeviceProperties: [u8; 1],
}
import "golang.org/x/sys/windows"

type STORAGE_DEVICE_DESCRIPTOR struct {
	Version uint32
	Size uint32
	DeviceType byte
	DeviceTypeModifier byte
	RemovableMedia byte
	CommandQueueing byte
	VendorIdOffset uint32
	ProductIdOffset uint32
	ProductRevisionOffset uint32
	SerialNumberOffset uint32
	BusType int32
	RawPropertiesLength uint32
	RawDeviceProperties [1]byte
}
type
  STORAGE_DEVICE_DESCRIPTOR = record
    Version: DWORD;
    Size: DWORD;
    DeviceType: Byte;
    DeviceTypeModifier: Byte;
    RemovableMedia: ByteBool;
    CommandQueueing: ByteBool;
    VendorIdOffset: DWORD;
    ProductIdOffset: DWORD;
    ProductRevisionOffset: DWORD;
    SerialNumberOffset: DWORD;
    BusType: Integer;
    RawPropertiesLength: DWORD;
    RawDeviceProperties: array[0..0] of Byte;
  end;
const STORAGE_DEVICE_DESCRIPTOR = extern struct {
    Version: u32,
    Size: u32,
    DeviceType: u8,
    DeviceTypeModifier: u8,
    RemovableMedia: u8,
    CommandQueueing: u8,
    VendorIdOffset: u32,
    ProductIdOffset: u32,
    ProductRevisionOffset: u32,
    SerialNumberOffset: u32,
    BusType: i32,
    RawPropertiesLength: u32,
    RawDeviceProperties: [1]u8,
};
type
  STORAGE_DEVICE_DESCRIPTOR {.bycopy.} = object
    Version: uint32
    Size: uint32
    DeviceType: uint8
    DeviceTypeModifier: uint8
    RemovableMedia: uint8
    CommandQueueing: uint8
    VendorIdOffset: uint32
    ProductIdOffset: uint32
    ProductRevisionOffset: uint32
    SerialNumberOffset: uint32
    BusType: int32
    RawPropertiesLength: uint32
    RawDeviceProperties: array[1, uint8]
struct STORAGE_DEVICE_DESCRIPTOR
{
    uint Version;
    uint Size;
    ubyte DeviceType;
    ubyte DeviceTypeModifier;
    ubyte RemovableMedia;
    ubyte CommandQueueing;
    uint VendorIdOffset;
    uint ProductIdOffset;
    uint ProductRevisionOffset;
    uint SerialNumberOffset;
    int BusType;
    uint RawPropertiesLength;
    ubyte[1] RawDeviceProperties;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_DEVICE_DESCRIPTOR サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; DeviceType : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; DeviceTypeModifier : BYTE (+9, 1byte)  poke st,9,値  /  値 = peek(st,9)
; RemovableMedia : BOOLEAN (+10, 1byte)  poke st,10,値  /  値 = peek(st,10)
; CommandQueueing : BOOLEAN (+11, 1byte)  poke st,11,値  /  値 = peek(st,11)
; VendorIdOffset : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ProductIdOffset : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ProductRevisionOffset : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; SerialNumberOffset : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; BusType : STORAGE_BUS_TYPE (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; RawPropertiesLength : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; RawDeviceProperties : BYTE (+36, 1byte)  varptr(st)+36 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global STORAGE_DEVICE_DESCRIPTOR
    #field int Version
    #field int Size
    #field byte DeviceType
    #field byte DeviceTypeModifier
    #field bool1 RemovableMedia
    #field bool1 CommandQueueing
    #field int VendorIdOffset
    #field int ProductIdOffset
    #field int ProductRevisionOffset
    #field int SerialNumberOffset
    #field int BusType
    #field int RawPropertiesLength
    #field byte RawDeviceProperties 1
#endstruct

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