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

USBUSER_CONTROLLER_INFO_0

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

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

フィールド

フィールドサイズx64x86説明
HeaderUSBUSER_REQUEST_HEADER16+0+0USBUSER要求共通ヘッダ。要求コードと結果を保持する。
Info0USB_CONTROLLER_INFO_024+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_CONTROLLER_INFO_0  (x64 24 / x86 24 バイト)
#pragma pack(push, 1)
typedef struct USB_CONTROLLER_INFO_0 {
    DWORD PciVendorId;
    DWORD PciDeviceId;
    DWORD PciRevision;
    DWORD NumberOfRootPorts;
    USB_CONTROLLER_FLAVOR ControllerFlavor;
    DWORD HcFeatureFlags;
} USB_CONTROLLER_INFO_0;
#pragma pack(pop)

// USBUSER_CONTROLLER_INFO_0  (x64 40 / x86 40 バイト)
#pragma pack(push, 1)
typedef struct USBUSER_CONTROLLER_INFO_0 {
    USBUSER_REQUEST_HEADER Header;
    USB_CONTROLLER_INFO_0 Info0;
} USBUSER_CONTROLLER_INFO_0;
#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_CONTROLLER_INFO_0
{
    public uint PciVendorId;
    public uint PciDeviceId;
    public uint PciRevision;
    public uint NumberOfRootPorts;
    public int ControllerFlavor;
    public uint HcFeatureFlags;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USBUSER_CONTROLLER_INFO_0
{
    public USBUSER_REQUEST_HEADER Header;
    public USB_CONTROLLER_INFO_0 Info0;
}
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_CONTROLLER_INFO_0
    Public PciVendorId As UInteger
    Public PciDeviceId As UInteger
    Public PciRevision As UInteger
    Public NumberOfRootPorts As UInteger
    Public ControllerFlavor As Integer
    Public HcFeatureFlags As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USBUSER_CONTROLLER_INFO_0
    Public Header As USBUSER_REQUEST_HEADER
    Public Info0 As USB_CONTROLLER_INFO_0
End Structure
import 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_CONTROLLER_INFO_0(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("PciVendorId", wintypes.DWORD),
        ("PciDeviceId", wintypes.DWORD),
        ("PciRevision", wintypes.DWORD),
        ("NumberOfRootPorts", wintypes.DWORD),
        ("ControllerFlavor", ctypes.c_int),
        ("HcFeatureFlags", wintypes.DWORD),
    ]

class USBUSER_CONTROLLER_INFO_0(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Header", USBUSER_REQUEST_HEADER),
        ("Info0", USB_CONTROLLER_INFO_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_CONTROLLER_INFO_0 {
    pub PciVendorId: u32,
    pub PciDeviceId: u32,
    pub PciRevision: u32,
    pub NumberOfRootPorts: u32,
    pub ControllerFlavor: i32,
    pub HcFeatureFlags: u32,
}

#[repr(C, packed(1))]
pub struct USBUSER_CONTROLLER_INFO_0 {
    pub Header: USBUSER_REQUEST_HEADER,
    pub Info0: USB_CONTROLLER_INFO_0,
}
import "golang.org/x/sys/windows"

type USBUSER_REQUEST_HEADER struct {
	UsbUserRequest uint32
	UsbUserStatusCode int32
	RequestBufferLength uint32
	ActualBufferLength uint32
}

type USB_CONTROLLER_INFO_0 struct {
	PciVendorId uint32
	PciDeviceId uint32
	PciRevision uint32
	NumberOfRootPorts uint32
	ControllerFlavor int32
	HcFeatureFlags uint32
}

type USBUSER_CONTROLLER_INFO_0 struct {
	Header USBUSER_REQUEST_HEADER
	Info0 USB_CONTROLLER_INFO_0
}
type
  USBUSER_REQUEST_HEADER = packed record
    UsbUserRequest: DWORD;
    UsbUserStatusCode: Integer;
    RequestBufferLength: DWORD;
    ActualBufferLength: DWORD;
  end;

  USB_CONTROLLER_INFO_0 = packed record
    PciVendorId: DWORD;
    PciDeviceId: DWORD;
    PciRevision: DWORD;
    NumberOfRootPorts: DWORD;
    ControllerFlavor: Integer;
    HcFeatureFlags: DWORD;
  end;

  USBUSER_CONTROLLER_INFO_0 = packed record
    Header: USBUSER_REQUEST_HEADER;
    Info0: USB_CONTROLLER_INFO_0;
  end;
const USBUSER_REQUEST_HEADER = extern struct {
    UsbUserRequest: u32,
    UsbUserStatusCode: i32,
    RequestBufferLength: u32,
    ActualBufferLength: u32,
};

const USB_CONTROLLER_INFO_0 = extern struct {
    PciVendorId: u32,
    PciDeviceId: u32,
    PciRevision: u32,
    NumberOfRootPorts: u32,
    ControllerFlavor: i32,
    HcFeatureFlags: u32,
};

const USBUSER_CONTROLLER_INFO_0 = extern struct {
    Header: USBUSER_REQUEST_HEADER,
    Info0: USB_CONTROLLER_INFO_0,
};
type
  USBUSER_REQUEST_HEADER {.packed.} = object
    UsbUserRequest: uint32
    UsbUserStatusCode: int32
    RequestBufferLength: uint32
    ActualBufferLength: uint32

  USB_CONTROLLER_INFO_0 {.packed.} = object
    PciVendorId: uint32
    PciDeviceId: uint32
    PciRevision: uint32
    NumberOfRootPorts: uint32
    ControllerFlavor: int32
    HcFeatureFlags: uint32

  USBUSER_CONTROLLER_INFO_0 {.packed.} = object
    Header: USBUSER_REQUEST_HEADER
    Info0: USB_CONTROLLER_INFO_0
align(1)
struct USBUSER_REQUEST_HEADER
{
    uint UsbUserRequest;
    int UsbUserStatusCode;
    uint RequestBufferLength;
    uint ActualBufferLength;
}

align(1)
struct USB_CONTROLLER_INFO_0
{
    uint PciVendorId;
    uint PciDeviceId;
    uint PciRevision;
    uint NumberOfRootPorts;
    int ControllerFlavor;
    uint HcFeatureFlags;
}

align(1)
struct USBUSER_CONTROLLER_INFO_0
{
    USBUSER_REQUEST_HEADER Header;
    USB_CONTROLLER_INFO_0 Info0;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USBUSER_CONTROLLER_INFO_0 サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; Header : USBUSER_REQUEST_HEADER (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; Info0 : USB_CONTROLLER_INFO_0 (+16, 24byte)  varptr(st)+16 を基点に操作(24byte:入れ子/配列)
; ※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_CONTROLLER_INFO_0, pack=1
    #field int PciVendorId
    #field int PciDeviceId
    #field int PciRevision
    #field int NumberOfRootPorts
    #field int ControllerFlavor
    #field int HcFeatureFlags
#endstruct

#defstruct global USBUSER_CONTROLLER_INFO_0, pack=1
    #field USBUSER_REQUEST_HEADER Header
    #field USB_CONTROLLER_INFO_0 Info0
#endstruct

stdim st, USBUSER_CONTROLLER_INFO_0        ; NSTRUCT 変数を確保