ホーム › Devices.Usb › USB_BOS_DESCRIPTOR
USB_BOS_DESCRIPTOR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| bLength | BYTE | 1 | +0 | +0 | このディスクリプタのサイズをバイト単位で示す。 |
| bDescriptorType | BYTE | 1 | +1 | +1 | ディスクリプタ種別。BOSは0x0F。 |
| wTotalLength | WORD | 2 | +2 | +2 | BOSと全デバイス能力ディスクリプタの合計長を示す。 |
| bNumDeviceCaps | BYTE | 1 | +4 | +4 | 後続するデバイス能力ディスクリプタの数を示す。 |
各言語での定義
#include <windows.h>
// USB_BOS_DESCRIPTOR (x64 5 / x86 5 バイト)
#pragma pack(push, 1)
typedef struct USB_BOS_DESCRIPTOR {
BYTE bLength;
BYTE bDescriptorType;
WORD wTotalLength;
BYTE bNumDeviceCaps;
} USB_BOS_DESCRIPTOR;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_BOS_DESCRIPTOR
{
public byte bLength;
public byte bDescriptorType;
public ushort wTotalLength;
public byte bNumDeviceCaps;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_BOS_DESCRIPTOR
Public bLength As Byte
Public bDescriptorType As Byte
Public wTotalLength As UShort
Public bNumDeviceCaps As Byte
End Structureimport ctypes
from ctypes import wintypes
class USB_BOS_DESCRIPTOR(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bLength", ctypes.c_ubyte),
("bDescriptorType", ctypes.c_ubyte),
("wTotalLength", ctypes.c_ushort),
("bNumDeviceCaps", ctypes.c_ubyte),
]#[repr(C, packed(1))]
pub struct USB_BOS_DESCRIPTOR {
pub bLength: u8,
pub bDescriptorType: u8,
pub wTotalLength: u16,
pub bNumDeviceCaps: u8,
}import "golang.org/x/sys/windows"
type USB_BOS_DESCRIPTOR struct {
bLength byte
bDescriptorType byte
wTotalLength uint16
bNumDeviceCaps byte
}type
USB_BOS_DESCRIPTOR = packed record
bLength: Byte;
bDescriptorType: Byte;
wTotalLength: Word;
bNumDeviceCaps: Byte;
end;const USB_BOS_DESCRIPTOR = extern struct {
bLength: u8,
bDescriptorType: u8,
wTotalLength: u16,
bNumDeviceCaps: u8,
};type
USB_BOS_DESCRIPTOR {.packed.} = object
bLength: uint8
bDescriptorType: uint8
wTotalLength: uint16
bNumDeviceCaps: uint8align(1)
struct USB_BOS_DESCRIPTOR
{
ubyte bLength;
ubyte bDescriptorType;
ushort wTotalLength;
ubyte bNumDeviceCaps;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_BOS_DESCRIPTOR サイズ: 5 バイト(x64)
dim st, 2 ; 4byte整数×2(構造体サイズ 5 / 4 切り上げ)
; bLength : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; wTotalLength : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; bNumDeviceCaps : BYTE (+4, 1byte) poke st,4,値 / 値 = peek(st,4)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_BOS_DESCRIPTOR, pack=1
#field byte bLength
#field byte bDescriptorType
#field short wTotalLength
#field byte bNumDeviceCaps
#endstruct
stdim st, USB_BOS_DESCRIPTOR ; NSTRUCT 変数を確保
st->bLength = 100
mes "bLength=" + st->bLength