Win32 API 日本語リファレンス
ホームSystem.Ioctl › STORAGE_PROTOCOL_COMMAND

STORAGE_PROTOCOL_COMMAND

構造体
サイズx64: 84 バイト / x86: 84 バイト

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0この構造体のバージョンです。STORAGE_PROTOCOL_STRUCTURE_VERSION に設定してください。
LengthDWORD4+4+4この構造体のサイズです。sizeof(STORAGE_PROTOCOL_COMMAND) に設定してください。
ProtocolTypeSTORAGE_PROTOCOL_TYPE4+8+8プロトコルの種類です。型は STORAGE_PROTOCOL_TYPE です。
FlagsDWORD4+12+12

この要求に設定するフラグです。有効なフラグは次のとおりです。

フラグ 説明
STORAGE_PROTOCOL_COMMAND_FLAG_ADAPTER_REQUEST このフラグは、要求の対象がデバイスではなくアダプターであることを示します。
ReturnStatusDWORD4+16+16

ストレージデバイスに対して行われた要求の状態です。Windows 10 では、次の値が使用されます。

状態の値 説明
STORAGE_PROTOCOL_STATUS_PENDING 要求は保留中です。
STORAGE_PROTOCOL_STATUS_SUCCESS 要求は正常に完了しました。
STORAGE_PROTOCOL_STATUS_ERROR 要求でエラーが発生しました。
STORAGE_PROTOCOL_STATUS_INVALID_REQUEST 要求が無効です。
STORAGE_PROTOCOL_STATUS_NO_DEVICE 要求を発行する対象のデバイスが利用できません。
STORAGE_PROTOCOL_STATUS_BUSY デバイスは要求の処理中でビジー状態です。
STORAGE_PROTOCOL_STATUS_DATA_OVERRUN デバイスは要求の処理中にデータオーバーランを検出しました。
STORAGE_PROTOCOL_STATUS_INSUFFICIENT_RESOURCES リソースが不足しているため、デバイスは要求を完了できません。
STORAGE_PROTOCOL_STATUS_NOT_SUPPORTED 要求はサポートされていません。
ErrorCodeDWORD4+20+20この要求のエラーコードです。これは任意で設定します。
CommandLengthDWORD4+24+24コマンドの長さです。呼び出し元が 0 以外の値を設定しなければなりません。
ErrorInfoLengthDWORD4+28+28エラーバッファーの長さです。これは任意で設定するもので、0 を設定できます。
DataToDeviceTransferLengthDWORD4+32+32デバイスへ転送するバッファーのサイズです。これは WRITE 要求でのみ使用されます。
DataFromDeviceTransferLengthDWORD4+36+36デバイスから転送されるバッファーのサイズです。これは READ 要求でのみ使用されます。
TimeOutValueDWORD4+40+40タイムアウトするまでデバイスを待機する時間です。これは秒単位で設定します。
ErrorInfoOffsetDWORD4+44+44エラーバッファーのオフセットです。ポインター境界に整列していなければなりません。
DataToDeviceBufferOffsetDWORD4+48+48デバイスへ転送するバッファーのオフセットです。ポインター境界に整列していなければならず、WRITE 要求でのみ使用されます。
DataFromDeviceBufferOffsetDWORD4+52+52デバイスから転送されるバッファーのオフセットです。ポインター境界に整列していなければならず、READ 要求でのみ使用されます。
CommandSpecificDWORD4+56+56コマンドとともに渡される、コマンド固有のデータです。内容はドライバーからのコマンドによって異なり、任意で設定します。
Reserved0DWORD4+60+60将来の使用のために予約済みです。
FixedProtocolReturnDataDWORD4+64+64返されるデータです。これは任意で設定します。NVMe などの一部のプロトコルでは、デバイスとの個別のデータ転送を行わずに少量のデータ (完了キューエントリの DWORD0) を返す場合があります。
FixedProtocolReturnData2DWORD4+68+68プロトコル固有の追加の固定返却データ領域。
Reserved1DWORD8+72+72将来の使用のために予約済みです。
CommandBYTE1+80+80デバイスへパススルーされるベンダー固有のコマンドです。

公式ドキュメント

