ホーム › System.Ioctl › STORAGE_DEVICE_LOCATION_DESCRIPTOR
STORAGE_DEVICE_LOCATION_DESCRIPTOR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Version | DWORD | 4 | +0 | +0 | 構造体のバージョン番号。 |
| Size | DWORD | 4 | +4 | +4 | この構造体全体のサイズをバイト単位で示す。 |
| Location | DEVICE_LOCATION | 24/20 | +8 | +8 | デバイスの物理位置を示すDEVICE_LOCATION構造体。 |
| StringOffset | DWORD | 4 | +32 | +28 | 位置を表す文字列への本構造体先頭からのバイトオフセット。 |
各言語での定義
#include <windows.h>
// DEVICE_LOCATION (x64 24 / x86 20 バイト)
typedef struct DEVICE_LOCATION {
DWORD Socket;
DWORD Slot;
DWORD Adapter;
DWORD Port;
_Anonymous_e__Union Anonymous;
} DEVICE_LOCATION;
// STORAGE_DEVICE_LOCATION_DESCRIPTOR (x64 40 / x86 32 バイト)
typedef struct STORAGE_DEVICE_LOCATION_DESCRIPTOR {
DWORD Version;
DWORD Size;
DEVICE_LOCATION Location;
DWORD StringOffset;
} STORAGE_DEVICE_LOCATION_DESCRIPTOR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEVICE_LOCATION
{
public uint Socket;
public uint Slot;
public uint Adapter;
public uint Port;
public _Anonymous_e__Union Anonymous;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_DEVICE_LOCATION_DESCRIPTOR
{
public uint Version;
public uint Size;
public DEVICE_LOCATION Location;
public uint StringOffset;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEVICE_LOCATION
Public Socket As UInteger
Public Slot As UInteger
Public Adapter As UInteger
Public Port As UInteger
Public Anonymous As _Anonymous_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_DEVICE_LOCATION_DESCRIPTOR
Public Version As UInteger
Public Size As UInteger
Public Location As DEVICE_LOCATION
Public StringOffset As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DEVICE_LOCATION(ctypes.Structure):
_fields_ = [
("Socket", wintypes.DWORD),
("Slot", wintypes.DWORD),
("Adapter", wintypes.DWORD),
("Port", wintypes.DWORD),
("Anonymous", _Anonymous_e__Union),
]
class STORAGE_DEVICE_LOCATION_DESCRIPTOR(ctypes.Structure):
_fields_ = [
("Version", wintypes.DWORD),
("Size", wintypes.DWORD),
("Location", DEVICE_LOCATION),
("StringOffset", wintypes.DWORD),
]#[repr(C)]
pub struct DEVICE_LOCATION {
pub Socket: u32,
pub Slot: u32,
pub Adapter: u32,
pub Port: u32,
pub Anonymous: _Anonymous_e__Union,
}
#[repr(C)]
pub struct STORAGE_DEVICE_LOCATION_DESCRIPTOR {
pub Version: u32,
pub Size: u32,
pub Location: DEVICE_LOCATION,
pub StringOffset: u32,
}import "golang.org/x/sys/windows"
type DEVICE_LOCATION struct {
Socket uint32
Slot uint32
Adapter uint32
Port uint32
Anonymous _Anonymous_e__Union
}
type STORAGE_DEVICE_LOCATION_DESCRIPTOR struct {
Version uint32
Size uint32
Location DEVICE_LOCATION
StringOffset uint32
}type
DEVICE_LOCATION = record
Socket: DWORD;
Slot: DWORD;
Adapter: DWORD;
Port: DWORD;
Anonymous: _Anonymous_e__Union;
end;
STORAGE_DEVICE_LOCATION_DESCRIPTOR = record
Version: DWORD;
Size: DWORD;
Location: DEVICE_LOCATION;
StringOffset: DWORD;
end;const DEVICE_LOCATION = extern struct {
Socket: u32,
Slot: u32,
Adapter: u32,
Port: u32,
Anonymous: _Anonymous_e__Union,
};
const STORAGE_DEVICE_LOCATION_DESCRIPTOR = extern struct {
Version: u32,
Size: u32,
Location: DEVICE_LOCATION,
StringOffset: u32,
};type
DEVICE_LOCATION {.bycopy.} = object
Socket: uint32
Slot: uint32
Adapter: uint32
Port: uint32
Anonymous: _Anonymous_e__Union
STORAGE_DEVICE_LOCATION_DESCRIPTOR {.bycopy.} = object
Version: uint32
Size: uint32
Location: DEVICE_LOCATION
StringOffset: uint32struct DEVICE_LOCATION
{
uint Socket;
uint Slot;
uint Adapter;
uint Port;
_Anonymous_e__Union Anonymous;
}
struct STORAGE_DEVICE_LOCATION_DESCRIPTOR
{
uint Version;
uint Size;
DEVICE_LOCATION Location;
uint StringOffset;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; STORAGE_DEVICE_LOCATION_DESCRIPTOR サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Version : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Location : DEVICE_LOCATION (+8, 20byte) varptr(st)+8 を基点に操作(20byte:入れ子/配列)
; StringOffset : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_DEVICE_LOCATION_DESCRIPTOR サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; Version : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Location : DEVICE_LOCATION (+8, 24byte) varptr(st)+8 を基点に操作(24byte:入れ子/配列)
; StringOffset : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DEVICE_LOCATION
#field int Socket
#field int Slot
#field int Adapter
#field int Port
#field byte Anonymous 8
#endstruct
#defstruct global STORAGE_DEVICE_LOCATION_DESCRIPTOR
#field int Version
#field int Size
#field DEVICE_LOCATION Location
#field int StringOffset
#endstruct
stdim st, STORAGE_DEVICE_LOCATION_DESCRIPTOR ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version