ホーム › System.Memory › WIN32_MEMORY_REGION_INFORMATION
WIN32_MEMORY_REGION_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| AllocationBase | void* | 8/4 | +0 | +0 | 割り当てのベースアドレスです。 |
| AllocationProtect | DWORD | 4 | +8 | +4 | 割り当てが作成されたときに指定されたページ保護値です。割り当て内の個々のページの保護は、この値と異なる場合があります。個々のページの保護値を照会するには、VirtualQuery 関数を使用してください。 |
| Anonymous | _Anonymous_e__Union | 8/4 | +16 | +8 | リージョンの状態フラグ(Private/MappedImage等)を保持する無名共用体。 |
| RegionSize | UINT_PTR | 8/4 | +24 | +12 | 割り当てのサイズです。 |
| CommitSize | UINT_PTR | 8/4 | +32 | +16 | 割り当てに関連付けられたコミットチャージです。プライベートな割り当ての場合、これは領域内で予約済みではなくコミット済みであるページの合計サイズです。マップドビューの場合、これはコピーオンライト保護を持つページ、またはコピーオンライトの結果としてプライベートになったページの合計サイズです。 |
共用体: _Anonymous_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Flags | DWORD | 4 | +0 | +0 | すべてのメモリ領域フラグを単一の ULONG 値として表します。アプリケーションはこのフィールドを使用しないでください。代わりに、以下で定義されている個々のビットフィールドフラグをテストしてください。 |
| Anonymous | _Anonymous_e__Struct | 8/4 | +0 | +0 | リージョンの状態フラグ(Private/MappedImage等)を保持する無名共用体。 |
公式ドキュメント
メモリ領域に関する情報を格納します。メモリ領域とは、VirtualAlloc や MapViewOfFile などのメモリ割り当て関数を使用して作成された単一の割り当てのことです。
解説(Remarks)
WIN32_MEMORY_REGION_INFORMATION 構造体は、単一のメモリ割り当てに関する情報を格納します。これに対して、VirtualQuery 関数によって返される MEMORY_BASIC_INFORMATION 構造体は、単一の割り当て内で、型、状態、保護がすべて同じである連続したページの並びを記述します。WIN32_MEMORY_REGION_INFORMATION のフィールドと VirtualQuery が返すメモリ型の値との対応は次のとおりです。
| WIN32_MEMORY_REGION_INFORMATION | MEMORY_BASIC_INFORMATION::Type |
|---|---|
| Private | MEM_PRIVATE |
| MappedDataFile | MEM_MAPPED |
| MappedImage | MEM_IMAGE |
| MappedPageFile | MEM_MAPPED |
| MappedPhysical | MEM_MAPPED |
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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 Structureimport 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: uintstruct 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 非対応)。必要に応じ手動でアクセス。