この構造体は、パススルー機構を使用してストレージデバイスにベンダー固有のコマンドを発行する際 (IOCTL_STORAGE_PROTOCOL_COMMAND を使用) に、入力バッファーとして使用されます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// STORAGE_PROTOCOL_COMMAND  (x64 84 / x86 84 バイト)
typedef struct STORAGE_PROTOCOL_COMMAND {
    DWORD Version;
    DWORD Length;
    STORAGE_PROTOCOL_TYPE ProtocolType;
    DWORD Flags;
    DWORD ReturnStatus;
    DWORD ErrorCode;
    DWORD CommandLength;
    DWORD ErrorInfoLength;
    DWORD DataToDeviceTransferLength;
    DWORD DataFromDeviceTransferLength;
    DWORD TimeOutValue;
    DWORD ErrorInfoOffset;
    DWORD DataToDeviceBufferOffset;
    DWORD DataFromDeviceBufferOffset;
    DWORD CommandSpecific;
    DWORD Reserved0;
    DWORD FixedProtocolReturnData;
    DWORD FixedProtocolReturnData2;
    DWORD Reserved1[2];
    BYTE Command[1];
} STORAGE_PROTOCOL_COMMAND;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_PROTOCOL_COMMAND
{
    public uint Version;
    public uint Length;
    public int ProtocolType;
    public uint Flags;
    public uint ReturnStatus;
    public uint ErrorCode;
    public uint CommandLength;
    public uint ErrorInfoLength;
    public uint DataToDeviceTransferLength;
    public uint DataFromDeviceTransferLength;
    public uint TimeOutValue;
    public uint ErrorInfoOffset;
    public uint DataToDeviceBufferOffset;
    public uint DataFromDeviceBufferOffset;
    public uint CommandSpecific;
    public uint Reserved0;
    public uint FixedProtocolReturnData;
    public uint FixedProtocolReturnData2;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] Reserved1;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Command;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_PROTOCOL_COMMAND
    Public Version As UInteger
    Public Length As UInteger
    Public ProtocolType As Integer
    Public Flags As UInteger
    Public ReturnStatus As UInteger
    Public ErrorCode As UInteger
    Public CommandLength As UInteger
    Public ErrorInfoLength As UInteger
    Public DataToDeviceTransferLength As UInteger
    Public DataFromDeviceTransferLength As UInteger
    Public TimeOutValue As UInteger
    Public ErrorInfoOffset As UInteger
    Public DataToDeviceBufferOffset As UInteger
    Public DataFromDeviceBufferOffset As UInteger
    Public CommandSpecific As UInteger
    Public Reserved0 As UInteger
    Public FixedProtocolReturnData As UInteger
    Public FixedProtocolReturnData2 As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Reserved1() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Command() As Byte
End Structure
import ctypes
from ctypes import wintypes

