ホーム › Devices.Usb › USBUSER_CLOSE_RAW_DEVICE
USBUSER_CLOSE_RAW_DEVICE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Header | USBUSER_REQUEST_HEADER | 16 | +0 | +0 | USBUSER要求共通ヘッダ。要求コードと結果を保持する。 |
| Parameters | USB_CLOSE_RAW_DEVICE_PARAMETERS | 4 | +16 | +16 | 生デバイスをクローズするためのパラメータを保持する。 |
各言語での定義
#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_CLOSE_RAW_DEVICE_PARAMETERS (x64 4 / x86 4 バイト)
#pragma pack(push, 1)
typedef struct USB_CLOSE_RAW_DEVICE_PARAMETERS {
DWORD xxx;
} USB_CLOSE_RAW_DEVICE_PARAMETERS;
#pragma pack(pop)
// USBUSER_CLOSE_RAW_DEVICE (x64 20 / x86 20 バイト)
#pragma pack(push, 1)
typedef struct USBUSER_CLOSE_RAW_DEVICE {
USBUSER_REQUEST_HEADER Header;
USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters;
} USBUSER_CLOSE_RAW_DEVICE;
#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_CLOSE_RAW_DEVICE_PARAMETERS
{
public uint xxx;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USBUSER_CLOSE_RAW_DEVICE
{
public USBUSER_REQUEST_HEADER Header;
public USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters;
}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_CLOSE_RAW_DEVICE_PARAMETERS
Public xxx As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USBUSER_CLOSE_RAW_DEVICE
Public Header As USBUSER_REQUEST_HEADER
Public Parameters As USB_CLOSE_RAW_DEVICE_PARAMETERS
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_CLOSE_RAW_DEVICE_PARAMETERS(ctypes.Structure):
_pack_ = 1
_fields_ = [
("xxx", wintypes.DWORD),
]
class USBUSER_CLOSE_RAW_DEVICE(ctypes.Structure):
_pack_ = 1
_fields_ = [
("Header", USBUSER_REQUEST_HEADER),
("Parameters", USB_CLOSE_RAW_DEVICE_PARAMETERS),
]#[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_CLOSE_RAW_DEVICE_PARAMETERS {
pub xxx: u32,
}
#[repr(C, packed(1))]
pub struct USBUSER_CLOSE_RAW_DEVICE {
pub Header: USBUSER_REQUEST_HEADER,
pub Parameters: USB_CLOSE_RAW_DEVICE_PARAMETERS,
}import "golang.org/x/sys/windows"
type USBUSER_REQUEST_HEADER struct {
UsbUserRequest uint32
UsbUserStatusCode int32
RequestBufferLength uint32
ActualBufferLength uint32
}
type USB_CLOSE_RAW_DEVICE_PARAMETERS struct {
xxx uint32
}
type USBUSER_CLOSE_RAW_DEVICE struct {
Header USBUSER_REQUEST_HEADER
Parameters USB_CLOSE_RAW_DEVICE_PARAMETERS
}type
USBUSER_REQUEST_HEADER = packed record
UsbUserRequest: DWORD;
UsbUserStatusCode: Integer;
RequestBufferLength: DWORD;
ActualBufferLength: DWORD;
end;
USB_CLOSE_RAW_DEVICE_PARAMETERS = packed record
xxx: DWORD;
end;
USBUSER_CLOSE_RAW_DEVICE = packed record
Header: USBUSER_REQUEST_HEADER;
Parameters: USB_CLOSE_RAW_DEVICE_PARAMETERS;
end;const USBUSER_REQUEST_HEADER = extern struct {
UsbUserRequest: u32,
UsbUserStatusCode: i32,
RequestBufferLength: u32,
ActualBufferLength: u32,
};
const USB_CLOSE_RAW_DEVICE_PARAMETERS = extern struct {
xxx: u32,
};
const USBUSER_CLOSE_RAW_DEVICE = extern struct {
Header: USBUSER_REQUEST_HEADER,
Parameters: USB_CLOSE_RAW_DEVICE_PARAMETERS,
};type
USBUSER_REQUEST_HEADER {.packed.} = object
UsbUserRequest: uint32
UsbUserStatusCode: int32
RequestBufferLength: uint32
ActualBufferLength: uint32
USB_CLOSE_RAW_DEVICE_PARAMETERS {.packed.} = object
xxx: uint32
USBUSER_CLOSE_RAW_DEVICE {.packed.} = object
Header: USBUSER_REQUEST_HEADER
Parameters: USB_CLOSE_RAW_DEVICE_PARAMETERSalign(1)
struct USBUSER_REQUEST_HEADER
{
uint UsbUserRequest;
int UsbUserStatusCode;
uint RequestBufferLength;
uint ActualBufferLength;
}
align(1)
struct USB_CLOSE_RAW_DEVICE_PARAMETERS
{
uint xxx;
}
align(1)
struct USBUSER_CLOSE_RAW_DEVICE
{
USBUSER_REQUEST_HEADER Header;
USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USBUSER_CLOSE_RAW_DEVICE サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; Header : USBUSER_REQUEST_HEADER (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; Parameters : USB_CLOSE_RAW_DEVICE_PARAMETERS (+16, 4byte) varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; ※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_CLOSE_RAW_DEVICE_PARAMETERS, pack=1
#field int xxx
#endstruct
#defstruct global USBUSER_CLOSE_RAW_DEVICE, pack=1
#field USBUSER_REQUEST_HEADER Header
#field USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters
#endstruct
stdim st, USBUSER_CLOSE_RAW_DEVICE ; NSTRUCT 変数を確保