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

NVME_LBA_RANGE

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

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

フィールド

フィールドサイズx64x86説明
AttributesNVME_CONTEXT_ATTRIBUTES4+0+0Dataset ManagementにおけるこのLBA範囲の使用方法を示すコンテキスト属性である。
LogicalBlockCountDWORD4+4+4この範囲に含まれる論理ブロック数を表す32ビット値である。
StartingLBAULONGLONG8+8+8範囲の開始論理ブロックアドレス(Starting LBA)を表す64ビット値である。

各言語での定義

#include <windows.h>

// NVME_CONTEXT_ATTRIBUTES  (x64 4 / x86 4 バイト)
typedef struct NVME_CONTEXT_ATTRIBUTES {
    _Anonymous_e__Struct Anonymous;
    DWORD AsUlong;
} NVME_CONTEXT_ATTRIBUTES;

// NVME_LBA_RANGE  (x64 16 / x86 16 バイト)
typedef struct NVME_LBA_RANGE {
    NVME_CONTEXT_ATTRIBUTES Attributes;
    DWORD LogicalBlockCount;
    ULONGLONG StartingLBA;
} NVME_LBA_RANGE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_CONTEXT_ATTRIBUTES
{
    public _Anonymous_e__Struct Anonymous;
    public uint AsUlong;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_LBA_RANGE
{
    public NVME_CONTEXT_ATTRIBUTES Attributes;
    public uint LogicalBlockCount;
    public ulong StartingLBA;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_CONTEXT_ATTRIBUTES
    Public Anonymous As _Anonymous_e__Struct
    Public AsUlong As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_LBA_RANGE
    Public Attributes As NVME_CONTEXT_ATTRIBUTES
    Public LogicalBlockCount As UInteger
    Public StartingLBA As ULong
End Structure
import ctypes
from ctypes import wintypes

class NVME_CONTEXT_ATTRIBUTES(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Struct),
        ("AsUlong", wintypes.DWORD),
    ]

class NVME_LBA_RANGE(ctypes.Structure):
    _fields_ = [
        ("Attributes", NVME_CONTEXT_ATTRIBUTES),
        ("LogicalBlockCount", wintypes.DWORD),
        ("StartingLBA", ctypes.c_ulonglong),
    ]
#[repr(C)]
pub struct NVME_CONTEXT_ATTRIBUTES {
    pub Anonymous: _Anonymous_e__Struct,
    pub AsUlong: u32,
}

#[repr(C)]
pub struct NVME_LBA_RANGE {
    pub Attributes: NVME_CONTEXT_ATTRIBUTES,
    pub LogicalBlockCount: u32,
    pub StartingLBA: u64,
}
import "golang.org/x/sys/windows"

type NVME_CONTEXT_ATTRIBUTES struct {
	Anonymous _Anonymous_e__Struct
	AsUlong uint32
}

type NVME_LBA_RANGE struct {
	Attributes NVME_CONTEXT_ATTRIBUTES
	LogicalBlockCount uint32
	StartingLBA uint64
}
type
  NVME_CONTEXT_ATTRIBUTES = record
    Anonymous: _Anonymous_e__Struct;
    AsUlong: DWORD;
  end;

  NVME_LBA_RANGE = record
    Attributes: NVME_CONTEXT_ATTRIBUTES;
    LogicalBlockCount: DWORD;
    StartingLBA: UInt64;
  end;
const NVME_CONTEXT_ATTRIBUTES = extern struct {
    Anonymous: _Anonymous_e__Struct,
    AsUlong: u32,
};

const NVME_LBA_RANGE = extern struct {
    Attributes: NVME_CONTEXT_ATTRIBUTES,
    LogicalBlockCount: u32,
    StartingLBA: u64,
};
type
  NVME_CONTEXT_ATTRIBUTES {.bycopy.} = object
    Anonymous: _Anonymous_e__Struct
    AsUlong: uint32

  NVME_LBA_RANGE {.bycopy.} = object
    Attributes: NVME_CONTEXT_ATTRIBUTES
    LogicalBlockCount: uint32
    StartingLBA: uint64
struct NVME_CONTEXT_ATTRIBUTES
{
    _Anonymous_e__Struct Anonymous;
    uint AsUlong;
}

struct NVME_LBA_RANGE
{
    NVME_CONTEXT_ATTRIBUTES Attributes;
    uint LogicalBlockCount;
    ulong StartingLBA;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_LBA_RANGE サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Attributes : NVME_CONTEXT_ATTRIBUTES (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; LogicalBlockCount : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; StartingLBA : ULONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NVME_LBA_RANGE
    #field byte Attributes 4
    #field int LogicalBlockCount
    #field int64 StartingLBA
#endstruct

stdim st, NVME_LBA_RANGE        ; NSTRUCT 変数を確保
st->LogicalBlockCount = 100
mes "LogicalBlockCount=" + st->LogicalBlockCount
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。