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