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

DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP

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

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

フィールド

フィールドサイズx64x86説明
DescriptorDEVICEDUMP_STRUCTURE_VERSION12+0+0構造体のシグネチャ・バージョン・サイズを示すDEVICEDUMP_STRUCTURE_VERSION。
dwReasonForCollectionDWORD4+12+12ダンプ収集の理由を示すコード。
cDriverNameBYTE16+16+16ダンプを生成したドライバ名を示すバイト配列。
uiNumRecordsDWORD4+32+32RecordArrayに含まれる状態レコードの数。
RecordArrayDEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD64/60+36+36DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD構造体の可変長配列。各コマンド履歴を保持する。

各言語での定義

#include <windows.h>

// DEVICEDUMP_STRUCTURE_VERSION  (x64 12 / x86 12 バイト)
#pragma pack(push, 1)
typedef struct DEVICEDUMP_STRUCTURE_VERSION {
    DWORD dwSignature;
    DWORD dwVersion;
    DWORD dwSize;
} DEVICEDUMP_STRUCTURE_VERSION;
#pragma pack(pop)

// DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD  (x64 64 / x86 60 バイト)
#pragma pack(push, 1)
typedef struct DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD {
    BYTE Cdb[16];
    BYTE Command[16];
    ULONGLONG StartTime;
    ULONGLONG EndTime;
    DWORD OperationStatus;
    DWORD OperationError;
    _StackSpecific_e__Union StackSpecific;
} DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD;
#pragma pack(pop)

// DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP  (x64 100 / x86 96 バイト)
#pragma pack(push, 1)
typedef struct DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP {
    DEVICEDUMP_STRUCTURE_VERSION Descriptor;
    DWORD dwReasonForCollection;
    BYTE cDriverName[16];
    DWORD uiNumRecords;
    DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD RecordArray[1];
} DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DEVICEDUMP_STRUCTURE_VERSION
{
    public uint dwSignature;
    public uint dwVersion;
    public uint dwSize;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Cdb;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Command;
    public ulong StartTime;
    public ulong EndTime;
    public uint OperationStatus;
    public uint OperationError;
    public _StackSpecific_e__Union StackSpecific;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP
{
    public DEVICEDUMP_STRUCTURE_VERSION Descriptor;
    public uint dwReasonForCollection;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] cDriverName;
    public uint uiNumRecords;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD[] RecordArray;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DEVICEDUMP_STRUCTURE_VERSION
    Public dwSignature As UInteger
    Public dwVersion As UInteger
    Public dwSize As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Cdb() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Command() As Byte
    Public StartTime As ULong
    Public EndTime As ULong
    Public OperationStatus As UInteger
    Public OperationError As UInteger
    Public StackSpecific As _StackSpecific_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP
    Public Descriptor As DEVICEDUMP_STRUCTURE_VERSION
    Public dwReasonForCollection As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public cDriverName() As Byte
    Public uiNumRecords As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public RecordArray() As DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD
End Structure
import ctypes
from ctypes import wintypes

class DEVICEDUMP_STRUCTURE_VERSION(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("dwSignature", wintypes.DWORD),
        ("dwVersion", wintypes.DWORD),
        ("dwSize", wintypes.DWORD),
    ]

class DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Cdb", ctypes.c_ubyte * 16),
        ("Command", ctypes.c_ubyte * 16),
        ("StartTime", ctypes.c_ulonglong),
        ("EndTime", ctypes.c_ulonglong),
        ("OperationStatus", wintypes.DWORD),
        ("OperationError", wintypes.DWORD),
        ("StackSpecific", _StackSpecific_e__Union),
    ]

class DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Descriptor", DEVICEDUMP_STRUCTURE_VERSION),
        ("dwReasonForCollection", wintypes.DWORD),
        ("cDriverName", ctypes.c_ubyte * 16),
        ("uiNumRecords", wintypes.DWORD),
        ("RecordArray", DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD * 1),
    ]
#[repr(C, packed(1))]
pub struct DEVICEDUMP_STRUCTURE_VERSION {
    pub dwSignature: u32,
    pub dwVersion: u32,
    pub dwSize: u32,
}

#[repr(C, packed(1))]
pub struct DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD {
    pub Cdb: [u8; 16],
    pub Command: [u8; 16],
    pub StartTime: u64,
    pub EndTime: u64,
    pub OperationStatus: u32,
    pub OperationError: u32,
    pub StackSpecific: _StackSpecific_e__Union,
}

#[repr(C, packed(1))]
pub struct DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP {
    pub Descriptor: DEVICEDUMP_STRUCTURE_VERSION,
    pub dwReasonForCollection: u32,
    pub cDriverName: [u8; 16],
    pub uiNumRecords: u32,
    pub RecordArray: [DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD; 1],
}
import "golang.org/x/sys/windows"

