Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › MEM_RANGE

MEM_RANGE

構造体
サイズx64: 36 バイト / x86: 36 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
MR_AlignULONGLONG8+0+0メモリ範囲のアライメント要件を示すビットマスク。
MR_nBytesDWORD4+8+8要求するメモリ範囲のバイト数。
MR_MinULONGLONG8+12+12許容される物理アドレスの下限値。
MR_MaxULONGLONG8+20+20許容される物理アドレスの上限値。
MR_FlagsMD_FLAGS4+28+28メモリ記述子のフラグ群(MD_FLAGS)。
MR_ReservedDWORD4+32+32システム内部利用の予約領域。

各言語での定義

#include <windows.h>

// MEM_RANGE  (x64 36 / x86 36 バイト)
#pragma pack(push, 1)
typedef struct MEM_RANGE {
    ULONGLONG MR_Align;
    DWORD MR_nBytes;
    ULONGLONG MR_Min;
    ULONGLONG MR_Max;
    MD_FLAGS MR_Flags;
    DWORD MR_Reserved;
} MEM_RANGE;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct MEM_RANGE
{
    public ulong MR_Align;
    public uint MR_nBytes;
    public ulong MR_Min;
    public ulong MR_Max;
    public uint MR_Flags;
    public uint MR_Reserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure MEM_RANGE
    Public MR_Align As ULong
    Public MR_nBytes As UInteger
    Public MR_Min As ULong
    Public MR_Max As ULong
    Public MR_Flags As UInteger
    Public MR_Reserved As UInteger
End Structure
import ctypes
from ctypes import wintypes

class MEM_RANGE(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("MR_Align", ctypes.c_ulonglong),
        ("MR_nBytes", wintypes.DWORD),
        ("MR_Min", ctypes.c_ulonglong),
        ("MR_Max", ctypes.c_ulonglong),
        ("MR_Flags", wintypes.DWORD),
        ("MR_Reserved", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct MEM_RANGE {
    pub MR_Align: u64,
    pub MR_nBytes: u32,
    pub MR_Min: u64,
    pub MR_Max: u64,
    pub MR_Flags: u32,
    pub MR_Reserved: u32,
}
import "golang.org/x/sys/windows"

type MEM_RANGE struct {
	MR_Align uint64
	MR_nBytes uint32
	MR_Min uint64
	MR_Max uint64
	MR_Flags uint32
	MR_Reserved uint32
}
type
  MEM_RANGE = packed record
    MR_Align: UInt64;
    MR_nBytes: DWORD;
    MR_Min: UInt64;
    MR_Max: UInt64;
    MR_Flags: DWORD;
    MR_Reserved: DWORD;
  end;
const MEM_RANGE = extern struct {
    MR_Align: u64,
    MR_nBytes: u32,
    MR_Min: u64,
    MR_Max: u64,
    MR_Flags: u32,
    MR_Reserved: u32,
};
type
  MEM_RANGE {.packed.} = object
    MR_Align: uint64
    MR_nBytes: uint32
    MR_Min: uint64
    MR_Max: uint64
    MR_Flags: uint32
    MR_Reserved: uint32
align(1)
struct MEM_RANGE
{
    ulong MR_Align;
    uint MR_nBytes;
    ulong MR_Min;
    ulong MR_Max;
    uint MR_Flags;
    uint MR_Reserved;
}

HSP用 定義

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

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

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