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

STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR

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

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号。
SizeDWORD4+4+4この構造体全体のサイズをバイト単位で示す。
NodeCountDWORD4+8+8Node配列に含まれる物理ノードの数。
ReservedDWORD4+12+12将来の拡張のために予約された32ビット領域。
NodeSTORAGE_PHYSICAL_NODE_DATA40+16+16STORAGE_PHYSICAL_NODE_DATA構造体の可変長配列。物理トポロジを構成する各ノード。

各言語での定義

#include <windows.h>

// STORAGE_PHYSICAL_NODE_DATA  (x64 40 / x86 40 バイト)
typedef struct STORAGE_PHYSICAL_NODE_DATA {
    DWORD NodeId;
    DWORD AdapterCount;
    DWORD AdapterDataLength;
    DWORD AdapterDataOffset;
    DWORD DeviceCount;
    DWORD DeviceDataLength;
    DWORD DeviceDataOffset;
    DWORD Reserved[3];
} STORAGE_PHYSICAL_NODE_DATA;

// STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR  (x64 56 / x86 56 バイト)
typedef struct STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR {
    DWORD Version;
    DWORD Size;
    DWORD NodeCount;
    DWORD Reserved;
    STORAGE_PHYSICAL_NODE_DATA Node[1];
} STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_PHYSICAL_NODE_DATA
{
    public uint NodeId;
    public uint AdapterCount;
    public uint AdapterDataLength;
    public uint AdapterDataOffset;
    public uint DeviceCount;
    public uint DeviceDataLength;
    public uint DeviceDataOffset;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] Reserved;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR
{
    public uint Version;
    public uint Size;
    public uint NodeCount;
    public uint Reserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public STORAGE_PHYSICAL_NODE_DATA[] Node;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_PHYSICAL_NODE_DATA
    Public NodeId As UInteger
    Public AdapterCount As UInteger
    Public AdapterDataLength As UInteger
    Public AdapterDataOffset As UInteger
    Public DeviceCount As UInteger
    Public DeviceDataLength As UInteger
    Public DeviceDataOffset As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR
    Public Version As UInteger
    Public Size As UInteger
    Public NodeCount As UInteger
    Public Reserved As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Node() As STORAGE_PHYSICAL_NODE_DATA
End Structure
import ctypes
from ctypes import wintypes

class STORAGE_PHYSICAL_NODE_DATA(ctypes.Structure):
    _fields_ = [
        ("NodeId", wintypes.DWORD),
        ("AdapterCount", wintypes.DWORD),
        ("AdapterDataLength", wintypes.DWORD),
        ("AdapterDataOffset", wintypes.DWORD),
        ("DeviceCount", wintypes.DWORD),
        ("DeviceDataLength", wintypes.DWORD),
        ("DeviceDataOffset", wintypes.DWORD),
        ("Reserved", wintypes.DWORD * 3),
    ]

class STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("NodeCount", wintypes.DWORD),
        ("Reserved", wintypes.DWORD),
        ("Node", STORAGE_PHYSICAL_NODE_DATA * 1),
    ]
#[repr(C)]
pub struct STORAGE_PHYSICAL_NODE_DATA {
    pub NodeId: u32,
    pub AdapterCount: u32,
    pub AdapterDataLength: u32,
    pub AdapterDataOffset: u32,
    pub DeviceCount: u32,
    pub DeviceDataLength: u32,
    pub DeviceDataOffset: u32,
    pub Reserved: [u32; 3],
}

#[repr(C)]
pub struct STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR {
    pub Version: u32,
    pub Size: u32,
    pub NodeCount: u32,
    pub Reserved: u32,
    pub Node: [STORAGE_PHYSICAL_NODE_DATA; 1],
}
import "golang.org/x/sys/windows"

type STORAGE_PHYSICAL_NODE_DATA struct {
	NodeId uint32
	AdapterCount uint32
	AdapterDataLength uint32
	AdapterDataOffset uint32
	DeviceCount uint32
	DeviceDataLength uint32
	DeviceDataOffset uint32
	Reserved [3]uint32
}

type STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR struct {
	Version uint32
	Size uint32
	NodeCount uint32
	Reserved uint32
	Node [1]STORAGE_PHYSICAL_NODE_DATA
}
type
  STORAGE_PHYSICAL_NODE_DATA = record
    NodeId: DWORD;
    AdapterCount: DWORD;
    AdapterDataLength: DWORD;
    AdapterDataOffset: DWORD;
    DeviceCount: DWORD;
    DeviceDataLength: DWORD;
    DeviceDataOffset: DWORD;
    Reserved: array[0..2] of DWORD;
  end;

  STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR = record
    Version: DWORD;
    Size: DWORD;
    NodeCount: DWORD;
    Reserved: DWORD;
    Node: array[0..0] of STORAGE_PHYSICAL_NODE_DATA;
  end;
const STORAGE_PHYSICAL_NODE_DATA = extern struct {
    NodeId: u32,
    AdapterCount: u32,
    AdapterDataLength: u32,
    AdapterDataOffset: u32,
    DeviceCount: u32,
    DeviceDataLength: u32,
    DeviceDataOffset: u32,
    Reserved: [3]u32,
};

const STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR = extern struct {
    Version: u32,
    Size: u32,
    NodeCount: u32,
    Reserved: u32,
    Node: [1]STORAGE_PHYSICAL_NODE_DATA,
};
type
  STORAGE_PHYSICAL_NODE_DATA {.bycopy.} = object
    NodeId: uint32
    AdapterCount: uint32
    AdapterDataLength: uint32
    AdapterDataOffset: uint32
    DeviceCount: uint32
    DeviceDataLength: uint32
    DeviceDataOffset: uint32
    Reserved: array[3, uint32]

  STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR {.bycopy.} = object
    Version: uint32
    Size: uint32
    NodeCount: uint32
    Reserved: uint32
    Node: array[1, STORAGE_PHYSICAL_NODE_DATA]
struct STORAGE_PHYSICAL_NODE_DATA
{
    uint NodeId;
    uint AdapterCount;
    uint AdapterDataLength;
    uint AdapterDataOffset;
    uint DeviceCount;
    uint DeviceDataLength;
    uint DeviceDataOffset;
    uint[3] Reserved;
}

struct STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR
{
    uint Version;
    uint Size;
    uint NodeCount;
    uint Reserved;
    STORAGE_PHYSICAL_NODE_DATA[1] Node;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; NodeCount : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Reserved : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Node : STORAGE_PHYSICAL_NODE_DATA (+16, 40byte)  varptr(st)+16 を基点に操作(40byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global STORAGE_PHYSICAL_NODE_DATA
    #field int NodeId
    #field int AdapterCount
    #field int AdapterDataLength
    #field int AdapterDataOffset
    #field int DeviceCount
    #field int DeviceDataLength
    #field int DeviceDataOffset
    #field int Reserved 3
#endstruct

#defstruct global STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR
    #field int Version
    #field int Size
    #field int NodeCount
    #field int Reserved
    #field STORAGE_PHYSICAL_NODE_DATA Node 1
#endstruct

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