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

READCONTROLSPACE32

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

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

フィールド

フィールドサイズx64x86説明
ProcessorWORD2+0+0対象とするプロセッサ番号。
AddressDWORD4+4+4コントロール空間の読み出し開始アドレス(32ビット)。
BufLenDWORD4+8+8Bufが受け取るデータのバイト長。
BufBYTE1+12+12読み出したデータを格納する可変長バッファの先頭。

各言語での定義

#include <windows.h>

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

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

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

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

type READCONTROLSPACE32 struct {
	Processor uint16
	Address uint32
	BufLen uint32
	Buf [1]byte
}
type
  READCONTROLSPACE32 = record
    Processor: Word;
    Address: DWORD;
    BufLen: DWORD;
    Buf: array[0..0] of Byte;
  end;
const READCONTROLSPACE32 = extern struct {
    Processor: u16,
    Address: u32,
    BufLen: u32,
    Buf: [1]u8,
};
type
  READCONTROLSPACE32 {.bycopy.} = object
    Processor: uint16
    Address: uint32
    BufLen: uint32
    Buf: array[1, uint8]
struct READCONTROLSPACE32
{
    ushort Processor;
    uint 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 レイアウト)
; READCONTROLSPACE32 サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Processor : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; Address : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; 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 READCONTROLSPACE32
    #field short Processor
    #field int Address
    #field int BufLen
    #field byte Buf 1
#endstruct

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