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

NTFS_VOLUME_DATA_BUFFER

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

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

フィールド

フィールドサイズx64x86説明
VolumeSerialNumberLONGLONG8+0+0ボリュームのシリアル番号。
NumberSectorsLONGLONG8+8+8ボリュームの総セクタ数。
TotalClustersLONGLONG8+16+16ボリュームの総クラスタ数。
FreeClustersLONGLONG8+24+24空きクラスタ数。
TotalReservedLONGLONG8+32+32予約済みクラスタ数。
BytesPerSectorDWORD4+40+401セクタあたりのバイト数。
BytesPerClusterDWORD4+44+441クラスタあたりのバイト数。
BytesPerFileRecordSegmentDWORD4+48+481ファイルレコードセグメントあたりのバイト数。
ClustersPerFileRecordSegmentDWORD4+52+521ファイルレコードセグメントあたりのクラスタ数。
MftValidDataLengthLONGLONG8+56+56MFTの有効データ長。バイト単位。
MftStartLcnLONGLONG8+64+64MFTの開始論理クラスタ番号(LCN)。
Mft2StartLcnLONGLONG8+72+72MFTミラーの開始論理クラスタ番号(LCN)。
MftZoneStartLONGLONG8+80+80MFTゾーンの開始LCN。
MftZoneEndLONGLONG8+88+88MFTゾーンの終了LCN。

各言語での定義

#include <windows.h>

