Win32 API 日本語リファレンス
ホームStorage.Nvme › NVME_ENDURANCE_GROUP_LOG

NVME_ENDURANCE_GROUP_LOG

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

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

フィールド

フィールドサイズx64x86説明
Reserved0DWORD4+0+0予約領域。将来拡張用で0とする。
AvailableSpareThresholdBYTE1+4+4予備領域の警告しきい値。百分率で表す。
PercentageUsedBYTE1+5+5グループの推定消耗率。百分率で表す。
Reserved1BYTE26+6+6予約領域。将来拡張用で0とする。
EnduranceEstimateBYTE16+32+32推定耐久度(書き込み可能総容量)。128ビット値。
DataUnitsReadBYTE16+48+48読み取られたデータ単位数(128ビット)。
DataUnitsWrittenBYTE16+64+64書き込まれたデータ単位数(128ビット)。
MediaUnitsWrittenBYTE16+80+80メディアへ書き込まれた単位数(128ビット)。
Reserved2BYTE416+96+96予約領域。将来拡張用で0とする。

各言語での定義

#include <windows.h>

// NVME_ENDURANCE_GROUP_LOG  (x64 512 / x86 512 バイト)
#pragma pack(push, 1)
typedef struct NVME_ENDURANCE_GROUP_LOG {
    DWORD Reserved0;
    BYTE AvailableSpareThreshold;
    BYTE PercentageUsed;
    BYTE Reserved1[26];
    BYTE EnduranceEstimate[16];
    BYTE DataUnitsRead[16];
    BYTE DataUnitsWritten[16];
    BYTE MediaUnitsWritten[16];
    BYTE Reserved2[416];
} NVME_ENDURANCE_GROUP_LOG;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct NVME_ENDURANCE_GROUP_LOG
{
    public uint Reserved0;
    public byte AvailableSpareThreshold;
    public byte PercentageUsed;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 26)] public byte[] Reserved1;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] EnduranceEstimate;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] DataUnitsRead;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] DataUnitsWritten;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] MediaUnitsWritten;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 416)] public byte[] Reserved2;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure NVME_ENDURANCE_GROUP_LOG
    Public Reserved0 As UInteger
    Public AvailableSpareThreshold As Byte
    Public PercentageUsed As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=26)> Public Reserved1() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public EnduranceEstimate() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public DataUnitsRead() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public DataUnitsWritten() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public MediaUnitsWritten() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=416)> Public Reserved2() As Byte
End Structure
import ctypes
from ctypes import wintypes

class NVME_ENDURANCE_GROUP_LOG(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Reserved0", wintypes.DWORD),
        ("AvailableSpareThreshold", ctypes.c_ubyte),
        ("PercentageUsed", ctypes.c_ubyte),
        ("Reserved1", ctypes.c_ubyte * 26),
        ("EnduranceEstimate", ctypes.c_ubyte * 16),
        ("DataUnitsRead", ctypes.c_ubyte * 16),
        ("DataUnitsWritten", ctypes.c_ubyte * 16),
        ("MediaUnitsWritten", ctypes.c_ubyte * 16),
        ("Reserved2", ctypes.c_ubyte * 416),
    ]
#[repr(C, packed(1))]
pub struct NVME_ENDURANCE_GROUP_LOG {
    pub Reserved0: u32,
    pub AvailableSpareThreshold: u8,
    pub PercentageUsed: u8,
    pub Reserved1: [u8; 26],
    pub EnduranceEstimate: [u8; 16],
    pub DataUnitsRead: [u8; 16],
    pub DataUnitsWritten: [u8; 16],
    pub MediaUnitsWritten: [u8; 16],
    pub Reserved2: [u8; 416],
}
import "golang.org/x/sys/windows"

type NVME_ENDURANCE_GROUP_LOG struct {
	Reserved0 uint32
	AvailableSpareThreshold byte
	PercentageUsed byte
	Reserved1 [26]byte
	EnduranceEstimate [16]byte
	DataUnitsRead [16]byte
	DataUnitsWritten [16]byte
	MediaUnitsWritten [16]byte
	Reserved2 [416]byte
}
type
  NVME_ENDURANCE_GROUP_LOG = packed record
    Reserved0: DWORD;
    AvailableSpareThreshold: Byte;
    PercentageUsed: Byte;
    Reserved1: array[0..25] of Byte;
    EnduranceEstimate: array[0..15] of Byte;
    DataUnitsRead: array[0..15] of Byte;
    DataUnitsWritten: array[0..15] of Byte;
    MediaUnitsWritten: array[0..15] of Byte;
    Reserved2: array[0..415] of Byte;
  end;
const NVME_ENDURANCE_GROUP_LOG = extern struct {
    Reserved0: u32,
    AvailableSpareThreshold: u8,
    PercentageUsed: u8,
    Reserved1: [26]u8,
    EnduranceEstimate: [16]u8,
    DataUnitsRead: [16]u8,
    DataUnitsWritten: [16]u8,
    MediaUnitsWritten: [16]u8,
    Reserved2: [416]u8,
};
type
  NVME_ENDURANCE_GROUP_LOG {.packed.} = object
    Reserved0: uint32
    AvailableSpareThreshold: uint8
    PercentageUsed: uint8
    Reserved1: array[26, uint8]
    EnduranceEstimate: array[16, uint8]
    DataUnitsRead: array[16, uint8]
    DataUnitsWritten: array[16, uint8]
    MediaUnitsWritten: array[16, uint8]
    Reserved2: array[416, uint8]
align(1)
struct NVME_ENDURANCE_GROUP_LOG
{
    uint Reserved0;
    ubyte AvailableSpareThreshold;
    ubyte PercentageUsed;
    ubyte[26] Reserved1;
    ubyte[16] EnduranceEstimate;
    ubyte[16] DataUnitsRead;
    ubyte[16] DataUnitsWritten;
    ubyte[16] MediaUnitsWritten;
    ubyte[416] Reserved2;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_ENDURANCE_GROUP_LOG サイズ: 512 バイト(x64)
dim st, 128    ; 4byte整数×128(構造体サイズ 512 / 4 切り上げ)
; Reserved0 : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; AvailableSpareThreshold : BYTE (+4, 1byte)  poke st,4,値  /  値 = peek(st,4)
; PercentageUsed : BYTE (+5, 1byte)  poke st,5,値  /  値 = peek(st,5)
; Reserved1 : BYTE (+6, 26byte)  varptr(st)+6 を基点に操作(26byte:入れ子/配列)
; EnduranceEstimate : BYTE (+32, 16byte)  varptr(st)+32 を基点に操作(16byte:入れ子/配列)
; DataUnitsRead : BYTE (+48, 16byte)  varptr(st)+48 を基点に操作(16byte:入れ子/配列)
; DataUnitsWritten : BYTE (+64, 16byte)  varptr(st)+64 を基点に操作(16byte:入れ子/配列)
; MediaUnitsWritten : BYTE (+80, 16byte)  varptr(st)+80 を基点に操作(16byte:入れ子/配列)
; Reserved2 : BYTE (+96, 416byte)  varptr(st)+96 を基点に操作(416byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NVME_ENDURANCE_GROUP_LOG, pack=1
    #field int Reserved0
    #field byte AvailableSpareThreshold
    #field byte PercentageUsed
    #field byte Reserved1 26
    #field byte EnduranceEstimate 16
    #field byte DataUnitsRead 16
    #field byte DataUnitsWritten 16
    #field byte MediaUnitsWritten 16
    #field byte Reserved2 416
#endstruct

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