ホーム › Devices.Usb › USBUSER_BUS_STATISTICS_0_REQUEST
USBUSER_BUS_STATISTICS_0_REQUEST
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Header | USBUSER_REQUEST_HEADER | 16 | +0 | +0 | USBUSER要求共通ヘッダ。要求コードと結果を保持する。 |
| BusStatistics0 | USB_BUS_STATISTICS_0 | 56 | +16 | +16 | バス統計情報(バージョン0)を保持する。 |
各言語での定義
#include <windows.h>
// USBUSER_REQUEST_HEADER (x64 16 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct USBUSER_REQUEST_HEADER {
DWORD UsbUserRequest;
USB_USER_ERROR_CODE UsbUserStatusCode;
DWORD RequestBufferLength;
DWORD ActualBufferLength;
} USBUSER_REQUEST_HEADER;
#pragma pack(pop)
// USB_BUS_STATISTICS_0 (x64 56 / x86 56 バイト)
#pragma pack(push, 1)
typedef struct USB_BUS_STATISTICS_0 {
DWORD DeviceCount;
LONGLONG CurrentSystemTime;
DWORD CurrentUsbFrame;
DWORD BulkBytes;
DWORD IsoBytes;
DWORD InterruptBytes;
DWORD ControlDataBytes;
DWORD PciInterruptCount;
DWORD HardResetCount;
DWORD WorkerSignalCount;
DWORD CommonBufferBytes;
DWORD WorkerIdleTimeMs;
BOOLEAN RootHubEnabled;
BYTE RootHubDevicePowerState;
BYTE Unused;
BYTE NameIndex;
} USB_BUS_STATISTICS_0;
#pragma pack(pop)
// USBUSER_BUS_STATISTICS_0_REQUEST (x64 72 / x86 72 バイト)
#pragma pack(push, 1)
typedef struct USBUSER_BUS_STATISTICS_0_REQUEST {
USBUSER_REQUEST_HEADER Header;
USB_BUS_STATISTICS_0 BusStatistics0;
} USBUSER_BUS_STATISTICS_0_REQUEST;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USBUSER_REQUEST_HEADER
{
public uint UsbUserRequest;
public int UsbUserStatusCode;
public uint RequestBufferLength;
public uint ActualBufferLength;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_BUS_STATISTICS_0
{
public uint DeviceCount;
public long CurrentSystemTime;
public uint CurrentUsbFrame;
public uint BulkBytes;
public uint IsoBytes;
public uint InterruptBytes;
public uint ControlDataBytes;
public uint PciInterruptCount;
public uint HardResetCount;
public uint WorkerSignalCount;
public uint CommonBufferBytes;
public uint WorkerIdleTimeMs;
[MarshalAs(UnmanagedType.U1)] public bool RootHubEnabled;
public byte RootHubDevicePowerState;
public byte Unused;
public byte NameIndex;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USBUSER_BUS_STATISTICS_0_REQUEST
{
public USBUSER_REQUEST_HEADER Header;
public USB_BUS_STATISTICS_0 BusStatistics0;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USBUSER_REQUEST_HEADER
Public UsbUserRequest As UInteger
Public UsbUserStatusCode As Integer
Public RequestBufferLength As UInteger
Public ActualBufferLength As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_BUS_STATISTICS_0
Public DeviceCount As UInteger
Public CurrentSystemTime As Long
Public CurrentUsbFrame As UInteger
Public BulkBytes As UInteger
Public IsoBytes As UInteger
Public InterruptBytes As UInteger
Public ControlDataBytes As UInteger
Public PciInterruptCount As UInteger
Public HardResetCount As UInteger
Public WorkerSignalCount As UInteger
Public CommonBufferBytes As UInteger
Public WorkerIdleTimeMs As UInteger
<MarshalAs(UnmanagedType.U1)> Public RootHubEnabled As Boolean
Public RootHubDevicePowerState As Byte
Public Unused As Byte
Public NameIndex As Byte
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USBUSER_BUS_STATISTICS_0_REQUEST
Public Header As USBUSER_REQUEST_HEADER
Public BusStatistics0 As USB_BUS_STATISTICS_0
End Structureimport ctypes
from ctypes import wintypes
class USBUSER_REQUEST_HEADER(ctypes.Structure):
_pack_ = 1
_fields_ = [
("UsbUserRequest", wintypes.DWORD),
("UsbUserStatusCode", ctypes.c_int),
("RequestBufferLength", wintypes.DWORD),
("ActualBufferLength", wintypes.DWORD),
]
class USB_BUS_STATISTICS_0(ctypes.Structure):
_pack_ = 1
_fields_ = [
("DeviceCount", wintypes.DWORD),
("CurrentSystemTime", ctypes.c_longlong),
("CurrentUsbFrame", wintypes.DWORD),
("BulkBytes", wintypes.DWORD),
("IsoBytes", wintypes.DWORD),
("InterruptBytes", wintypes.DWORD),
("ControlDataBytes", wintypes.DWORD),
("PciInterruptCount", wintypes.DWORD),
("HardResetCount", wintypes.DWORD),
("WorkerSignalCount", wintypes.DWORD),
("CommonBufferBytes", wintypes.DWORD),
("WorkerIdleTimeMs", wintypes.DWORD),
("RootHubEnabled", ctypes.c_byte),
("RootHubDevicePowerState", ctypes.c_ubyte),
("Unused", ctypes.c_ubyte),
("NameIndex", ctypes.c_ubyte),
]
class USBUSER_BUS_STATISTICS_0_REQUEST(ctypes.Structure):
_pack_ = 1
_fields_ = [
("Header", USBUSER_REQUEST_HEADER),
("BusStatistics0", USB_BUS_STATISTICS_0),
]#[repr(C, packed(1))]
pub struct USBUSER_REQUEST_HEADER {
pub UsbUserRequest: u32,
pub UsbUserStatusCode: i32,
pub RequestBufferLength: u32,
pub ActualBufferLength: u32,
}
#[repr(C, packed(1))]
pub struct USB_BUS_STATISTICS_0 {
pub DeviceCount: u32,
pub CurrentSystemTime: i64,
pub CurrentUsbFrame: u32,
pub BulkBytes: u32,
pub IsoBytes: u32,
pub InterruptBytes: u32,
pub ControlDataBytes: u32,
pub PciInterruptCount: u32,
pub HardResetCount: u32,
pub WorkerSignalCount: u32,
pub CommonBufferBytes: u32,
pub WorkerIdleTimeMs: u32,
pub RootHubEnabled: u8,
pub RootHubDevicePowerState: u8,
pub Unused: u8,
pub NameIndex: u8,
}
#[repr(C, packed(1))]
pub struct USBUSER_BUS_STATISTICS_0_REQUEST {
pub Header: USBUSER_REQUEST_HEADER,
pub BusStatistics0: USB_BUS_STATISTICS_0,
}import "golang.org/x/sys/windows"
type USBUSER_REQUEST_HEADER struct {
UsbUserRequest uint32
UsbUserStatusCode int32
RequestBufferLength uint32
ActualBufferLength uint32
}
type USB_BUS_STATISTICS_0 struct {
DeviceCount uint32
CurrentSystemTime int64
CurrentUsbFrame uint32
BulkBytes uint32
IsoBytes uint32
InterruptBytes uint32
ControlDataBytes uint32
PciInterruptCount uint32
HardResetCount uint32
WorkerSignalCount uint32
CommonBufferBytes uint32
WorkerIdleTimeMs uint32
RootHubEnabled byte
RootHubDevicePowerState byte
Unused byte
NameIndex byte
}
type USBUSER_BUS_STATISTICS_0_REQUEST struct {
Header USBUSER_REQUEST_HEADER
BusStatistics0 USB_BUS_STATISTICS_0
}type
USBUSER_REQUEST_HEADER = packed record
UsbUserRequest: DWORD;
UsbUserStatusCode: Integer;
RequestBufferLength: DWORD;
ActualBufferLength: DWORD;
end;
USB_BUS_STATISTICS_0 = packed record
DeviceCount: DWORD;
CurrentSystemTime: Int64;
CurrentUsbFrame: DWORD;
BulkBytes: DWORD;
IsoBytes: DWORD;
InterruptBytes: DWORD;
ControlDataBytes: DWORD;
PciInterruptCount: DWORD;
HardResetCount: DWORD;
WorkerSignalCount: DWORD;
CommonBufferBytes: DWORD;
WorkerIdleTimeMs: DWORD;
RootHubEnabled: ByteBool;
RootHubDevicePowerState: Byte;
Unused: Byte;
NameIndex: Byte;
end;
USBUSER_BUS_STATISTICS_0_REQUEST = packed record
Header: USBUSER_REQUEST_HEADER;
BusStatistics0: USB_BUS_STATISTICS_0;
end;const USBUSER_REQUEST_HEADER = extern struct {
UsbUserRequest: u32,
UsbUserStatusCode: i32,
RequestBufferLength: u32,
ActualBufferLength: u32,
};
const USB_BUS_STATISTICS_0 = extern struct {
DeviceCount: u32,
CurrentSystemTime: i64,
CurrentUsbFrame: u32,
BulkBytes: u32,
IsoBytes: u32,
InterruptBytes: u32,
ControlDataBytes: u32,
PciInterruptCount: u32,
HardResetCount: u32,
WorkerSignalCount: u32,
CommonBufferBytes: u32,
WorkerIdleTimeMs: u32,
RootHubEnabled: u8,
RootHubDevicePowerState: u8,
Unused: u8,
NameIndex: u8,
};
const USBUSER_BUS_STATISTICS_0_REQUEST = extern struct {
Header: USBUSER_REQUEST_HEADER,
BusStatistics0: USB_BUS_STATISTICS_0,
};type
USBUSER_REQUEST_HEADER {.packed.} = object
UsbUserRequest: uint32
UsbUserStatusCode: int32
RequestBufferLength: uint32
ActualBufferLength: uint32
USB_BUS_STATISTICS_0 {.packed.} = object
DeviceCount: uint32
CurrentSystemTime: int64
CurrentUsbFrame: uint32
BulkBytes: uint32
IsoBytes: uint32
InterruptBytes: uint32
ControlDataBytes: uint32
PciInterruptCount: uint32
HardResetCount: uint32
WorkerSignalCount: uint32
CommonBufferBytes: uint32
WorkerIdleTimeMs: uint32
RootHubEnabled: uint8
RootHubDevicePowerState: uint8
Unused: uint8
NameIndex: uint8
USBUSER_BUS_STATISTICS_0_REQUEST {.packed.} = object
Header: USBUSER_REQUEST_HEADER
BusStatistics0: USB_BUS_STATISTICS_0align(1)
struct USBUSER_REQUEST_HEADER
{
uint UsbUserRequest;
int UsbUserStatusCode;
uint RequestBufferLength;
uint ActualBufferLength;
}
align(1)
struct USB_BUS_STATISTICS_0
{
uint DeviceCount;
long CurrentSystemTime;
uint CurrentUsbFrame;
uint BulkBytes;
uint IsoBytes;
uint InterruptBytes;
uint ControlDataBytes;
uint PciInterruptCount;
uint HardResetCount;
uint WorkerSignalCount;
uint CommonBufferBytes;
uint WorkerIdleTimeMs;
ubyte RootHubEnabled;
ubyte RootHubDevicePowerState;
ubyte Unused;
ubyte NameIndex;
}
align(1)
struct USBUSER_BUS_STATISTICS_0_REQUEST
{
USBUSER_REQUEST_HEADER Header;
USB_BUS_STATISTICS_0 BusStatistics0;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USBUSER_BUS_STATISTICS_0_REQUEST サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; Header : USBUSER_REQUEST_HEADER (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; BusStatistics0 : USB_BUS_STATISTICS_0 (+16, 56byte) varptr(st)+16 を基点に操作(56byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global USBUSER_REQUEST_HEADER, pack=1
#field int UsbUserRequest
#field int UsbUserStatusCode
#field int RequestBufferLength
#field int ActualBufferLength
#endstruct
#defstruct global USB_BUS_STATISTICS_0, pack=1
#field int DeviceCount
#field int64 CurrentSystemTime
#field int CurrentUsbFrame
#field int BulkBytes
#field int IsoBytes
#field int InterruptBytes
#field int ControlDataBytes
#field int PciInterruptCount
#field int HardResetCount
#field int WorkerSignalCount
#field int CommonBufferBytes
#field int WorkerIdleTimeMs
#field bool1 RootHubEnabled
#field byte RootHubDevicePowerState
#field byte Unused
#field byte NameIndex
#endstruct
#defstruct global USBUSER_BUS_STATISTICS_0_REQUEST, pack=1
#field USBUSER_REQUEST_HEADER Header
#field USB_BUS_STATISTICS_0 BusStatistics0
#endstruct
stdim st, USBUSER_BUS_STATISTICS_0_REQUEST ; NSTRUCT 変数を確保