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

WIN32_MEMORY_REGION_INFORMATION

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

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

フィールド

フィールドサイズx64x86説明
AllocationBasevoid*8/4+0+0リージョンを確保した割り当て基底アドレス。
AllocationProtectDWORD4+8+4リージョン確保時に指定されたメモリ保護属性。
Anonymous_Anonymous_e__Union8/4+16+8リージョンの状態フラグ(Private/MappedImage等)を保持する無名共用体。
RegionSizeUINT_PTR8/4+24+12リージョンのバイト単位サイズ。
CommitSizeUINT_PTR8/4+32+16リージョン内でコミット済みのバイト数。

共用体: _Anonymous_e__Union x64 8B / x86 4B

フィールドサイズx64x86説明
FlagsDWORD4+0+0
Anonymous_Anonymous_e__Struct8/4+0+0リージョンの状態フラグ(Private/MappedImage等)を保持する無名共用体。

各言語での定義

#include <windows.h>

// WIN32_MEMORY_REGION_INFORMATION  (x64 40 / x86 20 バイト)
typedef struct WIN32_MEMORY_REGION_INFORMATION {
    void* AllocationBase;
    DWORD AllocationProtect;
    _Anonymous_e__Union Anonymous;
    UINT_PTR RegionSize;
    UINT_PTR CommitSize;
} WIN32_MEMORY_REGION_INFORMATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WIN32_MEMORY_REGION_INFORMATION
{
    public IntPtr AllocationBase;
    public uint AllocationProtect;
    public _Anonymous_e__Union Anonymous;
    public UIntPtr RegionSize;
    public UIntPtr CommitSize;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WIN32_MEMORY_REGION_INFORMATION
    Public AllocationBase As IntPtr
    Public AllocationProtect As UInteger
    Public Anonymous As _Anonymous_e__Union
    Public RegionSize As UIntPtr
    Public CommitSize As UIntPtr
End Structure
import ctypes
from ctypes import wintypes

class WIN32_MEMORY_REGION_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("AllocationBase", ctypes.c_void_p),
        ("AllocationProtect", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Union),
        ("RegionSize", ctypes.c_size_t),
        ("CommitSize", ctypes.c_size_t),
    ]
#[repr(C)]
pub struct WIN32_MEMORY_REGION_INFORMATION {
    pub AllocationBase: *mut core::ffi::c_void,
    pub AllocationProtect: u32,
    pub Anonymous: _Anonymous_e__Union,
    pub RegionSize: usize,
    pub CommitSize: usize,
}
import "golang.org/x/sys/windows"

type WIN32_MEMORY_REGION_INFORMATION struct {
	AllocationBase uintptr
	AllocationProtect uint32
	Anonymous _Anonymous_e__Union
	RegionSize uintptr
	CommitSize uintptr
}
type
  WIN32_MEMORY_REGION_INFORMATION = record
    AllocationBase: Pointer;
    AllocationProtect: DWORD;
    Anonymous: _Anonymous_e__Union;
    RegionSize: NativeUInt;
    CommitSize: NativeUInt;
  end;
const WIN32_MEMORY_REGION_INFORMATION = extern struct {
    AllocationBase: ?*anyopaque,
    AllocationProtect: u32,
    Anonymous: _Anonymous_e__Union,
    RegionSize: usize,
    CommitSize: usize,
};
type
  WIN32_MEMORY_REGION_INFORMATION {.bycopy.} = object
    AllocationBase: pointer
    AllocationProtect: uint32
    Anonymous: _Anonymous_e__Union
    RegionSize: uint
    CommitSize: uint
struct WIN32_MEMORY_REGION_INFORMATION
{
    void* AllocationBase;
    uint AllocationProtect;
    _Anonymous_e__Union Anonymous;
    size_t RegionSize;
    size_t CommitSize;
}

HSP用 定義

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

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

stdim st, WIN32_MEMORY_REGION_INFORMATION        ; NSTRUCT 変数を確保
st->AllocationProtect = 100
mes "AllocationProtect=" + st->AllocationProtect
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。