ホーム › System.Ioctl › SENDCMDOUTPARAMS
SENDCMDOUTPARAMS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cBufferSize | DWORD | 4 | +0 | +0 | bBufferのバイト単位のサイズ。 |
| DriverStatus | DRIVERSTATUS | 12 | +4 | +4 | コマンド実行のドライバステータス。DRIVERSTATUS構造体。 |
| bBuffer | BYTE | 1 | +16 | +16 | コマンドの出力データバッファ。可変長配列。 |
各言語での定義
#include <windows.h>
// DRIVERSTATUS (x64 12 / x86 12 バイト)
#pragma pack(push, 1)
typedef struct DRIVERSTATUS {
BYTE bDriverError;
BYTE bIDEError;
BYTE bReserved[2];
DWORD dwReserved[2];
} DRIVERSTATUS;
#pragma pack(pop)
// SENDCMDOUTPARAMS (x64 17 / x86 17 バイト)
#pragma pack(push, 1)
typedef struct SENDCMDOUTPARAMS {
DWORD cBufferSize;
DRIVERSTATUS DriverStatus;
BYTE bBuffer[1];
} SENDCMDOUTPARAMS;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DRIVERSTATUS
{
public byte bDriverError;
public byte bIDEError;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] bReserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] dwReserved;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SENDCMDOUTPARAMS
{
public uint cBufferSize;
public DRIVERSTATUS DriverStatus;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] bBuffer;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DRIVERSTATUS
Public bDriverError As Byte
Public bIDEError As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public bReserved() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public dwReserved() As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SENDCMDOUTPARAMS
Public cBufferSize As UInteger
Public DriverStatus As DRIVERSTATUS
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public bBuffer() As Byte
End Structureimport ctypes
from ctypes import wintypes
class DRIVERSTATUS(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bDriverError", ctypes.c_ubyte),
("bIDEError", ctypes.c_ubyte),
("bReserved", ctypes.c_ubyte * 2),
("dwReserved", wintypes.DWORD * 2),
]
class SENDCMDOUTPARAMS(ctypes.Structure):
_pack_ = 1
_fields_ = [
("cBufferSize", wintypes.DWORD),
("DriverStatus", DRIVERSTATUS),
("bBuffer", ctypes.c_ubyte * 1),
]#[repr(C, packed(1))]
pub struct DRIVERSTATUS {
pub bDriverError: u8,
pub bIDEError: u8,
pub bReserved: [u8; 2],
pub dwReserved: [u32; 2],
}
#[repr(C, packed(1))]
pub struct SENDCMDOUTPARAMS {
pub cBufferSize: u32,
pub DriverStatus: DRIVERSTATUS,
pub bBuffer: [u8; 1],
}import "golang.org/x/sys/windows"
type DRIVERSTATUS struct {
bDriverError byte
bIDEError byte
bReserved [2]byte
dwReserved [2]uint32
}
type SENDCMDOUTPARAMS struct {
cBufferSize uint32
DriverStatus DRIVERSTATUS
bBuffer [1]byte
}type
DRIVERSTATUS = packed record
bDriverError: Byte;
bIDEError: Byte;
bReserved: array[0..1] of Byte;
dwReserved: array[0..1] of DWORD;
end;
SENDCMDOUTPARAMS = packed record
cBufferSize: DWORD;
DriverStatus: DRIVERSTATUS;
bBuffer: array[0..0] of Byte;
end;const DRIVERSTATUS = extern struct {
bDriverError: u8,
bIDEError: u8,
bReserved: [2]u8,
dwReserved: [2]u32,
};
const SENDCMDOUTPARAMS = extern struct {
cBufferSize: u32,
DriverStatus: DRIVERSTATUS,
bBuffer: [1]u8,
};type
DRIVERSTATUS {.packed.} = object
bDriverError: uint8
bIDEError: uint8
bReserved: array[2, uint8]
dwReserved: array[2, uint32]
SENDCMDOUTPARAMS {.packed.} = object
cBufferSize: uint32
DriverStatus: DRIVERSTATUS
bBuffer: array[1, uint8]align(1)
struct DRIVERSTATUS
{
ubyte bDriverError;
ubyte bIDEError;
ubyte[2] bReserved;
uint[2] dwReserved;
}
align(1)
struct SENDCMDOUTPARAMS
{
uint cBufferSize;
DRIVERSTATUS DriverStatus;
ubyte[1] bBuffer;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SENDCMDOUTPARAMS サイズ: 17 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 17 / 4 切り上げ)
; cBufferSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; DriverStatus : DRIVERSTATUS (+4, 12byte) varptr(st)+4 を基点に操作(12byte:入れ子/配列)
; bBuffer : BYTE (+16, 1byte) varptr(st)+16 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DRIVERSTATUS, pack=1
#field byte bDriverError
#field byte bIDEError
#field byte bReserved 2
#field int dwReserved 2
#endstruct
#defstruct global SENDCMDOUTPARAMS, pack=1
#field int cBufferSize
#field DRIVERSTATUS DriverStatus
#field byte bBuffer 1
#endstruct
stdim st, SENDCMDOUTPARAMS ; NSTRUCT 変数を確保
st->cBufferSize = 100
mes "cBufferSize=" + st->cBufferSize