class STORAGE_PROTOCOL_COMMAND(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Length", wintypes.DWORD),
        ("ProtocolType", ctypes.c_int),
        ("Flags", wintypes.DWORD),
        ("ReturnStatus", wintypes.DWORD),
        ("ErrorCode", wintypes.DWORD),
        ("CommandLength", wintypes.DWORD),
        ("ErrorInfoLength", wintypes.DWORD),
        ("DataToDeviceTransferLength", wintypes.DWORD),
        ("DataFromDeviceTransferLength", wintypes.DWORD),
        ("TimeOutValue", wintypes.DWORD),
        ("ErrorInfoOffset", wintypes.DWORD),
        ("DataToDeviceBufferOffset", wintypes.DWORD),
        ("DataFromDeviceBufferOffset", wintypes.DWORD),
        ("CommandSpecific", wintypes.DWORD),
        ("Reserved0", wintypes.DWORD),
        ("FixedProtocolReturnData", wintypes.DWORD),
        ("FixedProtocolReturnData2", wintypes.DWORD),
        ("Reserved1", wintypes.DWORD * 2),
        ("Command", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct STORAGE_PROTOCOL_COMMAND {
    pub Version: u32,
    pub Length: u32,
    pub ProtocolType: i32,
    pub Flags: u32,
    pub ReturnStatus: u32,
    pub ErrorCode: u32,
    pub CommandLength: u32,
    pub ErrorInfoLength: u32,
    pub DataToDeviceTransferLength: u32,
    pub DataFromDeviceTransferLength: u32,
    pub TimeOutValue: u32,
    pub ErrorInfoOffset: u32,
    pub DataToDeviceBufferOffset: u32,
    pub DataFromDeviceBufferOffset: u32,
    pub CommandSpecific: u32,
    pub Reserved0: u32,
    pub FixedProtocolReturnData: u32,
    pub FixedProtocolReturnData2: u32,
    pub Reserved1: [u32; 2],
    pub Command: [u8; 1],
}
import "golang.org/x/sys/windows"

type STORAGE_PROTOCOL_COMMAND struct {
	Version uint32
	Length uint32
	ProtocolType int32
	Flags uint32
	ReturnStatus uint32
	ErrorCode uint32
	CommandLength uint32
	ErrorInfoLength uint32
	DataToDeviceTransferLength uint32
	DataFromDeviceTransferLength uint32
	TimeOutValue uint32
	ErrorInfoOffset uint32
	DataToDeviceBufferOffset uint32
	DataFromDeviceBufferOffset uint32
	CommandSpecific uint32
	Reserved0 uint32
	FixedProtocolReturnData uint32
	FixedProtocolReturnData2 uint32
	Reserved1 [2]uint32
	Command [1]byte
}
type
  STORAGE_PROTOCOL_COMMAND = record
    Version: DWORD;
    Length: DWORD;
    ProtocolType: Integer;
    Flags: DWORD;
    ReturnStatus: DWORD;
    ErrorCode: DWORD;
    CommandLength: DWORD;
    ErrorInfoLength: DWORD;
    DataToDeviceTransferLength: DWORD;
    DataFromDeviceTransferLength: DWORD;
    TimeOutValue: DWORD;
    ErrorInfoOffset: DWORD;
    DataToDeviceBufferOffset: DWORD;
    DataFromDeviceBufferOffset: DWORD;
    CommandSpecific: DWORD;
    Reserved0: DWORD;
    FixedProtocolReturnData: DWORD;
    FixedProtocolReturnData2: DWORD;
    Reserved1: array[0..1] of DWORD;
    Command: array[0..0] of Byte;
  end;
const STORAGE_PROTOCOL_COMMAND = extern struct {
    Version: u32,
    Length: u32,
    ProtocolType: i32,
    Flags: u32,
    ReturnStatus: u32,
    ErrorCode: u32,
    CommandLength: u32,
    ErrorInfoLength: u32,
    DataToDeviceTransferLength: u32,
    DataFromDeviceTransferLength: u32,
    TimeOutValue: u32,
    ErrorInfoOffset: u32,
    DataToDeviceBufferOffset: u32,
    DataFromDeviceBufferOffset: u32,
    CommandSpecific: u32,
    Reserved0: u32,
    FixedProtocolReturnData: u32,
    FixedProtocolReturnData2: u32,
    Reserved1: [2]u32,
    Command: [1]u8,
};
type
  STORAGE_PROTOCOL_COMMAND {.bycopy.} = object
    Version: uint32
    Length: uint32
    ProtocolType: int32
    Flags: uint32
    ReturnStatus: uint32
    ErrorCode: uint32
    CommandLength: uint32
    ErrorInfoLength: uint32
    DataToDeviceTransferLength: uint32
    DataFromDeviceTransferLength: uint32
    TimeOutValue: uint32
    ErrorInfoOffset: uint32
    DataToDeviceBufferOffset: uint32
    DataFromDeviceBufferOffset: uint32
    CommandSpecific: uint32
    Reserved0: uint32
    FixedProtocolReturnData: uint32
    FixedProtocolReturnData2: uint32
    Reserved1: array[2, uint32]
    Command: array[1, uint8]
struct STORAGE_PROTOCOL_COMMAND
{
    uint Version;
    uint Length;
    int ProtocolType;
    uint Flags;
    uint ReturnStatus;
    uint ErrorCode;
    uint CommandLength;
    uint ErrorInfoLength;
    uint DataToDeviceTransferLength;
    uint DataFromDeviceTransferLength;
    uint TimeOutValue;
    uint ErrorInfoOffset;
    uint DataToDeviceBufferOffset;
    uint DataFromDeviceBufferOffset;
    uint CommandSpecific;
    uint Reserved0;
    uint FixedProtocolReturnData;
    uint FixedProtocolReturnData2;
    uint[2] Reserved1;
    ubyte[1] Command;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_PROTOCOL_COMMAND サイズ: 84 バイト(x64)
dim st, 21    ; 4byte整数×21(構造体サイズ 84 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Length : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ProtocolType : STORAGE_PROTOCOL_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Flags : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ReturnStatus : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ErrorCode : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; CommandLength : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ErrorInfoLength : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; DataToDeviceTransferLength : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; DataFromDeviceTransferLength : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; TimeOutValue : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; ErrorInfoOffset : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; DataToDeviceBufferOffset : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; DataFromDeviceBufferOffset : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; CommandSpecific : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; Reserved0 : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; FixedProtocolReturnData : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; FixedProtocolReturnData2 : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; Reserved1 : DWORD (+72, 8byte)  varptr(st)+72 を基点に操作(8byte:入れ子/配列)
; Command : BYTE (+80, 1byte)  varptr(st)+80 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global STORAGE_PROTOCOL_COMMAND
    #field int Version
    #field int Length
    #field int ProtocolType
    #field int Flags
    #field int ReturnStatus
    #field int ErrorCode
    #field int CommandLength
    #field int ErrorInfoLength
    #field int DataToDeviceTransferLength
    #field int DataFromDeviceTransferLength
    #field int TimeOutValue
    #field int ErrorInfoOffset
    #field int DataToDeviceBufferOffset
    #field int DataFromDeviceBufferOffset
    #field int CommandSpecific
    #field int Reserved0
    #field int FixedProtocolReturnData
    #field int FixedProtocolReturnData2
    #field int Reserved1 2
    #field byte Command 1
#endstruct

stdim st, STORAGE_PROTOCOL_COMMAND        ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version