type DEVICEDUMP_STRUCTURE_VERSION struct {
	dwSignature uint32
	dwVersion uint32
	dwSize uint32
}

type DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD struct {
	Cdb [16]byte
	Command [16]byte
	StartTime uint64
	EndTime uint64
	OperationStatus uint32
	OperationError uint32
	StackSpecific _StackSpecific_e__Union
}

type DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP struct {
	Descriptor DEVICEDUMP_STRUCTURE_VERSION
	dwReasonForCollection uint32
	cDriverName [16]byte
	uiNumRecords uint32
	RecordArray [1]DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD
}
type
  DEVICEDUMP_STRUCTURE_VERSION = packed record
    dwSignature: DWORD;
    dwVersion: DWORD;
    dwSize: DWORD;
  end;

  DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD = packed record
    Cdb: array[0..15] of Byte;
    Command: array[0..15] of Byte;
    StartTime: UInt64;
    EndTime: UInt64;
    OperationStatus: DWORD;
    OperationError: DWORD;
    StackSpecific: _StackSpecific_e__Union;
  end;

  DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP = packed record
    Descriptor: DEVICEDUMP_STRUCTURE_VERSION;
    dwReasonForCollection: DWORD;
    cDriverName: array[0..15] of Byte;
    uiNumRecords: DWORD;
    RecordArray: array[0..0] of DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD;
  end;
const DEVICEDUMP_STRUCTURE_VERSION = extern struct {
    dwSignature: u32,
    dwVersion: u32,
    dwSize: u32,
};

const DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD = extern struct {
    Cdb: [16]u8,
    Command: [16]u8,
    StartTime: u64,
    EndTime: u64,
    OperationStatus: u32,
    OperationError: u32,
    StackSpecific: _StackSpecific_e__Union,
};

const DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP = extern struct {
    Descriptor: DEVICEDUMP_STRUCTURE_VERSION,
    dwReasonForCollection: u32,
    cDriverName: [16]u8,
    uiNumRecords: u32,
    RecordArray: [1]DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD,
};
type
  DEVICEDUMP_STRUCTURE_VERSION {.packed.} = object
    dwSignature: uint32
    dwVersion: uint32
    dwSize: uint32

  DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD {.packed.} = object
    Cdb: array[16, uint8]
    Command: array[16, uint8]
    StartTime: uint64
    EndTime: uint64
    OperationStatus: uint32
    OperationError: uint32
    StackSpecific: _StackSpecific_e__Union

  DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP {.packed.} = object
    Descriptor: DEVICEDUMP_STRUCTURE_VERSION
    dwReasonForCollection: uint32
    cDriverName: array[16, uint8]
    uiNumRecords: uint32
    RecordArray: array[1, DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD]
align(1)
struct DEVICEDUMP_STRUCTURE_VERSION
{
    uint dwSignature;
    uint dwVersion;
    uint dwSize;
}

align(1)
struct DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD
{
    ubyte[16] Cdb;
    ubyte[16] Command;
    ulong StartTime;
    ulong EndTime;
    uint OperationStatus;
    uint OperationError;
    _StackSpecific_e__Union StackSpecific;
}

align(1)
struct DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP
{
    DEVICEDUMP_STRUCTURE_VERSION Descriptor;
    uint dwReasonForCollection;
    ubyte[16] cDriverName;
    uint uiNumRecords;
    DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD[1] RecordArray;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP サイズ: 96 バイト(x86)
dim st, 24    ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; Descriptor : DEVICEDUMP_STRUCTURE_VERSION (+0, 12byte)  varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; dwReasonForCollection : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; cDriverName : BYTE (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; uiNumRecords : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; RecordArray : DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD (+36, 60byte)  varptr(st)+36 を基点に操作(60byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP サイズ: 100 バイト(x64)
dim st, 25    ; 4byte整数×25(構造体サイズ 100 / 4 切り上げ)
; Descriptor : DEVICEDUMP_STRUCTURE_VERSION (+0, 12byte)  varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; dwReasonForCollection : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; cDriverName : BYTE (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; uiNumRecords : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; RecordArray : DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD (+36, 64byte)  varptr(st)+36 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DEVICEDUMP_STRUCTURE_VERSION, pack=1
    #field int dwSignature
    #field int dwVersion
    #field int dwSize
#endstruct

#defstruct global DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD, pack=1
    #field byte Cdb 16
    #field byte Command 16
    #field int64 StartTime
    #field int64 EndTime
    #field int OperationStatus
    #field int OperationError
    #field byte StackSpecific 8
#endstruct

#defstruct global DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP, pack=1
    #field DEVICEDUMP_STRUCTURE_VERSION Descriptor
    #field int dwReasonForCollection
    #field byte cDriverName 16
    #field int uiNumRecords
    #field DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD RecordArray 1
#endstruct

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