Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug.Extensions › PHYSICAL

PHYSICAL

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

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

フィールド

フィールドサイズx64x86説明
AddressULONGLONG8+0+0アクセスする物理メモリのアドレス。
BufLenDWORD4+8+8Bufが受け取るデータのバイト長。
BufBYTE1+12+12読み出したデータを格納する可変長バッファの先頭。

各言語での定義

#include <windows.h>

// PHYSICAL  (x64 16 / x86 16 バイト)
typedef struct PHYSICAL {
    ULONGLONG Address;
    DWORD BufLen;
    BYTE Buf[1];
} PHYSICAL;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PHYSICAL
{
    public ulong Address;
    public uint BufLen;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Buf;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PHYSICAL
    Public Address As ULong
    Public BufLen As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Buf() As Byte
End Structure
import ctypes
from ctypes import wintypes

class PHYSICAL(ctypes.Structure):
    _fields_ = [
        ("Address", ctypes.c_ulonglong),
        ("BufLen", wintypes.DWORD),
        ("Buf", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct PHYSICAL {
    pub Address: u64,
    pub BufLen: u32,
    pub Buf: [u8; 1],
}
import "golang.org/x/sys/windows"

type PHYSICAL struct {
	Address uint64
	BufLen uint32
	Buf [1]byte
}
type
  PHYSICAL = record
    Address: UInt64;
    BufLen: DWORD;
    Buf: array[0..0] of Byte;
  end;
const PHYSICAL = extern struct {
    Address: u64,
    BufLen: u32,
    Buf: [1]u8,
};
type
  PHYSICAL {.bycopy.} = object
    Address: uint64
    BufLen: uint32
    Buf: array[1, uint8]
struct PHYSICAL
{
    ulong Address;
    uint BufLen;
    ubyte[1] Buf;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PHYSICAL サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Address : ULONGLONG (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; BufLen : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Buf : BYTE (+12, 1byte)  varptr(st)+12 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PHYSICAL
    #field int64 Address
    #field int BufLen
    #field byte Buf 1
#endstruct

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