ホーム › Devices.Usb › USBD_INTERFACE_INFORMATION
USBD_INTERFACE_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Length | WORD | 2 | +0 | +0 | この構造体の長さをバイト単位で示す。 |
| InterfaceNumber | BYTE | 1 | +2 | +2 | 対象インターフェイスの番号を示す。 |
| AlternateSetting | BYTE | 1 | +3 | +3 | 選択する代替設定番号を示す。 |
| Class | BYTE | 1 | +4 | +4 | インターフェイスのクラスコードを示す。 |
| SubClass | BYTE | 1 | +5 | +5 | インターフェイスのサブクラスコードを示す。 |
| Protocol | BYTE | 1 | +6 | +6 | インターフェイスのプロトコルコードを示す。 |
| Reserved | BYTE | 1 | +7 | +7 | 予約フィールド。 |
| InterfaceHandle | void* | 8/4 | +8 | +8 | USBDが割り当てたインターフェイスハンドルへのポインタ。 |
| NumberOfPipes | DWORD | 4 | +16 | +12 | このインターフェイスのパイプ数を示す。 |
| Pipes | USBD_PIPE_INFORMATION | 24/20 | +24 | +16 | 各パイプの情報を格納するUSBD_PIPE_INFORMATION配列。 |
各言語での定義
#include <windows.h>
// USBD_PIPE_INFORMATION (x64 24 / x86 20 バイト)
typedef struct USBD_PIPE_INFORMATION {
WORD MaximumPacketSize;
BYTE EndpointAddress;
BYTE Interval;
USBD_PIPE_TYPE PipeType;
void* PipeHandle;
DWORD MaximumTransferSize;
DWORD PipeFlags;
} USBD_PIPE_INFORMATION;
// USBD_INTERFACE_INFORMATION (x64 48 / x86 36 バイト)
typedef struct USBD_INTERFACE_INFORMATION {
WORD Length;
BYTE InterfaceNumber;
BYTE AlternateSetting;
BYTE Class;
BYTE SubClass;
BYTE Protocol;
BYTE Reserved;
void* InterfaceHandle;
DWORD NumberOfPipes;
USBD_PIPE_INFORMATION Pipes[1];
} USBD_INTERFACE_INFORMATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USBD_PIPE_INFORMATION
{
public ushort MaximumPacketSize;
public byte EndpointAddress;
public byte Interval;
public int PipeType;
public IntPtr PipeHandle;
public uint MaximumTransferSize;
public uint PipeFlags;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USBD_INTERFACE_INFORMATION
{
public ushort Length;
public byte InterfaceNumber;
public byte AlternateSetting;
public byte Class;
public byte SubClass;
public byte Protocol;
public byte Reserved;
public IntPtr InterfaceHandle;
public uint NumberOfPipes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public USBD_PIPE_INFORMATION[] Pipes;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USBD_PIPE_INFORMATION
Public MaximumPacketSize As UShort
Public EndpointAddress As Byte
Public Interval As Byte
Public PipeType As Integer
Public PipeHandle As IntPtr
Public MaximumTransferSize As UInteger
Public PipeFlags As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USBD_INTERFACE_INFORMATION
Public Length As UShort
Public InterfaceNumber As Byte
Public AlternateSetting As Byte
Public Class As Byte
Public SubClass As Byte
Public Protocol As Byte
Public Reserved As Byte
Public InterfaceHandle As IntPtr
Public NumberOfPipes As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Pipes() As USBD_PIPE_INFORMATION
End Structureimport ctypes
from ctypes import wintypes
class USBD_PIPE_INFORMATION(ctypes.Structure):
_fields_ = [
("MaximumPacketSize", ctypes.c_ushort),
("EndpointAddress", ctypes.c_ubyte),
("Interval", ctypes.c_ubyte),
("PipeType", ctypes.c_int),
("PipeHandle", ctypes.c_void_p),
("MaximumTransferSize", wintypes.DWORD),
("PipeFlags", wintypes.DWORD),
]
class USBD_INTERFACE_INFORMATION(ctypes.Structure):
_fields_ = [
("Length", ctypes.c_ushort),
("InterfaceNumber", ctypes.c_ubyte),
("AlternateSetting", ctypes.c_ubyte),
("Class", ctypes.c_ubyte),
("SubClass", ctypes.c_ubyte),
("Protocol", ctypes.c_ubyte),
("Reserved", ctypes.c_ubyte),
("InterfaceHandle", ctypes.c_void_p),
("NumberOfPipes", wintypes.DWORD),
("Pipes", USBD_PIPE_INFORMATION * 1),
]#[repr(C)]
pub struct USBD_PIPE_INFORMATION {
pub MaximumPacketSize: u16,
pub EndpointAddress: u8,
pub Interval: u8,
pub PipeType: i32,
pub PipeHandle: *mut core::ffi::c_void,
pub MaximumTransferSize: u32,
pub PipeFlags: u32,
}
#[repr(C)]
pub struct USBD_INTERFACE_INFORMATION {
pub Length: u16,
pub InterfaceNumber: u8,
pub AlternateSetting: u8,
pub Class: u8,
pub SubClass: u8,
pub Protocol: u8,
pub Reserved: u8,
pub InterfaceHandle: *mut core::ffi::c_void,
pub NumberOfPipes: u32,
pub Pipes: [USBD_PIPE_INFORMATION; 1],
}import "golang.org/x/sys/windows"
type USBD_PIPE_INFORMATION struct {
MaximumPacketSize uint16
EndpointAddress byte
Interval byte
PipeType int32
PipeHandle uintptr
MaximumTransferSize uint32
PipeFlags uint32
}
type USBD_INTERFACE_INFORMATION struct {
Length uint16
InterfaceNumber byte
AlternateSetting byte
Class byte
SubClass byte
Protocol byte
Reserved byte
InterfaceHandle uintptr
NumberOfPipes uint32
Pipes [1]USBD_PIPE_INFORMATION
}type
USBD_PIPE_INFORMATION = record
MaximumPacketSize: Word;
EndpointAddress: Byte;
Interval: Byte;
PipeType: Integer;
PipeHandle: Pointer;
MaximumTransferSize: DWORD;
PipeFlags: DWORD;
end;
USBD_INTERFACE_INFORMATION = record
Length: Word;
InterfaceNumber: Byte;
AlternateSetting: Byte;
Class: Byte;
SubClass: Byte;
Protocol: Byte;
Reserved: Byte;
InterfaceHandle: Pointer;
NumberOfPipes: DWORD;
Pipes: array[0..0] of USBD_PIPE_INFORMATION;
end;const USBD_PIPE_INFORMATION = extern struct {
MaximumPacketSize: u16,
EndpointAddress: u8,
Interval: u8,
PipeType: i32,
PipeHandle: ?*anyopaque,
MaximumTransferSize: u32,
PipeFlags: u32,
};
const USBD_INTERFACE_INFORMATION = extern struct {
Length: u16,
InterfaceNumber: u8,
AlternateSetting: u8,
Class: u8,
SubClass: u8,
Protocol: u8,
Reserved: u8,
InterfaceHandle: ?*anyopaque,
NumberOfPipes: u32,
Pipes: [1]USBD_PIPE_INFORMATION,
};type
USBD_PIPE_INFORMATION {.bycopy.} = object
MaximumPacketSize: uint16
EndpointAddress: uint8
Interval: uint8
PipeType: int32
PipeHandle: pointer
MaximumTransferSize: uint32
PipeFlags: uint32
USBD_INTERFACE_INFORMATION {.bycopy.} = object
Length: uint16
InterfaceNumber: uint8
AlternateSetting: uint8
Class: uint8
SubClass: uint8
Protocol: uint8
Reserved: uint8
InterfaceHandle: pointer
NumberOfPipes: uint32
Pipes: array[1, USBD_PIPE_INFORMATION]struct USBD_PIPE_INFORMATION
{
ushort MaximumPacketSize;
ubyte EndpointAddress;
ubyte Interval;
int PipeType;
void* PipeHandle;
uint MaximumTransferSize;
uint PipeFlags;
}
struct USBD_INTERFACE_INFORMATION
{
ushort Length;
ubyte InterfaceNumber;
ubyte AlternateSetting;
ubyte Class;
ubyte SubClass;
ubyte Protocol;
ubyte Reserved;
void* InterfaceHandle;
uint NumberOfPipes;
USBD_PIPE_INFORMATION[1] Pipes;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; USBD_INTERFACE_INFORMATION サイズ: 36 バイト(x86)
dim st, 9 ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; Length : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; InterfaceNumber : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; AlternateSetting : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; Class : BYTE (+4, 1byte) poke st,4,値 / 値 = peek(st,4)
; SubClass : BYTE (+5, 1byte) poke st,5,値 / 値 = peek(st,5)
; Protocol : BYTE (+6, 1byte) poke st,6,値 / 値 = peek(st,6)
; Reserved : BYTE (+7, 1byte) poke st,7,値 / 値 = peek(st,7)
; InterfaceHandle : void* (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; NumberOfPipes : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Pipes : USBD_PIPE_INFORMATION (+16, 20byte) varptr(st)+16 を基点に操作(20byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USBD_INTERFACE_INFORMATION サイズ: 48 バイト(x64)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Length : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; InterfaceNumber : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; AlternateSetting : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; Class : BYTE (+4, 1byte) poke st,4,値 / 値 = peek(st,4)
; SubClass : BYTE (+5, 1byte) poke st,5,値 / 値 = peek(st,5)
; Protocol : BYTE (+6, 1byte) poke st,6,値 / 値 = peek(st,6)
; Reserved : BYTE (+7, 1byte) poke st,7,値 / 値 = peek(st,7)
; InterfaceHandle : void* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; NumberOfPipes : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; Pipes : USBD_PIPE_INFORMATION (+24, 24byte) varptr(st)+24 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global USBD_PIPE_INFORMATION
#field short MaximumPacketSize
#field byte EndpointAddress
#field byte Interval
#field int PipeType
#field intptr PipeHandle
#field int MaximumTransferSize
#field int PipeFlags
#endstruct
#defstruct global USBD_INTERFACE_INFORMATION
#field short Length
#field byte InterfaceNumber
#field byte AlternateSetting
#field byte Class
#field byte SubClass
#field byte Protocol
#field byte Reserved
#field intptr InterfaceHandle
#field int NumberOfPipes
#field USBD_PIPE_INFORMATION Pipes 1
#endstruct
stdim st, USBD_INTERFACE_INFORMATION ; NSTRUCT 変数を確保
st->Length = 100
mes "Length=" + st->Length