ホーム › Devices.Usb › _URB_SELECT_CONFIGURATION
_URB_SELECT_CONFIGURATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| Hdr | _URB_HEADER | 24/16 | +0 | +0 |
| ConfigurationDescriptor | USB_CONFIGURATION_DESCRIPTOR* | 8/4 | +24 | +16 |
| ConfigurationHandle | void* | 8/4 | +32 | +20 |
| Interface | USBD_INTERFACE_INFORMATION | 48/36 | +40 | +24 |
各言語での定義
#include <windows.h>
// _URB_HEADER (x64 24 / x86 16 バイト)
typedef struct _URB_HEADER {
WORD Length;
WORD Function;
INT Status;
void* UsbdDeviceHandle;
DWORD UsbdFlags;
} _URB_HEADER;
// 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;
// _URB_SELECT_CONFIGURATION (x64 88 / x86 60 バイト)
typedef struct _URB_SELECT_CONFIGURATION {
_URB_HEADER Hdr;
USB_CONFIGURATION_DESCRIPTOR* ConfigurationDescriptor;
void* ConfigurationHandle;
USBD_INTERFACE_INFORMATION Interface;
} _URB_SELECT_CONFIGURATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct _URB_HEADER
{
public ushort Length;
public ushort Function;
public int Status;
public IntPtr UsbdDeviceHandle;
public uint UsbdFlags;
}
[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;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct _URB_SELECT_CONFIGURATION
{
public _URB_HEADER Hdr;
public IntPtr ConfigurationDescriptor;
public IntPtr ConfigurationHandle;
public USBD_INTERFACE_INFORMATION Interface;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure _URB_HEADER
Public Length As UShort
Public Function As UShort
Public Status As Integer
Public UsbdDeviceHandle As IntPtr
Public UsbdFlags As UInteger
End Structure
<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 Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure _URB_SELECT_CONFIGURATION
Public Hdr As _URB_HEADER
Public ConfigurationDescriptor As IntPtr
Public ConfigurationHandle As IntPtr
Public Interface As USBD_INTERFACE_INFORMATION
End Structureimport ctypes
from ctypes import wintypes
class _URB_HEADER(ctypes.Structure):
_fields_ = [
("Length", ctypes.c_ushort),
("Function", ctypes.c_ushort),
("Status", ctypes.c_int),
("UsbdDeviceHandle", ctypes.c_void_p),
("UsbdFlags", wintypes.DWORD),
]
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),
]
class _URB_SELECT_CONFIGURATION(ctypes.Structure):
_fields_ = [
("Hdr", _URB_HEADER),
("ConfigurationDescriptor", ctypes.c_void_p),
("ConfigurationHandle", ctypes.c_void_p),
("Interface", USBD_INTERFACE_INFORMATION),
]#[repr(C)]
pub struct _URB_HEADER {
pub Length: u16,
pub Function: u16,
pub Status: i32,
pub UsbdDeviceHandle: *mut core::ffi::c_void,
pub UsbdFlags: u32,
}
#[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],
}
#[repr(C)]
pub struct _URB_SELECT_CONFIGURATION {
pub Hdr: _URB_HEADER,
pub ConfigurationDescriptor: *mut core::ffi::c_void,
pub ConfigurationHandle: *mut core::ffi::c_void,
pub Interface: USBD_INTERFACE_INFORMATION,
}import "golang.org/x/sys/windows"
type _URB_HEADER struct {
Length uint16
Function uint16
Status int32
UsbdDeviceHandle uintptr
UsbdFlags uint32
}
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 _URB_SELECT_CONFIGURATION struct {
Hdr _URB_HEADER
ConfigurationDescriptor uintptr
ConfigurationHandle uintptr
Interface USBD_INTERFACE_INFORMATION
}type
_URB_HEADER = record
Length: Word;
Function: Word;
Status: Integer;
UsbdDeviceHandle: Pointer;
UsbdFlags: DWORD;
end;
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;
_URB_SELECT_CONFIGURATION = record
Hdr: _URB_HEADER;
ConfigurationDescriptor: Pointer;
ConfigurationHandle: Pointer;
Interface: USBD_INTERFACE_INFORMATION;
end;const _URB_HEADER = extern struct {
Length: u16,
Function: u16,
Status: i32,
UsbdDeviceHandle: ?*anyopaque,
UsbdFlags: u32,
};
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,
};
const _URB_SELECT_CONFIGURATION = extern struct {
Hdr: _URB_HEADER,
ConfigurationDescriptor: ?*anyopaque,
ConfigurationHandle: ?*anyopaque,
Interface: USBD_INTERFACE_INFORMATION,
};type
_URB_HEADER {.bycopy.} = object
Length: uint16
Function: uint16
Status: int32
UsbdDeviceHandle: pointer
UsbdFlags: uint32
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]
_URB_SELECT_CONFIGURATION {.bycopy.} = object
Hdr: _URB_HEADER
ConfigurationDescriptor: pointer
ConfigurationHandle: pointer
Interface: USBD_INTERFACE_INFORMATIONstruct _URB_HEADER
{
ushort Length;
ushort Function;
int Status;
void* UsbdDeviceHandle;
uint UsbdFlags;
}
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;
}
struct _URB_SELECT_CONFIGURATION
{
_URB_HEADER Hdr;
void* ConfigurationDescriptor;
void* ConfigurationHandle;
USBD_INTERFACE_INFORMATION Interface;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; _URB_SELECT_CONFIGURATION サイズ: 60 バイト(x86)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; Hdr : _URB_HEADER (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ConfigurationDescriptor : USB_CONFIGURATION_DESCRIPTOR* (+16, 4byte) varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; ConfigurationHandle : void* (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; Interface : USBD_INTERFACE_INFORMATION (+24, 36byte) varptr(st)+24 を基点に操作(36byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; _URB_SELECT_CONFIGURATION サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; Hdr : _URB_HEADER (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; ConfigurationDescriptor : USB_CONFIGURATION_DESCRIPTOR* (+24, 8byte) varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; ConfigurationHandle : void* (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; Interface : USBD_INTERFACE_INFORMATION (+40, 48byte) varptr(st)+40 を基点に操作(48byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global _URB_HEADER
#field short Length
#field short Function
#field int Status
#field intptr UsbdDeviceHandle
#field int UsbdFlags
#endstruct
#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
#defstruct global _URB_SELECT_CONFIGURATION
#field _URB_HEADER Hdr
#field intptr ConfigurationDescriptor
#field intptr ConfigurationHandle
#field USBD_INTERFACE_INFORMATION Interface
#endstruct
stdim st, _URB_SELECT_CONFIGURATION ; NSTRUCT 変数を確保