ホーム › System.VirtualDosMachines › VDM_SEGINFO
VDM_SEGINFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Selector | WORD | 2 | +0 | +0 | セグメントセレクタ値。 |
| SegNumber | WORD | 2 | +2 | +2 | セグメント番号。 |
| Length | DWORD | 4 | +4 | +4 | セグメントの長さ(バイト)。 |
| Type | WORD | 2 | +8 | +8 | セグメントの種別を示す値。 |
| ModuleName | CHAR | 9 | +10 | +10 | セグメントが属するモジュール名を表すCHAR配列。 |
| FileName | CHAR | 255 | +19 | +19 | モジュールのファイル名を表すCHAR配列。 |
各言語での定義
#include <windows.h>
// VDM_SEGINFO (x64 276 / x86 276 バイト)
typedef struct VDM_SEGINFO {
WORD Selector;
WORD SegNumber;
DWORD Length;
WORD Type;
CHAR ModuleName[9];
CHAR FileName[255];
} VDM_SEGINFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VDM_SEGINFO
{
public ushort Selector;
public ushort SegNumber;
public uint Length;
public ushort Type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] public sbyte[] ModuleName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 255)] public sbyte[] FileName;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure VDM_SEGINFO
Public Selector As UShort
Public SegNumber As UShort
Public Length As UInteger
Public Type As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=9)> Public ModuleName() As SByte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=255)> Public FileName() As SByte
End Structureimport ctypes
from ctypes import wintypes
class VDM_SEGINFO(ctypes.Structure):
_fields_ = [
("Selector", ctypes.c_ushort),
("SegNumber", ctypes.c_ushort),
("Length", wintypes.DWORD),
("Type", ctypes.c_ushort),
("ModuleName", ctypes.c_byte * 9),
("FileName", ctypes.c_byte * 255),
]#[repr(C)]
pub struct VDM_SEGINFO {
pub Selector: u16,
pub SegNumber: u16,
pub Length: u32,
pub Type: u16,
pub ModuleName: [i8; 9],
pub FileName: [i8; 255],
}import "golang.org/x/sys/windows"
type VDM_SEGINFO struct {
Selector uint16
SegNumber uint16
Length uint32
Type uint16
ModuleName [9]int8
FileName [255]int8
}type
VDM_SEGINFO = record
Selector: Word;
SegNumber: Word;
Length: DWORD;
Type: Word;
ModuleName: array[0..8] of Shortint;
FileName: array[0..254] of Shortint;
end;const VDM_SEGINFO = extern struct {
Selector: u16,
SegNumber: u16,
Length: u32,
Type: u16,
ModuleName: [9]i8,
FileName: [255]i8,
};type
VDM_SEGINFO {.bycopy.} = object
Selector: uint16
SegNumber: uint16
Length: uint32
Type: uint16
ModuleName: array[9, int8]
FileName: array[255, int8]struct VDM_SEGINFO
{
ushort Selector;
ushort SegNumber;
uint Length;
ushort Type;
byte[9] ModuleName;
byte[255] FileName;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; VDM_SEGINFO サイズ: 276 バイト(x64)
dim st, 69 ; 4byte整数×69(構造体サイズ 276 / 4 切り上げ)
; Selector : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; SegNumber : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; Length : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Type : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; ModuleName : CHAR (+10, 9byte) varptr(st)+10 を基点に操作(9byte:入れ子/配列)
; FileName : CHAR (+19, 255byte) varptr(st)+19 を基点に操作(255byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global VDM_SEGINFO
#field short Selector
#field short SegNumber
#field int Length
#field short Type
#field byte ModuleName 9
#field byte FileName 255
#endstruct
stdim st, VDM_SEGINFO ; NSTRUCT 変数を確保
st->Selector = 100
mes "Selector=" + st->Selector