ホーム › System.Ioctl › DRIVE_LAYOUT_INFORMATION_EX
DRIVE_LAYOUT_INFORMATION_EX
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| PartitionStyle | DWORD | 4 | +0 | +0 | ディスクのパーティション形式を示す値。 |
| PartitionCount | DWORD | 4 | +4 | +4 | PartitionEntry配列に含まれるパーティション数。 |
| Anonymous | _Anonymous_e__Union | 40 | +8 | +8 | PartitionStyleに応じてMBRまたはGPTレイアウト情報を保持する共用体。 |
| PartitionEntry | PARTITION_INFORMATION_EX | 144 | +48 | +48 | PARTITION_INFORMATION_EXの可変長配列。先頭要素。 |
共用体: _Anonymous_e__Union x64 40B / x86 40B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| Mbr | DRIVE_LAYOUT_INFORMATION_MBR | 8 | +0 | +0 |
| Gpt | DRIVE_LAYOUT_INFORMATION_GPT | 40 | +0 | +0 |
各言語での定義
#include <windows.h>
// PARTITION_INFORMATION_EX (x64 144 / x86 144 バイト)
typedef struct PARTITION_INFORMATION_EX {
PARTITION_STYLE PartitionStyle;
LONGLONG StartingOffset;
LONGLONG PartitionLength;
DWORD PartitionNumber;
BOOLEAN RewritePartition;
BOOLEAN IsServicePartition;
_Anonymous_e__Union Anonymous;
} PARTITION_INFORMATION_EX;
// DRIVE_LAYOUT_INFORMATION_EX (x64 192 / x86 192 バイト)
typedef struct DRIVE_LAYOUT_INFORMATION_EX {
DWORD PartitionStyle;
DWORD PartitionCount;
_Anonymous_e__Union Anonymous;
PARTITION_INFORMATION_EX PartitionEntry[1];
} DRIVE_LAYOUT_INFORMATION_EX;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PARTITION_INFORMATION_EX
{
public int PartitionStyle;
public long StartingOffset;
public long PartitionLength;
public uint PartitionNumber;
[MarshalAs(UnmanagedType.U1)] public bool RewritePartition;
[MarshalAs(UnmanagedType.U1)] public bool IsServicePartition;
public _Anonymous_e__Union Anonymous;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DRIVE_LAYOUT_INFORMATION_EX
{
public uint PartitionStyle;
public uint PartitionCount;
public _Anonymous_e__Union Anonymous;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public PARTITION_INFORMATION_EX[] PartitionEntry;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PARTITION_INFORMATION_EX
Public PartitionStyle As Integer
Public StartingOffset As Long
Public PartitionLength As Long
Public PartitionNumber As UInteger
<MarshalAs(UnmanagedType.U1)> Public RewritePartition As Boolean
<MarshalAs(UnmanagedType.U1)> Public IsServicePartition As Boolean
Public Anonymous As _Anonymous_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DRIVE_LAYOUT_INFORMATION_EX
Public PartitionStyle As UInteger
Public PartitionCount As UInteger
Public Anonymous As _Anonymous_e__Union
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public PartitionEntry() As PARTITION_INFORMATION_EX
End Structureimport ctypes
from ctypes import wintypes
class PARTITION_INFORMATION_EX(ctypes.Structure):
_fields_ = [
("PartitionStyle", ctypes.c_int),
("StartingOffset", ctypes.c_longlong),
("PartitionLength", ctypes.c_longlong),
("PartitionNumber", wintypes.DWORD),
("RewritePartition", ctypes.c_byte),
("IsServicePartition", ctypes.c_byte),
("Anonymous", _Anonymous_e__Union),
]
class DRIVE_LAYOUT_INFORMATION_EX(ctypes.Structure):
_fields_ = [
("PartitionStyle", wintypes.DWORD),
("PartitionCount", wintypes.DWORD),
("Anonymous", _Anonymous_e__Union),
("PartitionEntry", PARTITION_INFORMATION_EX * 1),
]#[repr(C)]
pub struct PARTITION_INFORMATION_EX {
pub PartitionStyle: i32,
pub StartingOffset: i64,
pub PartitionLength: i64,
pub PartitionNumber: u32,
pub RewritePartition: u8,
pub IsServicePartition: u8,
pub Anonymous: _Anonymous_e__Union,
}
#[repr(C)]
pub struct DRIVE_LAYOUT_INFORMATION_EX {
pub PartitionStyle: u32,
pub PartitionCount: u32,
pub Anonymous: _Anonymous_e__Union,
pub PartitionEntry: [PARTITION_INFORMATION_EX; 1],
}import "golang.org/x/sys/windows"
type PARTITION_INFORMATION_EX struct {
PartitionStyle int32
StartingOffset int64
PartitionLength int64
PartitionNumber uint32
RewritePartition byte
IsServicePartition byte
Anonymous _Anonymous_e__Union
}
type DRIVE_LAYOUT_INFORMATION_EX struct {
PartitionStyle uint32
PartitionCount uint32
Anonymous _Anonymous_e__Union
PartitionEntry [1]PARTITION_INFORMATION_EX
}type
PARTITION_INFORMATION_EX = record
PartitionStyle: Integer;
StartingOffset: Int64;
PartitionLength: Int64;
PartitionNumber: DWORD;
RewritePartition: ByteBool;
IsServicePartition: ByteBool;
Anonymous: _Anonymous_e__Union;
end;
DRIVE_LAYOUT_INFORMATION_EX = record
PartitionStyle: DWORD;
PartitionCount: DWORD;
Anonymous: _Anonymous_e__Union;
PartitionEntry: array[0..0] of PARTITION_INFORMATION_EX;
end;const PARTITION_INFORMATION_EX = extern struct {
PartitionStyle: i32,
StartingOffset: i64,
PartitionLength: i64,
PartitionNumber: u32,
RewritePartition: u8,
IsServicePartition: u8,
Anonymous: _Anonymous_e__Union,
};
const DRIVE_LAYOUT_INFORMATION_EX = extern struct {
PartitionStyle: u32,
PartitionCount: u32,
Anonymous: _Anonymous_e__Union,
PartitionEntry: [1]PARTITION_INFORMATION_EX,
};type
PARTITION_INFORMATION_EX {.bycopy.} = object
PartitionStyle: int32
StartingOffset: int64
PartitionLength: int64
PartitionNumber: uint32
RewritePartition: uint8
IsServicePartition: uint8
Anonymous: _Anonymous_e__Union
DRIVE_LAYOUT_INFORMATION_EX {.bycopy.} = object
PartitionStyle: uint32
PartitionCount: uint32
Anonymous: _Anonymous_e__Union
PartitionEntry: array[1, PARTITION_INFORMATION_EX]struct PARTITION_INFORMATION_EX
{
int PartitionStyle;
long StartingOffset;
long PartitionLength;
uint PartitionNumber;
ubyte RewritePartition;
ubyte IsServicePartition;
_Anonymous_e__Union Anonymous;
}
struct DRIVE_LAYOUT_INFORMATION_EX
{
uint PartitionStyle;
uint PartitionCount;
_Anonymous_e__Union Anonymous;
PARTITION_INFORMATION_EX[1] PartitionEntry;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DRIVE_LAYOUT_INFORMATION_EX サイズ: 192 バイト(x64)
dim st, 48 ; 4byte整数×48(構造体サイズ 192 / 4 切り上げ)
; PartitionStyle : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; PartitionCount : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+8, 40byte) varptr(st)+8 を基点に操作(40byte:入れ子/配列)
; PartitionEntry : PARTITION_INFORMATION_EX (+48, 144byte) varptr(st)+48 を基点に操作(144byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global PARTITION_INFORMATION_EX
#field int PartitionStyle
#field int64 StartingOffset
#field int64 PartitionLength
#field int PartitionNumber
#field bool1 RewritePartition
#field bool1 IsServicePartition
#field byte Anonymous 112
#endstruct
#defstruct global DRIVE_LAYOUT_INFORMATION_EX
#field int PartitionStyle
#field int PartitionCount
#field byte Anonymous 40
#field PARTITION_INFORMATION_EX PartitionEntry 1
#endstruct
stdim st, DRIVE_LAYOUT_INFORMATION_EX ; NSTRUCT 変数を確保
st->PartitionStyle = 100
mes "PartitionStyle=" + st->PartitionStyle
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。