サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
コピー #include <windows.h>
// NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 (x64 512 / x86 512 バイト)
#pragma pack(push, 1)
typedef struct NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 {
BYTE MediaUnitsWritten[16];
BYTE MediaUnitsRead[16];
_BadUserNANDBlockCount_e__Struct BadUserNANDBlockCount;
_BadSystemNANDBlockCount_e__Struct BadSystemNANDBlockCount;
ULONGLONG XORRecoveryCount;
ULONGLONG UnrecoverableReadErrorCount;
ULONGLONG SoftECCErrorCount;
_EndToEndCorrectionCounts_e__Struct EndToEndCorrectionCounts;
BYTE PercentageSystemDataUsed;
BYTE RefreshCount[7];
_UserDataEraseCounts_e__Struct UserDataEraseCounts;
_ThermalThrottling_e__Struct ThermalThrottling;
BYTE Reserved0[6];
ULONGLONG PCIeCorrectableErrorCount;
DWORD IncompleteShutdownCount;
DWORD Reserved1;
BYTE PercentageFreeBlocks;
BYTE Reserved2[7];
WORD CapacitorHealth;
BYTE Reserved3[6];
ULONGLONG UnalignedIOCount;
ULONGLONG SecurityVersionNumber;
ULONGLONG NUSE;
BYTE PLPStartCount[16];
BYTE EnduranceEstimate[16];
BYTE Reserved4[302];
WORD LogPageVersionNumber;
GUID LogPageGUID;
} NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2;
#pragma pack(pop)コピー using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] MediaUnitsWritten;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] MediaUnitsRead;
public _BadUserNANDBlockCount_e__Struct BadUserNANDBlockCount;
public _BadSystemNANDBlockCount_e__Struct BadSystemNANDBlockCount;
public ulong XORRecoveryCount;
public ulong UnrecoverableReadErrorCount;
public ulong SoftECCErrorCount;
public _EndToEndCorrectionCounts_e__Struct EndToEndCorrectionCounts;
public byte PercentageSystemDataUsed;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] public byte[] RefreshCount;
public _UserDataEraseCounts_e__Struct UserDataEraseCounts;
public _ThermalThrottling_e__Struct ThermalThrottling;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] Reserved0;
public ulong PCIeCorrectableErrorCount;
public uint IncompleteShutdownCount;
public uint Reserved1;
public byte PercentageFreeBlocks;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] public byte[] Reserved2;
public ushort CapacitorHealth;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] Reserved3;
public ulong UnalignedIOCount;
public ulong SecurityVersionNumber;
public ulong NUSE;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] PLPStartCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] EnduranceEstimate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 302)] public byte[] Reserved4;
public ushort LogPageVersionNumber;
public Guid LogPageGUID;
}コピー Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public MediaUnitsWritten() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public MediaUnitsRead() As Byte
Public BadUserNANDBlockCount As _BadUserNANDBlockCount_e__Struct
Public BadSystemNANDBlockCount As _BadSystemNANDBlockCount_e__Struct
Public XORRecoveryCount As ULong
Public UnrecoverableReadErrorCount As ULong
Public SoftECCErrorCount As ULong
Public EndToEndCorrectionCounts As _EndToEndCorrectionCounts_e__Struct
Public PercentageSystemDataUsed As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=7)> Public RefreshCount() As Byte
Public UserDataEraseCounts As _UserDataEraseCounts_e__Struct
Public ThermalThrottling As _ThermalThrottling_e__Struct
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Public Reserved0() As Byte
Public PCIeCorrectableErrorCount As ULong
Public IncompleteShutdownCount As UInteger
Public Reserved1 As UInteger
Public PercentageFreeBlocks As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=7)> Public Reserved2() As Byte
Public CapacitorHealth As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Public Reserved3() As Byte
Public UnalignedIOCount As ULong
Public SecurityVersionNumber As ULong
Public NUSE As ULong
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public PLPStartCount() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public EnduranceEstimate() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=302)> Public Reserved4() As Byte
Public LogPageVersionNumber As UShort
Public LogPageGUID As Guid
End Structureコピー import ctypes
from ctypes import wintypes
class NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2(ctypes.Structure):
_pack_ = 1
_fields_ = [
("MediaUnitsWritten", ctypes.c_ubyte * 16),
("MediaUnitsRead", ctypes.c_ubyte * 16),
("BadUserNANDBlockCount", _BadUserNANDBlockCount_e__Struct),
("BadSystemNANDBlockCount", _BadSystemNANDBlockCount_e__Struct),
("XORRecoveryCount", ctypes.c_ulonglong),
("UnrecoverableReadErrorCount", ctypes.c_ulonglong),
("SoftECCErrorCount", ctypes.c_ulonglong),
("EndToEndCorrectionCounts", _EndToEndCorrectionCounts_e__Struct),
("PercentageSystemDataUsed", ctypes.c_ubyte),
("RefreshCount", ctypes.c_ubyte * 7),
("UserDataEraseCounts", _UserDataEraseCounts_e__Struct),
("ThermalThrottling", _ThermalThrottling_e__Struct),
("Reserved0", ctypes.c_ubyte * 6),
("PCIeCorrectableErrorCount", ctypes.c_ulonglong),
("IncompleteShutdownCount", wintypes.DWORD),
("Reserved1", wintypes.DWORD),
("PercentageFreeBlocks", ctypes.c_ubyte),
("Reserved2", ctypes.c_ubyte * 7),
("CapacitorHealth", ctypes.c_ushort),
("Reserved3", ctypes.c_ubyte * 6),
("UnalignedIOCount", ctypes.c_ulonglong),
("SecurityVersionNumber", ctypes.c_ulonglong),
("NUSE", ctypes.c_ulonglong),
("PLPStartCount", ctypes.c_ubyte * 16),
("EnduranceEstimate", ctypes.c_ubyte * 16),
("Reserved4", ctypes.c_ubyte * 302),
("LogPageVersionNumber", ctypes.c_ushort),
("LogPageGUID", GUID),
]コピー #[repr(C, packed(1))]
pub struct NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 {
pub MediaUnitsWritten: [u8; 16],
pub MediaUnitsRead: [u8; 16],
pub BadUserNANDBlockCount: _BadUserNANDBlockCount_e__Struct,
pub BadSystemNANDBlockCount: _BadSystemNANDBlockCount_e__Struct,
pub XORRecoveryCount: u64,
pub UnrecoverableReadErrorCount: u64,
pub SoftECCErrorCount: u64,
pub EndToEndCorrectionCounts: _EndToEndCorrectionCounts_e__Struct,
pub PercentageSystemDataUsed: u8,
pub RefreshCount: [u8; 7],
pub UserDataEraseCounts: _UserDataEraseCounts_e__Struct,
pub ThermalThrottling: _ThermalThrottling_e__Struct,
pub Reserved0: [u8; 6],
pub PCIeCorrectableErrorCount: u64,
pub IncompleteShutdownCount: u32,
pub Reserved1: u32,
pub PercentageFreeBlocks: u8,
pub Reserved2: [u8; 7],
pub CapacitorHealth: u16,
pub Reserved3: [u8; 6],
pub UnalignedIOCount: u64,
pub SecurityVersionNumber: u64,
pub NUSE: u64,
pub PLPStartCount: [u8; 16],
pub EnduranceEstimate: [u8; 16],
pub Reserved4: [u8; 302],
pub LogPageVersionNumber: u16,
pub LogPageGUID: GUID,
}コピー import "golang.org/x/sys/windows"
type NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 struct {
MediaUnitsWritten [16]byte
MediaUnitsRead [16]byte
BadUserNANDBlockCount _BadUserNANDBlockCount_e__Struct
BadSystemNANDBlockCount _BadSystemNANDBlockCount_e__Struct
XORRecoveryCount uint64
UnrecoverableReadErrorCount uint64
SoftECCErrorCount uint64
EndToEndCorrectionCounts _EndToEndCorrectionCounts_e__Struct
PercentageSystemDataUsed byte
RefreshCount [7]byte
UserDataEraseCounts _UserDataEraseCounts_e__Struct
ThermalThrottling _ThermalThrottling_e__Struct
Reserved0 [6]byte
PCIeCorrectableErrorCount uint64
IncompleteShutdownCount uint32
Reserved1 uint32
PercentageFreeBlocks byte
Reserved2 [7]byte
CapacitorHealth uint16
Reserved3 [6]byte
UnalignedIOCount uint64
SecurityVersionNumber uint64
NUSE uint64
PLPStartCount [16]byte
EnduranceEstimate [16]byte
Reserved4 [302]byte
LogPageVersionNumber uint16
LogPageGUID windows.GUID
}コピー type
NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 = packed record
MediaUnitsWritten: array[0..15] of Byte;
MediaUnitsRead: array[0..15] of Byte;
BadUserNANDBlockCount: _BadUserNANDBlockCount_e__Struct;
BadSystemNANDBlockCount: _BadSystemNANDBlockCount_e__Struct;
XORRecoveryCount: UInt64;
UnrecoverableReadErrorCount: UInt64;
SoftECCErrorCount: UInt64;
EndToEndCorrectionCounts: _EndToEndCorrectionCounts_e__Struct;
PercentageSystemDataUsed: Byte;
RefreshCount: array[0..6] of Byte;
UserDataEraseCounts: _UserDataEraseCounts_e__Struct;
ThermalThrottling: _ThermalThrottling_e__Struct;
Reserved0: array[0..5] of Byte;
PCIeCorrectableErrorCount: UInt64;
IncompleteShutdownCount: DWORD;
Reserved1: DWORD;
PercentageFreeBlocks: Byte;
Reserved2: array[0..6] of Byte;
CapacitorHealth: Word;
Reserved3: array[0..5] of Byte;
UnalignedIOCount: UInt64;
SecurityVersionNumber: UInt64;
NUSE: UInt64;
PLPStartCount: array[0..15] of Byte;
EnduranceEstimate: array[0..15] of Byte;
Reserved4: array[0..301] of Byte;
LogPageVersionNumber: Word;
LogPageGUID: TGUID;
end;コピー const NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 = extern struct {
MediaUnitsWritten: [16]u8,
MediaUnitsRead: [16]u8,
BadUserNANDBlockCount: _BadUserNANDBlockCount_e__Struct,
BadSystemNANDBlockCount: _BadSystemNANDBlockCount_e__Struct,
XORRecoveryCount: u64,
UnrecoverableReadErrorCount: u64,
SoftECCErrorCount: u64,
EndToEndCorrectionCounts: _EndToEndCorrectionCounts_e__Struct,
PercentageSystemDataUsed: u8,
RefreshCount: [7]u8,
UserDataEraseCounts: _UserDataEraseCounts_e__Struct,
ThermalThrottling: _ThermalThrottling_e__Struct,
Reserved0: [6]u8,
PCIeCorrectableErrorCount: u64,
IncompleteShutdownCount: u32,
Reserved1: u32,
PercentageFreeBlocks: u8,
Reserved2: [7]u8,
CapacitorHealth: u16,
Reserved3: [6]u8,
UnalignedIOCount: u64,
SecurityVersionNumber: u64,
NUSE: u64,
PLPStartCount: [16]u8,
EnduranceEstimate: [16]u8,
Reserved4: [302]u8,
LogPageVersionNumber: u16,
LogPageGUID: GUID,
};コピー type
NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 {.packed.} = object
MediaUnitsWritten: array[16, uint8]
MediaUnitsRead: array[16, uint8]
BadUserNANDBlockCount: _BadUserNANDBlockCount_e__Struct
BadSystemNANDBlockCount: _BadSystemNANDBlockCount_e__Struct
XORRecoveryCount: uint64
UnrecoverableReadErrorCount: uint64
SoftECCErrorCount: uint64
EndToEndCorrectionCounts: _EndToEndCorrectionCounts_e__Struct
PercentageSystemDataUsed: uint8
RefreshCount: array[7, uint8]
UserDataEraseCounts: _UserDataEraseCounts_e__Struct
ThermalThrottling: _ThermalThrottling_e__Struct
Reserved0: array[6, uint8]
PCIeCorrectableErrorCount: uint64
IncompleteShutdownCount: uint32
Reserved1: uint32
PercentageFreeBlocks: uint8
Reserved2: array[7, uint8]
CapacitorHealth: uint16
Reserved3: array[6, uint8]
UnalignedIOCount: uint64
SecurityVersionNumber: uint64
NUSE: uint64
PLPStartCount: array[16, uint8]
EnduranceEstimate: array[16, uint8]
Reserved4: array[302, uint8]
LogPageVersionNumber: uint16
LogPageGUID: GUIDコピー align(1)
struct NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2
{
ubyte[16] MediaUnitsWritten;
ubyte[16] MediaUnitsRead;
_BadUserNANDBlockCount_e__Struct BadUserNANDBlockCount;
_BadSystemNANDBlockCount_e__Struct BadSystemNANDBlockCount;
ulong XORRecoveryCount;
ulong UnrecoverableReadErrorCount;
ulong SoftECCErrorCount;
_EndToEndCorrectionCounts_e__Struct EndToEndCorrectionCounts;
ubyte PercentageSystemDataUsed;
ubyte[7] RefreshCount;
_UserDataEraseCounts_e__Struct UserDataEraseCounts;
_ThermalThrottling_e__Struct ThermalThrottling;
ubyte[6] Reserved0;
ulong PCIeCorrectableErrorCount;
uint IncompleteShutdownCount;
uint Reserved1;
ubyte PercentageFreeBlocks;
ubyte[7] Reserved2;
ushort CapacitorHealth;
ubyte[6] Reserved3;
ulong UnalignedIOCount;
ulong SecurityVersionNumber;
ulong NUSE;
ubyte[16] PLPStartCount;
ubyte[16] EnduranceEstimate;
ubyte[302] Reserved4;
ushort LogPageVersionNumber;
GUID LogPageGUID;
}HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT (#defstruct/stdim/->)で32/64bit共通。
コピー ; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 サイズ: 512 バイト(x64)
dim st, 128 ; 4byte整数×128(構造体サイズ 512 / 4 切り上げ)
; MediaUnitsWritten : BYTE (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; MediaUnitsRead : BYTE (+16, 16byte) varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; BadUserNANDBlockCount : _BadUserNANDBlockCount_e__Struct (+32, 8byte) varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; BadSystemNANDBlockCount : _BadSystemNANDBlockCount_e__Struct (+40, 8byte) varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; XORRecoveryCount : ULONGLONG (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; UnrecoverableReadErrorCount : ULONGLONG (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; SoftECCErrorCount : ULONGLONG (+64, 8byte) qpoke st,64,値 / qpeek(st,64) ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; EndToEndCorrectionCounts : _EndToEndCorrectionCounts_e__Struct (+72, 8byte) varptr(st)+72 を基点に操作(8byte:入れ子/配列)
; PercentageSystemDataUsed : BYTE (+80, 1byte) poke st,80,値 / 値 = peek(st,80)
; RefreshCount : BYTE (+81, 7byte) varptr(st)+81 を基点に操作(7byte:入れ子/配列)
; UserDataEraseCounts : _UserDataEraseCounts_e__Struct (+88, 8byte) varptr(st)+88 を基点に操作(8byte:入れ子/配列)
; ThermalThrottling : _ThermalThrottling_e__Struct (+96, 2byte) varptr(st)+96 を基点に操作(2byte:入れ子/配列)
; Reserved0 : BYTE (+98, 6byte) varptr(st)+98 を基点に操作(6byte:入れ子/配列)
; PCIeCorrectableErrorCount : ULONGLONG (+104, 8byte) qpoke st,104,値 / qpeek(st,104) ※IronHSPのみ。3.7/3.8は lpoke st,104,下位 : lpoke st,108,上位
; IncompleteShutdownCount : DWORD (+112, 4byte) st.28 = 値 / 値 = st.28 (lpoke/lpeek も可)
; Reserved1 : DWORD (+116, 4byte) st.29 = 値 / 値 = st.29 (lpoke/lpeek も可)
; PercentageFreeBlocks : BYTE (+120, 1byte) poke st,120,値 / 値 = peek(st,120)
; Reserved2 : BYTE (+121, 7byte) varptr(st)+121 を基点に操作(7byte:入れ子/配列)
; CapacitorHealth : WORD (+128, 2byte) wpoke st,128,値 / 値 = wpeek(st,128)
; Reserved3 : BYTE (+130, 6byte) varptr(st)+130 を基点に操作(6byte:入れ子/配列)
; UnalignedIOCount : ULONGLONG (+136, 8byte) qpoke st,136,値 / qpeek(st,136) ※IronHSPのみ。3.7/3.8は lpoke st,136,下位 : lpoke st,140,上位
; SecurityVersionNumber : ULONGLONG (+144, 8byte) qpoke st,144,値 / qpeek(st,144) ※IronHSPのみ。3.7/3.8は lpoke st,144,下位 : lpoke st,148,上位
; NUSE : ULONGLONG (+152, 8byte) qpoke st,152,値 / qpeek(st,152) ※IronHSPのみ。3.7/3.8は lpoke st,152,下位 : lpoke st,156,上位
; PLPStartCount : BYTE (+160, 16byte) varptr(st)+160 を基点に操作(16byte:入れ子/配列)
; EnduranceEstimate : BYTE (+176, 16byte) varptr(st)+176 を基点に操作(16byte:入れ子/配列)
; Reserved4 : BYTE (+192, 302byte) varptr(st)+192 を基点に操作(302byte:入れ子/配列)
; LogPageVersionNumber : WORD (+494, 2byte) wpoke st,494,値 / 値 = wpeek(st,494)
; LogPageGUID : GUID (+496, 16byte) varptr(st)+496 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。コピー ; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2, pack=1
#field byte MediaUnitsWritten 16
#field byte MediaUnitsRead 16
#field _BadUserNANDBlockCount_e__Struct BadUserNANDBlockCount
#field _BadSystemNANDBlockCount_e__Struct BadSystemNANDBlockCount
#field int64 XORRecoveryCount
#field int64 UnrecoverableReadErrorCount
#field int64 SoftECCErrorCount
#field _EndToEndCorrectionCounts_e__Struct EndToEndCorrectionCounts
#field byte PercentageSystemDataUsed
#field byte RefreshCount 7
#field _UserDataEraseCounts_e__Struct UserDataEraseCounts
#field _ThermalThrottling_e__Struct ThermalThrottling
#field byte Reserved0 6
#field int64 PCIeCorrectableErrorCount
#field int IncompleteShutdownCount
#field int Reserved1
#field byte PercentageFreeBlocks
#field byte Reserved2 7
#field short CapacitorHealth
#field byte Reserved3 6
#field int64 UnalignedIOCount
#field int64 SecurityVersionNumber
#field int64 NUSE
#field byte PLPStartCount 16
#field byte EnduranceEstimate 16
#field byte Reserved4 302
#field short LogPageVersionNumber
#field GUID LogPageGUID
#endstruct
stdim st, NVME_WCS_DEVICE_SMART_ATTRIBUTES_LOG_V2 ; NSTRUCT 変数を確保
st->XORRecoveryCount = 100
mes "XORRecoveryCount=" + st->XORRecoveryCount