// NTFS_VOLUME_DATA_BUFFER  (x64 96 / x86 96 バイト)
typedef struct NTFS_VOLUME_DATA_BUFFER {
    LONGLONG VolumeSerialNumber;
    LONGLONG NumberSectors;
    LONGLONG TotalClusters;
    LONGLONG FreeClusters;
    LONGLONG TotalReserved;
    DWORD BytesPerSector;
    DWORD BytesPerCluster;
    DWORD BytesPerFileRecordSegment;
    DWORD ClustersPerFileRecordSegment;
    LONGLONG MftValidDataLength;
    LONGLONG MftStartLcn;
    LONGLONG Mft2StartLcn;
    LONGLONG MftZoneStart;
    LONGLONG MftZoneEnd;
} NTFS_VOLUME_DATA_BUFFER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NTFS_VOLUME_DATA_BUFFER
{
    public long VolumeSerialNumber;
    public long NumberSectors;
    public long TotalClusters;
    public long FreeClusters;
    public long TotalReserved;
    public uint BytesPerSector;
    public uint BytesPerCluster;
    public uint BytesPerFileRecordSegment;
    public uint ClustersPerFileRecordSegment;
    public long MftValidDataLength;
    public long MftStartLcn;
    public long Mft2StartLcn;
    public long MftZoneStart;
    public long MftZoneEnd;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NTFS_VOLUME_DATA_BUFFER
    Public VolumeSerialNumber As Long
    Public NumberSectors As Long
    Public TotalClusters As Long
    Public FreeClusters As Long
    Public TotalReserved As Long
    Public BytesPerSector As UInteger
    Public BytesPerCluster As UInteger
    Public BytesPerFileRecordSegment As UInteger
    Public ClustersPerFileRecordSegment As UInteger
    Public MftValidDataLength As Long
    Public MftStartLcn As Long
    Public Mft2StartLcn As Long
    Public MftZoneStart As Long
    Public MftZoneEnd As Long
End Structure
import ctypes
from ctypes import wintypes

class NTFS_VOLUME_DATA_BUFFER(ctypes.Structure):
    _fields_ = [
        ("VolumeSerialNumber", ctypes.c_longlong),
        ("NumberSectors", ctypes.c_longlong),
        ("TotalClusters", ctypes.c_longlong),
        ("FreeClusters", ctypes.c_longlong),
        ("TotalReserved", ctypes.c_longlong),
        ("BytesPerSector", wintypes.DWORD),
        ("BytesPerCluster", wintypes.DWORD),
        ("BytesPerFileRecordSegment", wintypes.DWORD),
        ("ClustersPerFileRecordSegment", wintypes.DWORD),
        ("MftValidDataLength", ctypes.c_longlong),
        ("MftStartLcn", ctypes.c_longlong),
        ("Mft2StartLcn", ctypes.c_longlong),
        ("MftZoneStart", ctypes.c_longlong),
        ("MftZoneEnd", ctypes.c_longlong),
    ]
#[repr(C)]
pub struct NTFS_VOLUME_DATA_BUFFER {
    pub VolumeSerialNumber: i64,
    pub NumberSectors: i64,
    pub TotalClusters: i64,
    pub FreeClusters: i64,
    pub TotalReserved: i64,
    pub BytesPerSector: u32,
    pub BytesPerCluster: u32,
    pub BytesPerFileRecordSegment: u32,
    pub ClustersPerFileRecordSegment: u32,
    pub MftValidDataLength: i64,
    pub MftStartLcn: i64,
    pub Mft2StartLcn: i64,
    pub MftZoneStart: i64,
    pub MftZoneEnd: i64,
}
import "golang.org/x/sys/windows"

type NTFS_VOLUME_DATA_BUFFER struct {
	VolumeSerialNumber int64
	NumberSectors int64
	TotalClusters int64
	FreeClusters int64
	TotalReserved int64
	BytesPerSector uint32
	BytesPerCluster uint32
	BytesPerFileRecordSegment uint32
	ClustersPerFileRecordSegment uint32
	MftValidDataLength int64
	MftStartLcn int64
	Mft2StartLcn int64
	MftZoneStart int64
	MftZoneEnd int64
}
type
  NTFS_VOLUME_DATA_BUFFER = record
    VolumeSerialNumber: Int64;
    NumberSectors: Int64;
    TotalClusters: Int64;
    FreeClusters: Int64;
    TotalReserved: Int64;
    BytesPerSector: DWORD;
    BytesPerCluster: DWORD;
    BytesPerFileRecordSegment: DWORD;
    ClustersPerFileRecordSegment: DWORD;
    MftValidDataLength: Int64;
    MftStartLcn: Int64;
    Mft2StartLcn: Int64;
    MftZoneStart: Int64;
    MftZoneEnd: Int64;
  end;
const NTFS_VOLUME_DATA_BUFFER = extern struct {
    VolumeSerialNumber: i64,
    NumberSectors: i64,
    TotalClusters: i64,
    FreeClusters: i64,
    TotalReserved: i64,
    BytesPerSector: u32,
    BytesPerCluster: u32,
    BytesPerFileRecordSegment: u32,
    ClustersPerFileRecordSegment: u32,
    MftValidDataLength: i64,
    MftStartLcn: i64,
    Mft2StartLcn: i64,
    MftZoneStart: i64,
    MftZoneEnd: i64,
};
type
  NTFS_VOLUME_DATA_BUFFER {.bycopy.} = object
    VolumeSerialNumber: int64
    NumberSectors: int64
    TotalClusters: int64
    FreeClusters: int64
    TotalReserved: int64
    BytesPerSector: uint32
    BytesPerCluster: uint32
    BytesPerFileRecordSegment: uint32
    ClustersPerFileRecordSegment: uint32
    MftValidDataLength: int64
    MftStartLcn: int64
    Mft2StartLcn: int64
    MftZoneStart: int64
    MftZoneEnd: int64
struct NTFS_VOLUME_DATA_BUFFER
{
    long VolumeSerialNumber;
    long NumberSectors;
    long TotalClusters;
    long FreeClusters;
    long TotalReserved;
    uint BytesPerSector;
    uint BytesPerCluster;
    uint BytesPerFileRecordSegment;
    uint ClustersPerFileRecordSegment;
    long MftValidDataLength;
    long MftStartLcn;
    long Mft2StartLcn;
    long MftZoneStart;
    long MftZoneEnd;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NTFS_VOLUME_DATA_BUFFER サイズ: 96 バイト(x64)
dim st, 24    ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; VolumeSerialNumber : LONGLONG (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; NumberSectors : LONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; TotalClusters : LONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; FreeClusters : LONGLONG (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; TotalReserved : LONGLONG (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; BytesPerSector : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; BytesPerCluster : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; BytesPerFileRecordSegment : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; ClustersPerFileRecordSegment : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; MftValidDataLength : LONGLONG (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; MftStartLcn : LONGLONG (+64, 8byte)  qpoke st,64,値 / qpeek(st,64)  ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; Mft2StartLcn : LONGLONG (+72, 8byte)  qpoke st,72,値 / qpeek(st,72)  ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; MftZoneStart : LONGLONG (+80, 8byte)  qpoke st,80,値 / qpeek(st,80)  ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; MftZoneEnd : LONGLONG (+88, 8byte)  qpoke st,88,値 / qpeek(st,88)  ※IronHSPのみ。3.7/3.8は lpoke st,88,下位 : lpoke st,92,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NTFS_VOLUME_DATA_BUFFER
    #field int64 VolumeSerialNumber
    #field int64 NumberSectors
    #field int64 TotalClusters
    #field int64 FreeClusters
    #field int64 TotalReserved
    #field int BytesPerSector
    #field int BytesPerCluster
    #field int BytesPerFileRecordSegment
    #field int ClustersPerFileRecordSegment
    #field int64 MftValidDataLength
    #field int64 MftStartLcn
    #field int64 Mft2StartLcn
    #field int64 MftZoneStart
    #field int64 MftZoneEnd
#endstruct

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