Win32 API 日本語リファレンス
ホームDevices.Usb › USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR

USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR

構造体
サイズx64: 26 バイト / x86: 18 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
bLengthBYTE1+0+0このディスクリプタのサイズをバイト単位で示す。
bDescriptorTypeBYTE1+1+1ディスクリプタ種別。デバイス能力ディスクリプタ。
bDevCapabilityTypeBYTE1+2+2能力種別。SuperSpeedPlus USBを示す。
bReservedBYTE1+3+3予約フィールド。0でなければならない。
bmAttributes_bmAttributes_e__Union8/4+4+4サブリンク速度属性数等を含む属性を保持する無名共用体。
wFunctionalitySupport_wFunctionalitySupport_e__Union8/4+12+8最低限の機能性をサポートする速度情報を保持する無名共用体。
wReservedWORD2+20+12予約フィールド。0でなければならない。
bmSublinkSpeedAttrUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED4+22+14各サブリンク速度属性の可変長配列。

共用体: _bmAttributes_e__Union x64 8B / x86 4B

フィールドサイズx64x86
AsUlongDWORD4+0+0
Anonymous_Anonymous_e__Struct8/4+0+0

共用体: _wFunctionalitySupport_e__Union x64 8B / x86 4B

フィールドサイズx64x86
AsUshortWORD2+0+0
Anonymous_Anonymous_e__Struct8/4+0+0

各言語での定義

#include <windows.h>

// USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED  (x64 4 / x86 4 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED {
    DWORD AsUlong32;
    _Anonymous_e__Struct Anonymous;
} USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED;
#pragma pack(pop)

// USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR  (x64 26 / x86 18 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR {
    BYTE bLength;
    BYTE bDescriptorType;
    BYTE bDevCapabilityType;
    BYTE bReserved;
    _bmAttributes_e__Union bmAttributes;
    _wFunctionalitySupport_e__Union wFunctionalitySupport;
    WORD wReserved;
    USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED bmSublinkSpeedAttr[1];
} USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
{
    public uint AsUlong32;
    public _Anonymous_e__Struct Anonymous;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR
{
    public byte bLength;
    public byte bDescriptorType;
    public byte bDevCapabilityType;
    public byte bReserved;
    public _bmAttributes_e__Union bmAttributes;
    public _wFunctionalitySupport_e__Union wFunctionalitySupport;
    public ushort wReserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED[] bmSublinkSpeedAttr;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
    Public AsUlong32 As UInteger
    Public Anonymous As _Anonymous_e__Struct
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR
    Public bLength As Byte
    Public bDescriptorType As Byte
    Public bDevCapabilityType As Byte
    Public bReserved As Byte
    Public bmAttributes As _bmAttributes_e__Union
    Public wFunctionalitySupport As _wFunctionalitySupport_e__Union
    Public wReserved As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public bmSublinkSpeedAttr() As USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
End Structure
import ctypes
from ctypes import wintypes

class USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("AsUlong32", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Struct),
    ]

class USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("bLength", ctypes.c_ubyte),
        ("bDescriptorType", ctypes.c_ubyte),
        ("bDevCapabilityType", ctypes.c_ubyte),
        ("bReserved", ctypes.c_ubyte),
        ("bmAttributes", _bmAttributes_e__Union),
        ("wFunctionalitySupport", _wFunctionalitySupport_e__Union),
        ("wReserved", ctypes.c_ushort),
        ("bmSublinkSpeedAttr", USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED * 1),
    ]
#[repr(C, packed(1))]
pub struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED {
    pub AsUlong32: u32,
    pub Anonymous: _Anonymous_e__Struct,
}

#[repr(C, packed(1))]
pub struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR {
    pub bLength: u8,
    pub bDescriptorType: u8,
    pub bDevCapabilityType: u8,
    pub bReserved: u8,
    pub bmAttributes: _bmAttributes_e__Union,
    pub wFunctionalitySupport: _wFunctionalitySupport_e__Union,
    pub wReserved: u16,
    pub bmSublinkSpeedAttr: [USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED; 1],
}
import "golang.org/x/sys/windows"

type USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED struct {
	AsUlong32 uint32
	Anonymous _Anonymous_e__Struct
}

type USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR struct {
	bLength byte
	bDescriptorType byte
	bDevCapabilityType byte
	bReserved byte
	bmAttributes _bmAttributes_e__Union
	wFunctionalitySupport _wFunctionalitySupport_e__Union
	wReserved uint16
	bmSublinkSpeedAttr [1]USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
}
type
  USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED = packed record
    AsUlong32: DWORD;
    Anonymous: _Anonymous_e__Struct;
  end;

  USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR = packed record
    bLength: Byte;
    bDescriptorType: Byte;
    bDevCapabilityType: Byte;
    bReserved: Byte;
    bmAttributes: _bmAttributes_e__Union;
    wFunctionalitySupport: _wFunctionalitySupport_e__Union;
    wReserved: Word;
    bmSublinkSpeedAttr: array[0..0] of USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED;
  end;
const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED = extern struct {
    AsUlong32: u32,
    Anonymous: _Anonymous_e__Struct,
};

const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR = extern struct {
    bLength: u8,
    bDescriptorType: u8,
    bDevCapabilityType: u8,
    bReserved: u8,
    bmAttributes: _bmAttributes_e__Union,
    wFunctionalitySupport: _wFunctionalitySupport_e__Union,
    wReserved: u16,
    bmSublinkSpeedAttr: [1]USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED,
};
type
  USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED {.packed.} = object
    AsUlong32: uint32
    Anonymous: _Anonymous_e__Struct

  USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR {.packed.} = object
    bLength: uint8
    bDescriptorType: uint8
    bDevCapabilityType: uint8
    bReserved: uint8
    bmAttributes: _bmAttributes_e__Union
    wFunctionalitySupport: _wFunctionalitySupport_e__Union
    wReserved: uint16
    bmSublinkSpeedAttr: array[1, USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED]
align(1)
struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
{
    uint AsUlong32;
    _Anonymous_e__Struct Anonymous;
}

align(1)
struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR
{
    ubyte bLength;
    ubyte bDescriptorType;
    ubyte bDevCapabilityType;
    ubyte bReserved;
    _bmAttributes_e__Union bmAttributes;
    _wFunctionalitySupport_e__Union wFunctionalitySupport;
    ushort wReserved;
    USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED[1] bmSublinkSpeedAttr;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR サイズ: 18 バイト(x86)
dim st, 5    ; 4byte整数×5(構造体サイズ 18 / 4 切り上げ)
; bLength : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; bDevCapabilityType : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; bReserved : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; bmAttributes : _bmAttributes_e__Union (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; wFunctionalitySupport : _wFunctionalitySupport_e__Union (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; wReserved : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; bmSublinkSpeedAttr : USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED (+14, 4byte)  varptr(st)+14 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR サイズ: 26 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 26 / 4 切り上げ)
; bLength : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; bDevCapabilityType : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; bReserved : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; bmAttributes : _bmAttributes_e__Union (+4, 8byte)  varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; wFunctionalitySupport : _wFunctionalitySupport_e__Union (+12, 8byte)  varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; wReserved : WORD (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; bmSublinkSpeedAttr : USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED (+22, 4byte)  varptr(st)+22 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR, pack=1
    #field byte bLength
    #field byte bDescriptorType
    #field byte bDevCapabilityType
    #field byte bReserved
    #field byte bmAttributes 8
    #field byte wFunctionalitySupport 8
    #field short wReserved
    #field byte bmSublinkSpeedAttr 4
#endstruct

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